IBHNet:Accessing PLC variables
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 |
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 | 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 |
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 |
Systemfunktionen der Schnittstelle IIIBHnet2 | S5 | S7 300/400 |
SoftSPS und S7-CX |
S7 200 |
Neustart (Reboot) des IBH Link HRESULT ResetDevice(BSTR device) device: Stationsname Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene Baugruppe die Funktion nicht untertützt. |
- | X | X | X |
Liest die Position des Schlüsselschalters der SPS aus HRESULT Key_Position([out, retval] long *pVal) pVal: gibt die Schalterstellung zurück Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene SPS die Funktion nicht untertützt. |
- | X | X | - |
Ermittelt die am Bus erreichbaren Teilnehmer HRESULT LifeList(BSTR device, VARIANT * lifelist) lifelist: enthält die Liste der Teilnehmer, 0x30 = Aktiv, 0x20 = Aktiv Ready, 0x10 = Nicht vorhanden, 0x00 = Passiv Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene SPS die Funktion nicht untertützt. |
- | X | X | X |
Liest Systemzustandslisten aus der SPS aus HRESULT SZ_List(long SZL_ID, long INDEX, VARIANT * SZ_List) 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. Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. E_NOTIMPL wird zurückgegeben, wenn die angeschlossene SPS die Funktion nicht untertützt. |
- | X | X | - |
Beendet den Treiber IBH_NetPcom.exe HRESULT TerminateDriver() Rückgabewert: Immer S_OK Bei den Protokollen RFC1006, API oder 1200 nicht relevant. |
- | X | X | X |
Erweiterte Funktionen und .NET der Schnittstelle IIIBHnet3 | S5 | S7 300/400 |
SoftSPS und S7-CX |
S7 200 |
Verbindung zur SPS aufbauen HRESULT Connect_DP(BSTR Station, long DPAdr, long Rack, long Slot) Station: Stationsname DPAdr: MPI® bzw. Profibusadresse Rack: Baugruppenträger Nummer (normalerweise 0) Slot: Steckplatz. Bei MPI meistens 0, bei Profibus der Steckplatz der CPU im Rack. Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. 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. |
- | X | - | - |
Geroutete Verbindung zur SPS in abgesetzte MPI/Profibus-Netzwerke aufbauen, sofern die CPU dies unterstützt HRESULT Subnet_Connect_DP(BSTR Station, long MPIStart, long MPIZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL) Station: Stationsname MPIStart: MPI® bzw. Profibusadresse, auf die der IBH Link aufgesteckt ist. MPIZiel: MPI® bzw. Profibusadresse, auf die im Subnetz geroutet werden soll. RackZiel: Baugruppenträger Nummer der Baugrupp im Zielsubnetz (normalerweise 0) SlotZiel: Steckplatz der CPU im Zielsubnetz (normalerweise 2). Subnet_HH: Subnet ID HighWort, aus Projekt. Subnet_LL: Subnet ID LowWort, aus Projekt. Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. 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. |
- | X | - | - |
Geroutete Verbindung zur SPS in abgesetzte TCP/IP-Netzwerke aufbauen, sofern die CPU dies unterstützt HRESULT Subnet_Connect_IP(BSTR Station, long MPIStart, BSTR IPZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL) Station: Stationsname MPIStart: MPI® bzw. Profibusadresse, auf die der IBH Link aufgesteckt ist. IPZiel: TCP/IP Adresse, auf die im Subnetz geroutet werden soll. RackZiel: Baugruppenträger Nummer der Baugrupp im Zielsubnetz (normalerweise 0) SlotZiel: Steckplatz der CPU im Zielsubnetz (normalerweise 2). Subnet_HH: Subnet ID HighWort, aus Projekt. Subnet_LL: Subnet ID LowWort, aus Projekt. Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. 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. |
- | X | - | - |
Geroutete Verbindung zur SPS in abgesetzte H1-Netzwerke aufbauen, sofern die CPU dies unterstützt HRESULT SubnetConnectH1(BSTR Station, long MPIStart, BSTR H1Ziel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL) Station: Stationsname MPIStart: MPI® bzw. Profibusadresse, auf die der IBH Link aufgesteckt ist. H1Ziel: H1 Adresse, auf die im Subnetz geroutet werden soll. RackZiel: Baugruppenträger Nummer der Baugrupp im Zielsubnetz (normalerweise 0) SlotZiel: Steckplatz der CPU im Zielsubnetz (normalerweise 2). Subnet_HH: Subnet ID HighWort, aus Projekt. Subnet_LL: Subnet ID LowWort, aus Projekt. Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler. 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. |
- | X | - | - |
Liest die Rohdaten eines Datenbausteins, wie dieser auf der SPS abliegt, aus. HRESULT ReadDB(long DBNr, VARIANT*DB, long * Len) DBNr: Datenbausteinnummer DB: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp Byte enthält mit dem Bausteininhalt. Len: Länge der Bausteines Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_INVALIDARG wenn der Datenbaustein nicht existiert. 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. |
X | X | X | - |
Schreibt die Rohdaten eines Datenbausteins, wie dieser auf der SPS abliegt. HRESULT WriteDB(long DBNr, VARIANT DB, long Len) DBNr: Datenbausteinnummer DB: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp Byte enthält mit dem Bausteininhalt. Len: Länge der Bausteines Rückgabewert: S_OK bei Erfolg, E_FAIL bei Fehler, E_INVALIDARG wenn der Datenbaustein nicht existiert 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. |
X | X | X | - |
Blockweise Lesen von Werten aus der SPS HRESULT DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals) DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals) typ: (E)ingang = 69d, (A)usgang = 65d, (M)erker = 77d, (D)atenbaustein = 68d nr: Startadresse bei EAM, bei D die Startadresse im DB DBNr: Datenbausteinnumer bei typ=D (68d), bei EAM 0 size: Anzahl der zu lesenden Bytes vals: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp BYTE enthält mit den daten aus der SPS. 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. 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. |
X | X | X | X |
Blockweise Schreiben von Werten in die SPS HRESULT DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals) DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals) typ: (E)ingang = 69d, (A)usgang = 65d, (M)erker = 77d, (D)atenbaustein = 68d nr: Startadresse bei EAM, bei D die Startadresse im DB DBNr: Datenbausteinnumer bei typ=D (68d), bei EAM 0 size: Anzahl der zu lesenden Bytes vals: VARIANT Variable, die wiederum ein SAFEARRAY vom Datentyp BYTE mit den Daten enthält. 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. 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. |
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.