Difference between revisions of "IBHNet:Accessing PLC variables"

From IBHsoftec Wiki English
Jump to: navigation, search
(Created page with "== Accessing PLC variables == The '''''IBHNet''''' network driver ships with an object, which allows access to variables of the PLC. This COM-Server can be used in any progra...")
 
 
(7 intermediate revisions by 2 users not shown)
Line 19: Line 19:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Search further configured stations<br />'''HRESULT NextStation(BSTR* pVal)'''<br />pVal: Station name<br />Return Value: Successful operation returns S_OK<br /><br />If no further station exists, S_FALSE is returned.
+
|Search further configured stations<br />'''HRESULT NextStation(BSTR* pVal)'''<br />pVal: Station name<br />Return Value: Successful operation returns S_OK<br />If no further station exists, S_FALSE is returned.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 26: Line 26:
 
|-
 
|-
 
|
 
|
Set up PLC connection<br />'''HRESULT Connect([in, string] BSTR Station,[in] long MPIAdr)'''<br />Station: Station Name<br />MPIAdr: MPI Addrerss<br />Return Value: Successful operation returns S_OK, E_FAIL or the sequence number if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferd to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
+
Set up PLC connection<br />'''HRESULT Connect([in, string] BSTR Station,[in] long MPIAdr)'''<br />Station: Station Name<br />MPIAdr: MPI Addrerss<br />Return Value: Successful operation returns S_OK, E_FAIL or the sequence number if failed.<br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 90: Line 90:
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
|align="center"| X
+
|align="center"| -
 
|-
 
|-
 
|Reads the revision of the SoftPLC.<br />'''HRESULT PLC_Version([out, retval] long *pVal)'''<br />pVal: reports the revision.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
 
|Reads the revision of the SoftPLC.<br />'''HRESULT PLC_Version([out, retval] long *pVal)'''<br />pVal: reports the revision.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
Line 218: Line 218:
 
|
 
|
 
|-
 
|-
! '''Eigenschaften für den Variablenzugriff'''
+
! '''Properties for PLC variable access'''
 +
Each of the functions listed below initiates a full read respectively write sequence with the PLC. It should be mentioned that reading or writing entire arrays of variables take only a negligible amount of time longer than reading/writing single variables. For this reason, it should be considered to collect all data in a single area of the PLC. This way complete array can be read/written, which may dramatically increase performance.
  
Es ist zu beachten, das jede der nachfolgend gelisteten Funktionen ein kompletten Lese- bzw. Schreibzugriff zur Steuerung durchführt. Man sollte daher versuchen, die zu lesenden bzw. zu schreibenden Bereiche in der SPS zusammenzufassen, damit diese als kompletter Block gelesen bzw. geschrieben werden können. Lesen bzw. Schreiben kompletter Blöcke über ReadVals / WriteVals dauert nur unwesentlich länger, als das Lesen bzw. Schreiben einer einzelnen Variablen.
 
 
!align="center"| S5  
 
!align="center"| S5  
 
!align="center"| S7 <br/> 300/400  
 
!align="center"| S7 <br/> 300/400  
!align="center"| SoftSPS <br/> und <br/> S7-CX  
+
!align="center"| SoftSPS <br/> and <br/> S7-CX  
 
!align="center"| S7 <br/> 200
 
!align="center"| S7 <br/> 200
 
|-
 
|-
|Liest ein Merkerdoppelwort<br />'''HRESULT MD(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Merkerdoppelworts<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Merkerdoppelwort<br />'''HRESULT MD(long nr, [in] long newVal)'''<br />nr: Nummer des Merkerdoppelworts<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a flag doubleword<br />'''HRESULT MD(long nr, [out, retval] long *pVal)'''<br />nr: Number of the flag doubleword<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a flag doubleword<br />'''HRESULT MD(long nr, [in] long newVal)'''<br />nr: Number of the flag doubleword<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 232: Line 232:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Merkerwort<br />'''HRESULT MW(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Merkerworts<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Merkerwort<br />'''HRESULT MW(long nr, [in] long newVal)'''<br />nr: Nummer des MerkerWorts<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a flag word<br />'''HRESULT MW(long nr, [out, retval] long *pVal)'''<br />nr: Number of the flag word<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a flag word<br />'''HRESULT MW(long nr, [in] long newVal)'''<br />nr: Number of the flag word<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 238: Line 238:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Merkerbyte<br />'''HRESULT MB(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Merkerbytes<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Merkerbyte<br />'''HRESULT MB(long nr, [in] long newVal)'''<br />nr: Nummer des Merkerbytes<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a flag byte<br />'''HRESULT MB(long nr, [out, retval] long *pVal)'''<br />nr: Number of the flag byte <br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a flag byte<br />'''HRESULT MB(long nr, [in] long newVal)'''<br />nr: Number of the flag byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 244: Line 244:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Merkerbit<br />'''HRESULT M(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Adresse des Merkerbytes<br />bit: Bitnummer im Merkerbyte<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Merkerbit<br />'''HRESULT M(long nr,long bit, [in] BOOL newVal)'''<br />nr: Adresse des Merkerbytes<br />bit: Bitnummer im Merkerbyte<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a flag<br />'''HRESULT M(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Number of the flag byte<br />bit: Bit number in the flag byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. <br /><br />Writes a flag<br />'''HRESULT M(long nr,long bit, [in] BOOL newVal)'''<br />nr: Number of the flag byte<br />bit: Bit number in the flag byte<br />newVal: Value to write <br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 250: Line 250:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Eingangsdoppelwort<br />'''HRESULT ED(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Eingangsdoppelworts<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Eingangsdoppelwort<br />'''HRESULT ED(long nr, [in] long newVal)'''<br />nr: Nummer des Eingangsdoppelworts<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a input doubleword<br />'''HRESULT ED(long nr, [out, retval] long *pVal)'''<br />nr: Number of the input doubleword<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a input doubleword<br />'''HRESULT ED(long nr, [in] long newVal)'''<br />nr: Number of the input doubleword<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 256: Line 256:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Eingangswort<br />'''HRESULT EW(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Eingangsworts<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Eingangsdoppelwort<br />'''HRESULT EW(long nr, [in] long newVal)'''<br />nr: Nummer des Eingangsworts<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a input word<br />'''HRESULT EW(long nr, [out, retval] long *pVal)'''<br />nr: Number of the input word<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a input word<br />'''HRESULT EW(long nr, [in] long newVal)'''<br />nr: Number of the input word<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 262: Line 262:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Eingangsbyte<br />'''HRESULT EB(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Eingangsbytes<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Eingangsbyte<br />'''HRESULT EB(long nr, [in] long newVal)'''<br />nr: Nummer des Eingangsbytes<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a input byte<br />'''EB(long nr, [out, retval] long *pVal)'''<br />nr: Number of the input byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a input byte<br />'''EB(long nr, [in] long newVal)'''<br />nr: Number of the input byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 268: Line 268:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Eingangsbit<br />'''HRESULT E(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Adresse des Eingangsbytes<br />bit: Bitnummer im Eingangsbyte<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Eingangsbit<br />'''HRESULT E(long nr,long bit, [in] BOOL newVal)'''<br />nr: Adresse des Eingangsbytes<br />bit: Bitnummer im Eingangsbyte<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads an input<br />'''E(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Number of the input byte<br />bit: Bit number in the input byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes an input<br />'''E(long nr,long bit, [in] BOOL newVal)'''<br />nr: Number of the input byte<br />bit: Bit number in the input byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 274: Line 274:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Ausgangsdoppelwort<br />'''HRESULT AD(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Ausgangsdoppelworts<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Ausgangsdoppelwort<br />'''HRESULT AD(long nr, [in] long newVal)'''<br />nr: Nummer des Ausgangsdoppelworts<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a output doubleword<br />'''HRESULT AD(long nr, [out, retval] long *pVal)'''<br />nr: Number of the output doubleword<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a output doubleword<br />'''HRESULT AD(long nr, [in] long newVal)'''<br />nr: Number of the output doubleword<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 280: Line 280:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Ausgangswort<br />'''HRESULT AW(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Ausgangsworts<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Ausgangswort<br />'''HRESULT AW(long nr, [in] long newVal)'''<br />nr: Nummer des AusgangsWorts<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|
 +
Reads a output word<br />'''HRESULT AW(long nr, [out, retval] long *pVal)'''<br />nr: Number of the output word<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a output word<br />'''HRESULT AW(long nr, [in] long newVal''')<br />nr: Number of the output word<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 286: Line 287:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Ausgangsbyte<br />'''HRESULT AB(long nr, [out, retval] long *pVal)'''<br />nr: Nummer des Ausgangsbytes<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.<br /><br />Schreibt ein Ausgangsbyte<br />'''HRESULT AB(long nr, [in] long newVal)'''<br />nr: Nummer des Ausgangsbytes<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads a output byte<br />'''HRESULT AB(long nr, [out, retval] long *pVal)'''<br />nr: Number of the output byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a output byte<br />'''HRESULT AB(long nr, [in] long newVal)'''<br />nr: Number of the output byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 292: Line 293:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Ausgangsbit<br />'''HRESULT A(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Adresse des Ausgangsbytes<br />bit: Bitnummer im Ausgangsbytes<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist. <br /><br />Schreibt ein Ausgangsbit<br />'''HRESULT A(long nr,long bit, [in] BOOL newVal)'''<br />nr: Adresse des Ausgangsbytes<br />bit: Bitnummer im Ausgangsbyte<br />newVal: Zu schreibender Wert<br /> Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich zu klein ist.
+
|Reads an output<br />'''HRESULT A(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Number of the output byte<br />bit: Bit number in the output byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes an output<br />'''HRESULT A(long nr,long bit, [in] BOOL newVal)'''<br />nr: Number of the output byte<br />bit: Bit number in the output byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 298: Line 299:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Datendoppelwort<br />'''HRESULT DD(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.<br /><br />Schreibt ein Datendoppelwort<br />'''HRESULT DD(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.
+
|Reads a data doubleword<br />'''HRESULT DD(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data doubleword<br />'''HRESULT DD(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 304: Line 305:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Datenwort<br />'''HRESULT DW(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.<br /><br />Schreibt ein Datenwort<br />'''HRESULT DW(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.
+
|Reads a data word<br />'''HRESULT DW(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data word<br />'''HRESULT DW(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 310: Line 311:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Datenbyte<br />'''HRESULT DB(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.<br /><br />Schreibt ein Datenbyte<br />'''HRESULT DB(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.
+
|Reads a data byte<br />'''HRESULT DB(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data byte<br />'''HRESULT DB(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 316: Line 317:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest ein Datenbit<br />'''HRESULT D(long DBNr,long nr,long bit, [out, retval] BOOL *pVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />bit: Bitnummer im Datenbyte<br />pVal: Gelesener Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist. <br /><br />Schreibt ein Datenbit<br />'''HRESULT D(long DBNr,long nr,long bit, [in] BOOL newVal)'''<br />DBNr: Nummer des Datenbausteins<br />nr: Byte-Offset im Datenbaustein<br />bit: Bitnummer im Datenbyte<br />newVal: Zu schreibender Wert<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.
+
|Reads a data bit<br />'''HRESULT D(long DBNr,long nr,long bit, [out, retval] BOOL *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />bit: Bit number within the data byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data bit<br />'''HRESULT D(long DBNr,long nr,long bit, [in] BOOL newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />bit: Bit number within the data byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 328: Line 329:
 
|
 
|
 
|-
 
|-
!'''Systemfunktionen der Schnittstelle IIIBHnet2
+
!'''System Functions of the Interface IIIBHnet2'''
 
!align="center"| S5  
 
!align="center"| S5  
 
!align="center"| S7 <br/> 300/400  
 
!align="center"| S7 <br/> 300/400  
!align="center"| SoftSPS <br/> und <br/> S7-CX  
+
!align="center"| SoftSPS <br/> and <br/> S7-CX  
 
!align="center"| S7 <br/> 200
 
!align="center"| S7 <br/> 200
 
|-
 
|-
|Neustart (Reboot) des IBH Link<br />'''HRESULT ResetDevice(BSTR device)'''<br />device: Stationsname<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene Baugruppe die Funktion nicht untertützt.
+
|Reboot of the IBH Link.<br />'''HRESULT ResetDevice(BSTR device)'''<br />device: Station name.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected module does not support the function.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 340: Line 341:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest die Position des Schlüsselschalters der SPS aus<br />'''HRESULT Key_Position([out, retval] long *pVal)'''<br />pVal: gibt die Schalterstellung zurück<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene SPS die Funktion nicht untertützt.
+
|Reads the key switch position of the PLC.<br />'''HRESULT Key_Position([out, retval] long *pVal)'''<br />pVal: returns the key switch position.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 346: Line 347:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Ermittelt die am Bus erreichbaren Teilnehmer<br />'''HRESULT LifeList(BSTR device, VARIANT * lifelist)'''<br />lifelist: enthält die Liste der Teilnehmer, 0x30 = Aktiv, 0x20 = Aktiv Ready, 0x10 = Nicht vorhanden, 0x00 = Passiv<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene SPS die Funktion nicht untertützt.
+
|Reads the available nodes on the bus.<br />'''HRESULT LifeList(BSTR device, VARIANT * lifelist)'''<br />lifelist: contains a list with the nodes.<br />0x30 = Active, 0x20 = Active Ready, 0x10 = Not existing, 0x00 = Passive<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 352: Line 353:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Liest Systemzustandslisten aus der SPS aus<br />'''HRESULT SZ_List(long SZL_ID, long INDEX, VARIANT * SZ_List)'''<br />Siehe hierzu die Siemens Dokumentation zur SFC51. Installationsverzeichnis: C:\Program Files\Siemens\Dokumentation\Deutsch\STEP 7 - System- und Standardfunktionen für S7-300 und S7-400 Kapitel: Systemzustandsliste SZL.<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene SPS die Funktion nicht untertützt.
+
|Reads the System Status Lists (SSL) from the PLC.<br />'''HRESULT SZ_List(long SZL_ID, long INDEX, VARIANT * SZ_List)'''<br />For more information please consult the Siemens dokumentation for the SFC51. Installation folder: C:\Program Files\Siemens\Dokumentation\English\STEP 7 - System and Standard Functions for S7-300 and S7-400 Chapter: System Status Lists (SSL).<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 358: Line 359:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Beendet den Treiber IBH_NetPcom.exe<br />'''HRESULT TerminateDriver()'''<br />Rückgabewert: Immer S_OK<br /><br />Bei den Protokollen RFC1006, API oder 1200 nicht relevant.
+
|Terminates the driver IBH_NetPcom.exe.<br />'''HRESULT TerminateDriver()'''<br />Return Value: Always S_OK.<br /><br />For the Protocols RFC1006, API or 1200 irrelevant.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 370: Line 371:
 
|
 
|
 
|-
 
|-
!'''Erweiterte Funktionen und .NET der Schnittstelle IIIBHnet3'''
+
!'''Advanced functions and .NET of the Interface IIIBHnet3'''
 
!align="center"| S5  
 
!align="center"| S5  
 
!align="center"| S7 <br/> 300/400  
 
!align="center"| S7 <br/> 300/400  
!align="center"| SoftSPS <br/> und <br/> S7-CX  
+
!align="center"| SoftSPS <br/> and <br/> S7-CX  
 
!align="center"| S7 <br/> 200
 
!align="center"| S7 <br/> 200
 
|-
 
|-
|Verbindung zur SPS aufbauen<br />'''HRESULT Connect_DP(BSTR Station, long DPAdr, long Rack, long Slot)'''<br />Station: Stationsname<br />DPAdr: MPI<sup>®</sup> bzw. Profibusadresse<br />Rack: Baugruppenträger Nummer (normalerweise 0)<br />Slot: Steckplatz. Bei MPI meistens 0, bei Profibus der Steckplatz der CPU im Rack.<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler.<br /><br />Die Funktion Connect_DP aus dem Interface IIIBHNet3 sollte zum Verbindungsaufbau vorgezogen werden da diese bei Misserfolg in Programmiersprachen wie VisualBasic oder C# immer eine Exeption auslöst.
+
|Set up PLC connection.<br />'''HRESULT Connect_DP(BSTR Station, long DPAdr, long Rack, long Slot)'''<br />Station: Station name<br />DPAdr: MPI<sup>®</sup> or Profibus address<br />Rack: Rack number (normally 0)<br />Slot: Slot number. For MPI normally 0, for Profibus the slot number of the CPU inside the rack.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.<br />If the protocol RFC1006 is chosen in the IBHNet station, the parameter DPAdr is irrelevant. For connections to a Siemens CP, only the parameters Rack and Slot are regarded. With an IBH Link S7++, the MPI/Profibusaddress is a combination from the lower 5 Bit of the parameter Slot and the lower 3 Bit of the parameter Rack.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 382: Line 383:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Geroutete Verbindung zur SPS in abgesetzte MPI/Profibus-Netzwerke aufbauen, sofern die CPU dies unterstützt<br />'''HRESULT Subnet_Connect_DP(BSTR Station, long MPIStart, long MPIZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Stationsname<br />MPIStart: MPI<sup>®</sup> bzw. Profibusadresse, auf die der IBH Link aufgesteckt ist.<br />MPIZiel: MPI<sup>®</sup> bzw. Profibusadresse, auf die im Subnetz geroutet werden soll.<br />RackZiel: Baugruppenträger Nummer der Baugrupp im Zielsubnetz (normalerweise 0)<br />SlotZiel: Steckplatz der CPU im Zielsubnetz (normalerweise 2).<br />Subnet_HH: Subnet ID HighWort, aus Projekt.<br />Subnet_LL: Subnet ID LowWort, aus Projekt.<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler.<br /><br />Die Funktion Connect_DP aus dem Interface IIIBHNet3 sollte zum Verbindungsaufbau vorgezogen werden da diese bei Misserfolg in Programmiersprachen wie VisualBasic oder C# immer eine Exeption auslöst.
+
|Set up a routed PLC connection to a PLC in a MPI/Profibus subnet, if the CPU supports it.<br />'''HRESULT Subnet_Connect_DP(BSTR Station, long MPIStart, long MPIZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Station name<br />MPIStart: MPI<sup>®</sup> or Profibus address, the IBH Link is connected to.<br />MPIZiel: Destination MPI<sup>®</sup> or Profibus address inside the subnet.<br />RackZiel: Destination rack number in the subnet (normally 0).<br />SlotZiel: Destination slot number in the subnet (normally 2).<br />Subnet_HH: Subnet ID HighWord, from Project.<br />Subnet_LL: Subnet ID LowWord, from Project.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 388: Line 389:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Geroutete Verbindung zur SPS in abgesetzte TCP/IP-Netzwerke aufbauen, sofern die CPU dies unterstützt<br />'''HRESULT Subnet_Connect_IP(BSTR Station, long MPIStart, BSTR IPZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Stationsname<br />MPIStart: MPI<sup>®</sup> bzw. Profibusadresse, auf die der IBH Link aufgesteckt ist.<br />IPZiel: TCP/IP Adresse, auf die im Subnetz geroutet werden soll.<br />RackZiel: Baugruppenträger Nummer der Baugrupp im Zielsubnetz (normalerweise 0)<br />SlotZiel: Steckplatz der CPU im Zielsubnetz (normalerweise 2).<br />Subnet_HH: Subnet ID HighWort, aus Projekt.<br />Subnet_LL: Subnet ID LowWort, aus Projekt.<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler.<br /><br />Die Funktion Connect_DP aus dem Interface IIIBHNet3 sollte zum Verbindungsaufbau vorgezogen werden da diese bei Misserfolg in Programmiersprachen wie VisualBasic oder C# immer eine Exeption auslöst.
+
|Set up a routed PLC connection to a PLC in a TCP/IP subnet, if the CPU supports it.<br />'''HRESULT Subnet_Connect_IP(BSTR Station, long MPIStart, BSTR IPZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Station name<br />MPIStart: MPI<sup>®</sup> or Profibus address, the IBH Link is connected to.<br />IPZiel: Destination TCP/IP address inside the subnet.<br />RackZiel: Destination rack number in the subnet (normally 0).<br />SlotZiel: Destination slot number in the subnet (normally 2).<br />Subnet_HH: Subnet ID HighWord, from Project.<br />Subnet_LL: Subnet ID LowWord, from Project.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 394: Line 395:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Geroutete Verbindung zur SPS in abgesetzte H1-Netzwerke aufbauen, sofern die CPU dies unterstützt<br />'''HRESULT SubnetConnectH1(BSTR Station, long MPIStart, BSTR H1Ziel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Stationsname<br />MPIStart: MPI<sup>®</sup> bzw. Profibusadresse, auf die der IBH Link aufgesteckt ist.<br />H1Ziel: H1 Adresse, auf die im Subnetz geroutet werden soll.<br />RackZiel: Baugruppenträger Nummer der Baugrupp im Zielsubnetz (normalerweise 0)<br />SlotZiel: Steckplatz der CPU im Zielsubnetz (normalerweise 2).<br />Subnet_HH: Subnet ID HighWort, aus Projekt.<br />Subnet_LL: Subnet ID LowWort, aus Projekt.<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler.<br /><br />Die Funktion Connect_DP aus dem Interface IIIBHNet3 sollte zum Verbindungsaufbau vorgezogen werden da diese bei Misserfolg in Programmiersprachen wie VisualBasic oder C# immer eine Exeption auslöst.
+
|Set up a routed PLC connection to a PLC in a H1 subnet, if the CPU supports it.<br />'''HRESULT SubnetConnectH1(BSTR Station, long MPIStart, BSTR H1Ziel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Station name<br />MPIStart: MPI<sup>®</sup> or Profibus address, the IBH Link is connected to.<br />H1Ziel: Destination H1 address inside the subnet.<br />RackZiel: Destination rack number in the subnet (normally 0).<br />SlotZiel: Destination slot number in the subnet (normally 2).<br />Subnet_HH: Subnet ID HighWord, from Project.<br />Subnet_LL: Subnet ID LowWord, from Project.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
 
|align="center"| -  
 
|align="center"| -  
 
|align="center"| X  
 
|align="center"| X  
Line 400: Line 401:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Liest die Rohdaten eines Datenbausteins, wie dieser auf der SPS abliegt, aus.<br />'''HRESULT ReadDB(long DBNr, VARIANT*DB, long * Len)'''<br />DBNr: Datenbausteinnummer<br />DB: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp Byte enthält mit dem Bausteininhalt.<br />Len: Länge der Bausteines<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_INVALIDARG wenn der Datenbaustein nicht existiert.<br /><br />Um diese Funktion verwenden zu können sind detaillierte Kenntnisse des S7-Bausteinaufbaus erforderlich. Aus rechtlichen Gründen können diese von IBHsoftec nicht veröffentlicht werden.
+
|Reads the raw contents of a datablock from the PLC.<br />'''HRESULT ReadDB(long DBNr, VARIANT*DB, long * Len)'''<br />DBNr: Data block number<br />DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block.<br />Len: Block length<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist.<br /><br />To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 406: Line 407:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Schreibt die Rohdaten eines Datenbausteins, wie dieser auf der SPS abliegt.<br />'''HRESULT WriteDB(long DBNr, VARIANT DB, long Len)'''<br />DBNr: Datenbausteinnummer<br />DB: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp Byte enthält mit dem Bausteininhalt.<br />Len: Länge der Bausteines<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_INVALIDARG wenn der Datenbaustein nicht existiert<br /><br />Um diese Funktion verwenden zu können sind detaillierte Kenntnisse des S7-Bausteinaufbaus erforderlich. Aus rechtlichen Gründen können diese von IBHsoftec nicht veröffentlicht werden.
+
|Writes the raw contents of a datablock to a PLC.<br />'''HRESULT WriteDB(long DBNr, VARIANT DB, long Len)'''<br />DBNr: Data block number<br />DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block.<br />Len: Block length<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist. <br />To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 412: Line 413:
 
|align="center"| -
 
|align="center"| -
 
|-
 
|-
|Blockweise Lesen von Werten aus der SPS<br />'''HRESULT DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals)'''<br />DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals)<br />typ: (E)ingang = 69d, (A)usgang = 65d, (M)erker = 77d, (D)atenbaustein = 68d<br />nr: Startadresse bei EAM, bei D die Startadresse im DB<br />DBNr: Datenbausteinnumer bei typ=D (68d), bei EAM 0<br />size: Anzahl der zu lesenden Bytes<br />vals: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp BYTE enthält mit den daten aus der SPS.<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.<br /><br />In den .Net Sprachen ist der Übergabeparameter ein Objekt. Sollen Datenbereiche gelesen werden die größer sind als die auf der CPU tatsächlich vorhandenen Bereiche, so meldet die CPU dem Treiber dass der Datenbereich nicht existent ist. Die Funktion gibt in diesem Fall E_INVALIDARG zurück. Die Verbindung zur Steuerung bleibt dabei bestehen, es besteht kein Grund die Verbindung zur Steuerung zu trennen.
+
|Reads an array of values from the PLC<br />'''HRESULT DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals)'''<br />typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d<br />nr: Start offset for Input/Output/Flags, for D the start offset within the DB<br />DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0<br />size: Number of Bytes to read<br />vals: VARIANT variable, that contains a SAFEARRAY of type Byte containing the values read from the PLC.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 418: Line 419:
 
|align="center"| X
 
|align="center"| X
 
|-
 
|-
|Blockweise Schreiben von Werten in die SPS<br />'''HRESULT DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals)'''<br />DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals)<br />typ: (E)ingang = 69d, (A)usgang = 65d, (M)erker = 77d, (D)atenbaustein = 68d<br />nr: Startadresse bei EAM, bei D die Startadresse im DB<br />DBNr: Datenbausteinnumer bei typ=D (68d), bei EAM 0<br />size: Anzahl der zu lesenden Bytes<br />vals: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp BYTE mit den Daten enthält.<br />Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_ABORT wenn die SPS den Zugriff verweigert oder E_INVALIDARG wenn der Datenbereich nicht existiert oder zu klein ist.<br /><br />DotNetReadVals übergibt Daten in einer VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp Byte enthält. In den .Net Sprachen ist der Übergabeparameter ein Objekt. Sollen Datenbereiche geschrieben werden die größer sind als die auf der CPU tatsächlich vorhandenen Bereiche, so meldet die CPU dem Treiber dass der Datenbereich nicht existent ist. Die Funktion gibt in diesem Fall E_INVALIDARG zurück. Die Verbindung zur Steuerung bleibt dabei bestehen, es besteht kein Grund die Verbindung zur Steuerung zu trennen.
+
|Writes an array of values to the PLC<br />'''HRESULT DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals)'''<br />typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d<br />nr: Start offset for Input/Output/Flags, for D the start offset within the DB<br />DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0<br />size: Number of Bytes to read<br />vals: VARIANT variable, that contains a SAFEARRAY of type Byte with the values to write to the PLC<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />DotNetWriteVals passes the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC.
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
 
|align="center"| X  
Line 427: Line 428:
 
 
 
 
  
 
+
  
 +
In the installation folder of the '''''IBHNet''''' driver, samples for Visual Basic 6 can be found. The samples are commented. Samples for other programming languages will follow. Contact our product support to ask for more samples.
  
 
 
  
 
 
  
 +
{|class="wikitable"
 +
|class="hintergrundfarbe5"|'''Attention: If multiple threads need to access the same IBHNet object, the access functions to the IBHNet object need to be locked from each other. Suitable mechanisms are for instance Critical Sections, Semaphores or Mutexes. A simple locking with variables is not suitable to securely avoid race conditions.'''
 +
|-
 +
|}
  
  
In the installation folder of the '''''IBHNet''''' driver, samples for Visual Basic 6 can be found. The samples are commented. Samples for other programming languages will follow. Contact our product support to ask for more samples.
+
Following error codes will be returned:
  
<table>
+
{| class="wikitable"
<tbody>
+
|-
<tr class="odd">
+
!Errorcode
<td align="left"> </td>
+
!Description
</tr>
+
|-
<tr class="even">
+
|1
<td align="left">'''Attention: If multiple threads need to access the same IBHNet object, the access functions to the IBHNet object need to be locked from each other. Suitable mechanisms are for instance Critical Sections, Semaphores or Mutexes. A simple locking with variables is not suitable to securely avoid race conditions.'''</td>
+
|netpcomv.CreateInstance failed
</tr>
+
|-
<tr class="odd">
+
|2
<td align="left"> </td>
+
|netpcomv.MPI_open failed
</tr>
+
|-
</tbody>
+
|3
</table>
+
|netpcomv.MPI_ConnRequest failed
 +
|-
 +
|4
 +
|connection request to SoftPlc failed
 +
|-
 +
|5
 +
|netpcomv.MPI_close failed
 +
|-
 +
|}
  
Following error codes will be returned:
 
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">'''Errorcode'''</td>
 
<td align="left">'''Description'''</td>
 
</tr>
 
<tr class="even">
 
<td align="left">1</td>
 
<td align="left">netpcomv.CreateInstance failed</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">2</td>
 
<td align="left">netpcomv.MPI_open failed</td>
 
</tr>
 
<tr class="even">
 
<td align="left">3</td>
 
<td align="left">netpcomv.MPI_ConnRequest failed</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">4</td>
 
<td align="left">connection request to SoftPlc failed</td>
 
</tr>
 
<tr class="even">
 
<td align="left">5</td>
 
<td align="left">netpcomv.MPI_close failed</td>
 
</tr>
 
</tbody>
 
</table>
 
  
 
If accessing a variable fails, still an exception will be raised.
 
If accessing a variable fails, still an exception will be raised.
Line 486: Line 469:
 
It is also possible to access the LOGO! RCE versions via RFC1006. In this case the MPI address 128 has to be used in the function Connect(), for Connect_DP() the slot 128 has to be used. MPI address and rack need to be 0. The possible variables are inputs, outputs, flags, the DB1 and the order number.
 
It is also possible to access the LOGO! RCE versions via RFC1006. In this case the MPI address 128 has to be used in the function Connect(), for Connect_DP() the slot 128 has to be used. MPI address and rack need to be 0. The possible variables are inputs, outputs, flags, the DB1 and the order number.
  
<br />
+
Additional security settings are necessary with S7-1500 to permit access from IBHNet. To do so, navigate to the PLC properties 'Protection' section. There the Option: 'Connection  mechanisms - Permit Access over PUT/GET communication from remote partner' must be checked.

Latest revision as of 11:45, 9 April 2013

Accessing PLC variables

The IBHNet network driver ships with an object, which allows access to variables of the PLC. This COM-Server can be used in any programming language, such as VisualBasic, Delphi a.s.o..

Its interface name is IIIBHnet. In VisualBasic for instance, it is presented as IBHNet 1.0 Type Library from the menu "Project – References". The RFC1006 protocol should be always used to read and write variables, if possible. Only obsolete devices may require other protocols. To access variables from the PLC the methods and properties listed below are available:

 

Functions of the Interface IIIBHnet S5 S7
300/400
SoftSPS
and
S7-CX
S7
200
Search first configured station
HRESULT FirstStation(BSTR* pVal)
pVal: First Station found
Return Value: Successful operation returns S_OK, if no station exists, S_FALSE is returned.
X X X X
Search further configured stations
HRESULT NextStation(BSTR* pVal)
pVal: Station name
Return Value: Successful operation returns S_OK
If no further station exists, S_FALSE is returned.
X X X X

Set up PLC connection
HRESULT Connect([in, string] BSTR Station,[in] long MPIAdr)
Station: Station Name
MPIAdr: MPI Addrerss
Return Value: Successful operation returns S_OK, E_FAIL or the sequence number if failed.
The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.

X X X X
PLC Disconnect
HRESULT Disconnect()
Parameters: None
Return Value: Always S_OK.
X X X X
Reads a single value from the PLC
HRESULT ReadVal(long typ, long nr, long DBNr, long size, long *val)
typ : 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d
nr: Start offset for Input/Output/Flags, for D the start offset within the DB
DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0
size: 0..7 = The bit number within the byte read, 8 = Byte, 16 = Word, 32 = Doubleword
val: The value read from the PLC
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
X X X X
Reads an array of values from the PLC
HRESULT ReadVals(long typ, long nr, long DBNr, long size, SAFEARRAY(unsigned char) vals)
typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d
nr: Start offset for Input/Output/Flags, for D the start offset within the DB
DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0
size: Number of Bytes to read
vals: The array with the values read from the PLC
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

ReadVals returns the data in a SAFEARRAY from type Byte. DotNetReadVals returns the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC.
X X X X
Writes a single value from the PLC
HRESULT WriteVal(long typ, long nr, long DBNr, long size, long val)
typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d
nr: Start offset for Input/Output/Flags, for D the start offset within the DB
DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0
size: 0..7 = The bit number within the byte read, 8 = Byte, 16 = Word, 32 = Doubleword
val: The value to be written to the PLC
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
X X X X
Writes an array of values to the PLC
HRESULT WriteVals(long typ, long nr, long DBNr, long size,SAFEARRAY(unsigned char) vals)
typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d
nr: Start offset for Input/Output/Flags, for D the start offset within the DB
DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0
size: Number of Bytes to read
vals: The array with the values to write to the PLC
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

WriteVals passes the data in a SAFEARRAY from type Byte. DotNetWriteVals passes the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC.
X X X X
Writes the .bin file of the SoftPLC, containing the PLC Program.
HRESULT PLC_Store()
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the .bin file of the SoftPLC, containing the PLC Program.
HRESULT PLC_Restore()
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Properties of the interface IIIBHnet S5 S7
300/400
SoftSPS
and
S7-CX
S7
200
Reads the operational state of the PLC.
HRESULT PLC_Run([out, retval] BOOL *pVal)
pVal: TRUE = Run, FALSE = Stop
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
X X X -
Reads the revision of the SoftPLC.
HRESULT PLC_Version([out, retval] long *pVal)
pVal: reports the revision.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the number of cyles of the SoftPLC.
HRESULT PLC_Cycles([out, retval] long *pVal)
pVal: reports the current count.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Switches the PLC to Stop mode.
HRESULT PLC_Stop([in] BOOL newVal)
The parameter newVal is reserved and must be always FALSE.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
X X X -
Warm Restart of the PLC.
HRESULT PLC_Run_OB100([in] BOOL newVal)
The parameter newVal is reserved and must be always TRUE.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
X X X -
Hot Restart of the PLC.
HRESULT PLC_Run_OB101([in] BOOL newVal)
The parameter newVal is reserved and must be always TRUE.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
X X X -
Terminates the SoftPLC.
HRESULT PLC_Terminate([in] BOOL newVal)
The parameter newVal is reserved and must be always FALSE.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the serial number of the SoftPLC.
HRESULT PLC_SerialNr([out, retval] BSTR *pVal)
pVal: returns the serial number.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the user name of the SoftPLC.
HRESULT PLC_Name([out, retval] BSTR *pVal)
pVal: returns the user name.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the company name of the SoftPLC.
HRESULT PLC_Firma([out, retval] BSTR *pVal)
pVal returns the company name.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the order number of the PLC.
HRESULT PLC_Mlfb([out, retval] BSTR *pVal)
pVal: returns the company name.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
X X X -
Reads the current scan cycle time of the SoftPLC.
HRESULT PLC_CycleAct([out, retval] long *pVal)
pVal returns the cycle time.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the minimum scan cycle time of the SoftPLC.
HRESULT PLC_CycleMin([out, retval] long *pVal)
pVal: returns the minimum cycle time.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the maximum scan cycle time of the SoftPLC.
HRESULT PLC_CycleMax([out, retval] long *pVal)
pVal returns the maximum cycle time.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the maximum jitter of the SoftPLC.
HRESULT PLC_JitterMax([out, retval] long *pVal)
pVal: returns the maximum jitter.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the current jitter of the SoftPLC.
HRESULT PLC_JitterAct([out, retval] long *pVal))
pVal: returns the current jitter.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Starts the SoftPLC.
HRESULT PLC_Load([in] long newVal)
newVal: 0 = As Process, 1 = As Service, 2 = As AutoStart Service, 3 = As DemandStart Service.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Path to the configuration file PLC43.ini of the SoftPLC.
HRESULT PLC_InitPath([out, retval] BSTR *pVal)
pVal: returns the path.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the SoftPLCs memory size.
HRESULT PLC_MemTotal([out, retval] long *pVal)
pVal: returns the memory size.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Reads the SoftPLCs free memory size.
HRESULT PLC_MemFree([out, retval] long *pVal)
pVal: returns the free memory size.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- - X -
Get configured station by index.
HRESULT Station(long Nr, [out, retval] BSTR* pVal)
Nr: Station index
pVal: If the station is not found, an empty name name is returned. Return Value: Successful operation returns S_OK, if the station does not exist, S_FALSE is returned.
- X X -
Properties for PLC variable access

Each of the functions listed below initiates a full read respectively write sequence with the PLC. It should be mentioned that reading or writing entire arrays of variables take only a negligible amount of time longer than reading/writing single variables. For this reason, it should be considered to collect all data in a single area of the PLC. This way complete array can be read/written, which may dramatically increase performance.

S5 S7
300/400
SoftSPS
and
S7-CX
S7
200
Reads a flag doubleword
HRESULT MD(long nr, [out, retval] long *pVal)
nr: Number of the flag doubleword
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a flag doubleword
HRESULT MD(long nr, [in] long newVal)
nr: Number of the flag doubleword
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a flag word
HRESULT MW(long nr, [out, retval] long *pVal)
nr: Number of the flag word
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a flag word
HRESULT MW(long nr, [in] long newVal)
nr: Number of the flag word
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a flag byte
HRESULT MB(long nr, [out, retval] long *pVal)
nr: Number of the flag byte
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a flag byte
HRESULT MB(long nr, [in] long newVal)
nr: Number of the flag byte
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a flag
HRESULT M(long nr,long bit, [out, retval] BOOL *pVal)
nr: Number of the flag byte
bit: Bit number in the flag byte
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a flag
HRESULT M(long nr,long bit, [in] BOOL newVal)
nr: Number of the flag byte
bit: Bit number in the flag byte
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a input doubleword
HRESULT ED(long nr, [out, retval] long *pVal)
nr: Number of the input doubleword
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a input doubleword
HRESULT ED(long nr, [in] long newVal)
nr: Number of the input doubleword
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a input word
HRESULT EW(long nr, [out, retval] long *pVal)
nr: Number of the input word
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a input word
HRESULT EW(long nr, [in] long newVal)
nr: Number of the input word
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a input byte
EB(long nr, [out, retval] long *pVal)
nr: Number of the input byte
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a input byte
EB(long nr, [in] long newVal)
nr: Number of the input byte
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads an input
E(long nr,long bit, [out, retval] BOOL *pVal)
nr: Number of the input byte
bit: Bit number in the input byte
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes an input
E(long nr,long bit, [in] BOOL newVal)
nr: Number of the input byte
bit: Bit number in the input byte
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a output doubleword
HRESULT AD(long nr, [out, retval] long *pVal)
nr: Number of the output doubleword
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a output doubleword
HRESULT AD(long nr, [in] long newVal)
nr: Number of the output doubleword
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X

Reads a output word
HRESULT AW(long nr, [out, retval] long *pVal)
nr: Number of the output word
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a output word
HRESULT AW(long nr, [in] long newVal)
nr: Number of the output word
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

X X X X
Reads a output byte
HRESULT AB(long nr, [out, retval] long *pVal)
nr: Number of the output byte
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes a output byte
HRESULT AB(long nr, [in] long newVal)
nr: Number of the output byte
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads an output
HRESULT A(long nr,long bit, [out, retval] BOOL *pVal)
nr: Number of the output byte
bit: Bit number in the output byte
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.

Writes an output
HRESULT A(long nr,long bit, [in] BOOL newVal)
nr: Number of the output byte
bit: Bit number in the output byte
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.
X X X X
Reads a data doubleword
HRESULT DD(long DBNr,long nr, [out, retval] long *pVal)
DBNr: Number of the data block
nr: Byte offset within the data block
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

Writes a data doubleword
HRESULT DD(long DBNr,long nr, [in] long newVal)
DBNr: Number of the data block
nr: Byte offset within the data block
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
X X X X
Reads a data word
HRESULT DW(long DBNr,long nr, [out, retval] long *pVal)
DBNr: Number of the data block
nr: Byte offset within the data block
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

Writes a data word
HRESULT DW(long DBNr,long nr, [in] long newVal)
DBNr: Number of the data block
nr: Byte offset within the data block
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
X X X X
Reads a data byte
HRESULT DB(long DBNr,long nr, [out, retval] long *pVal)
DBNr: Number of the data block
nr: Byte offset within the data block
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

Writes a data byte
HRESULT DB(long DBNr,long nr, [in] long newVal)
DBNr: Number of the data block
nr: Byte offset within the data block
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
X X X X
Reads a data bit
HRESULT D(long DBNr,long nr,long bit, [out, retval] BOOL *pVal)
DBNr: Number of the data block
nr: Byte offset within the data block
bit: Bit number within the data byte
pVal: Read value
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

Writes a data bit
HRESULT D(long DBNr,long nr,long bit, [in] BOOL newVal)
DBNr: Number of the data block
nr: Byte offset within the data block
bit: Bit number within the data byte
newVal: Value to write
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.
X X X X
System Functions of the Interface IIIBHnet2 S5 S7
300/400
SoftSPS
and
S7-CX
S7
200
Reboot of the IBH Link.
HRESULT ResetDevice(BSTR device)
device: Station name.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected module does not support the function.
- X X X
Reads the key switch position of the PLC.
HRESULT Key_Position([out, retval] long *pVal)
pVal: returns the key switch position.
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- X X -
Reads the available nodes on the bus.
HRESULT LifeList(BSTR device, VARIANT * lifelist)
lifelist: contains a list with the nodes.
0x30 = Active, 0x20 = Active Ready, 0x10 = Not existing, 0x00 = Passive
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- X X X
Reads the System Status Lists (SSL) from the PLC.
HRESULT SZ_List(long SZL_ID, long INDEX, VARIANT * SZ_List)
For more information please consult the Siemens dokumentation for the SFC51. Installation folder: C:\Program Files\Siemens\Dokumentation\English\STEP 7 - System and Standard Functions for S7-300 and S7-400 Chapter: System Status Lists (SSL).
Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function.
- X X -
Terminates the driver IBH_NetPcom.exe.
HRESULT TerminateDriver()
Return Value: Always S_OK.

For the Protocols RFC1006, API or 1200 irrelevant.
- X X X
Advanced functions and .NET of the Interface IIIBHnet3 S5 S7
300/400
SoftSPS
and
S7-CX
S7
200
Set up PLC connection.
HRESULT Connect_DP(BSTR Station, long DPAdr, long Rack, long Slot)
Station: Station name
DPAdr: MPI® or Profibus address
Rack: Rack number (normally 0)
Slot: Slot number. For MPI normally 0, for Profibus the slot number of the CPU inside the rack.
Return Value: Successful operation returns S_OK, E_FAIL if failed.

The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
If the protocol RFC1006 is chosen in the IBHNet station, the parameter DPAdr is irrelevant. For connections to a Siemens CP, only the parameters Rack and Slot are regarded. With an IBH Link S7++, the MPI/Profibusaddress is a combination from the lower 5 Bit of the parameter Slot and the lower 3 Bit of the parameter Rack.
- X - -
Set up a routed PLC connection to a PLC in a MPI/Profibus subnet, if the CPU supports it.
HRESULT Subnet_Connect_DP(BSTR Station, long MPIStart, long MPIZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)
Station: Station name
MPIStart: MPI® or Profibus address, the IBH Link is connected to.
MPIZiel: Destination MPI® or Profibus address inside the subnet.
RackZiel: Destination rack number in the subnet (normally 0).
SlotZiel: Destination slot number in the subnet (normally 2).
Subnet_HH: Subnet ID HighWord, from Project.
Subnet_LL: Subnet ID LowWord, from Project.
Return Value: Successful operation returns S_OK, E_FAIL if failed.

The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
- X - -
Set up a routed PLC connection to a PLC in a TCP/IP subnet, if the CPU supports it.
HRESULT Subnet_Connect_IP(BSTR Station, long MPIStart, BSTR IPZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)
Station: Station name
MPIStart: MPI® or Profibus address, the IBH Link is connected to.
IPZiel: Destination TCP/IP address inside the subnet.
RackZiel: Destination rack number in the subnet (normally 0).
SlotZiel: Destination slot number in the subnet (normally 2).
Subnet_HH: Subnet ID HighWord, from Project.
Subnet_LL: Subnet ID LowWord, from Project.
Return Value: Successful operation returns S_OK, E_FAIL if failed.

The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
- X - -
Set up a routed PLC connection to a PLC in a H1 subnet, if the CPU supports it.
HRESULT SubnetConnectH1(BSTR Station, long MPIStart, BSTR H1Ziel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)
Station: Station name
MPIStart: MPI® or Profibus address, the IBH Link is connected to.
H1Ziel: Destination H1 address inside the subnet.
RackZiel: Destination rack number in the subnet (normally 0).
SlotZiel: Destination slot number in the subnet (normally 2).
Subnet_HH: Subnet ID HighWord, from Project.
Subnet_LL: Subnet ID LowWord, from Project.
Return Value: Successful operation returns S_OK, E_FAIL if failed.

The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.
- X - -
Reads the raw contents of a datablock from the PLC.
HRESULT ReadDB(long DBNr, VARIANT*DB, long * Len)
DBNr: Data block number
DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block.
Len: Block length
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist.

To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec.
X X X -
Writes the raw contents of a datablock to a PLC.
HRESULT WriteDB(long DBNr, VARIANT DB, long Len)
DBNr: Data block number
DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block.
Len: Block length
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist.
To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec.
X X X -
Reads an array of values from the PLC
HRESULT DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals)
typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d
nr: Start offset for Input/Output/Flags, for D the start offset within the DB
DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0
size: Number of Bytes to read
vals: VARIANT variable, that contains a SAFEARRAY of type Byte containing the values read from the PLC.
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC.
X X X X
Writes an array of values to the PLC
HRESULT DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals)
typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d
nr: Start offset for Input/Output/Flags, for D the start offset within the DB
DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0
size: Number of Bytes to read
vals: VARIANT variable, that contains a SAFEARRAY of type Byte with the values to write to the PLC
Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.

DotNetWriteVals passes the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC.
X X X X

 

   In the installation folder of the IBHNet driver, samples for Visual Basic 6 can be found. The samples are commented. Samples for other programming languages will follow. Contact our product support to ask for more samples.


Attention: If multiple threads need to access the same IBHNet object, the access functions to the IBHNet object need to be locked from each other. Suitable mechanisms are for instance Critical Sections, Semaphores or Mutexes. A simple locking with variables is not suitable to securely avoid race conditions.


Following error codes will be returned:

Errorcode Description
1 netpcomv.CreateInstance failed
2 netpcomv.MPI_open failed
3 netpcomv.MPI_ConnRequest failed
4 connection request to SoftPlc failed
5 netpcomv.MPI_close failed


If accessing a variable fails, still an exception will be raised.

It is also possible to access the LOGO! RCE versions via RFC1006. In this case the MPI address 128 has to be used in the function Connect(), for Connect_DP() the slot 128 has to be used. MPI address and rack need to be 0. The possible variables are inputs, outputs, flags, the DB1 and the order number.

Additional security settings are necessary with S7-1500 to permit access from IBHNet. To do so, navigate to the PLC properties 'Protection' section. There the Option: 'Connection mechanisms - Permit Access over PUT/GET communication from remote partner' must be checked.