1.1 - indel.ch
Transcription
1.1 - indel.ch
Inco-Server Rev 1.1 Indel AG, © 03/06/2010 INOC-Server Inhaltsverzeichnis 1 INCO-Server Introduction..............................................................................................3 2 INCO-Standard...............................................................................................................3 3 4 2.1 Access via name.............................................................................................................................3 2.2 Network wide access:....................................................................................................................3 2.3 Data Base oriented Recipe handling:...........................................................................................4 INCO-Commands...........................................................................................................4 3.1 3.1.1 3.1.2 Examples.........................................................................................................................................5 Visual Basic......................................................................................................................................5 Visual C++........................................................................................................................................6 3.2 PutBlock16......................................................................................................................................7 3.3 GetBlock16......................................................................................................................................8 3.4 GetBit...............................................................................................................................................9 3.5 PutBit.............................................................................................................................................10 3.6 Further Bit Commands.................................................................................................................11 3.7 3.7.2 Variable Commandos...................................................................................................................12 GetVariable.....................................................................................................................................14 3.8 CallProcedure................................................................................................................................15 3.9 3.9.1 3.9.2 Special functions..........................................................................................................................16 GetError..........................................................................................................................................16 GetErrorDescription........................................................................................................................16 Error Codes..................................................................................................................18 Seite 2/19 Rev 1.1 © 03/06/2010 INOC-Server 1 Inhaltsverzeichnis INCO-Server Introduction INCOServer is running on a PC. It is used for communication between applications running under Windwos or Linux and Indel-Targets. Communication can be done over serial port, Ethernet or PCI/PCIe slots. 2 INCO-Standard All INCO-commands are standardised. 2.1 Access via name The access of superordinate systems to values and variables in the target system is carried out via their names. Special attention was given to the continuity of the data. This means for each Variables and Values (e.g. a string in the input buffer of the serial interface or the occupancy of a tank but also the actual position of a motor): defined once, accessable allways and in the entire system (network wide) via their name. For practice this means: Variables and Values defined for process are used for Visualisation or Loggers, directly and without conversion. Nothing is needed but the Name of the Variable. 2.2 Network wide access: With the aid of a few handles, an application runs on as many as desired computers, independent of the location in the network. This refers not only to Local Area Networks (LAN) but also to globale Networks (WAN). Therefore, it is unimportant whether an application runs directly on the host computer or communicates via a modem connection (e.g. for a teleservicing). Rev 1.1 © 03/06/2010 Seite 3/19 INOC-Server 2.3 Data Base oriented Recipe handling: Central aim of the software design is to obtain bases and structures for an Integrated Automation. hardware configuration data, parameterization of the process, recipes and so on are stored in tables of relational data bases and are accepted and processed as such ones of the system. Date handling via tables breaks fixed structures and provides the programmer a simple way to a complete and direct influence of all data in process (from system constants up to whole recipes). In such a way, a production unit e.g. can be set to new products by a reload of the specific tables. This is executed during full operation of the system. 3 INCO-Commands INCO-Commands allow data transfer between PC-Application and Indel Targets. All commands have the same structure: Example PutBlock8(char* aSlave, uint32 aDest, uint8* aSource, uint32 aNumber); GetVariable(char* aSlave, char* aName, void* aValue, uint32 aLength=0); Put / Get PutXYZ writes data from source (PC-Application) to destination (Indel Target) GetXYZ reads data from source (Indel Target) to destination (PC-Application) Parameter aSlave Name of Indel Target. Names are defined at INCO-Registry. Return value Return values always show error codes. Zero stands for a successful command. GetErrorDescription() delivers description. Datatypes Typ Range void* void char* String-Pointer uint8 8-Bit Value: 0...255 uint16 16-Bit Value: 0...65535 unt32 32-Bit Value: 0...4294967295 uint64 64-Bit Value: 0...1.844674E19 double 64-Bit Value: -1,79769313486232E308 to -4,94065645841247E-324 (negative) 64-Bit Value: 4,94065645841247E-324 to 1,79769313486232E308 (positive) Seite 4/19 Rev 1.1 © 03/06/2010 INOC-Server Inhaltsverzeichnis 3.1 Examples 3.1.1 Visual Basic Read Inputs with block command To reduce communication time all imputs can be read with one command: GetBock32() ' Code in Form, click event Private Sub GetInputs_Click() On Error GoTo ERROR_HANDLER Dim lInputs(1 To 10) As Long Dim lError As Long, lInputAddress As Long Dim sTargetName As String sTargetName = "PPC" lError = 0 ' get base address of digital inputs lError = GetVBVariable(sTargetName, "Digital.Inputs!Address", lInputAddress) ' error handling If lError Then GoTo ERROR_HANDLER ' get 320 inputs lError = GetBlock32(sTargetName, lInputAddress, lInputs(1), 10) ' error handling? If lError Then GoTo ERROR_HANDLER MsgBox "Inputs from the second 32-bit card: 0x" & Hex(lInputs(2)), vbOKOnly, "Message" Exit Sub ERROR_HANDLER: Dim sErrorMsg As String If lError Then ' get error description Call GetVBErrorDescription(sTargetName, lError, sErrorMsg, 100) End If ' print error message MsgBox sErrorMsg + Err.Description, vbExclamation + vbOKOnly, "Error" End Sub Rev 1.1 © 03/06/2010 Seite 5/19 INOC-Server 3.1.2 Visual C++ Read Inputs with block command To reduce communication time all imputs can be read with one command: GetBock32() #include #include #include "inco_32.h" // lini INCO_32.lib #pragma comment(lib, "INCO_32.lib") void main() { uint32 Inputs[10]; uint32 Error; double InputAddress; char* TargetName = "PPC"; // get base address of digital inputs Error = GetVariable(TargetName,"Digital.Inputs!Address",&InputAddress); // error handling if (Error) goto ErrorHandler; // get 320 inputs Error=GetBlock32(TargetName,(uint32)InputAddress,Inputs,10); // error handling if (Error) goto ErrorHandler; char Buffer[100]; sprintf(Buffer,"Inputs from the second 32-bit card: 0x%08lx",Inputs[1]); // ausgabe der Eingänge MessageBox(0,Buffer,"I/O-Card Nr. 2/3",MB_OK|MB_ICONEXCLAMATION); return; ErrorHandler: char ErrorText[256]; // get error description GetErrorDescription(TargetName,Error,ErrorText,sizeof(ErrorText)); // print error message MessageBox(0,ErrorText,"INCO-Error",MB_OK|MB_ICONEXCLAMATION); } Seite 6/19 Rev 1.1 © 03/06/2010 INOC-Server 3.2 Inhaltsverzeichnis PutBlock16 C-Syntax uint32 PutBlock16(char* aSlave, uint32 aDest, uint16* aSource, uint32 aNumber ); VB-Syntax PutBlock16(ByVal aSlave As String, ByVal aDest As Long, aSource As Any, ByVal aNumber As Long) As Long Return value See chapter 4 Error Codes Parameter aSlave Target name aDest Buffer with data. aSource Source address with data to be copied to indel target. aNumber Number of 2-Byte values to be copied. Comment Write number aNumber of 16-Bit values from source address aSource to destination buffer aDest. Rev 1.1 © 03/06/2010 Seite 7/19 INOC-Server 3.3 GetBlock16 C-Syntax uint32 GetBlock16(char* aSlave, uint32 aSource, uint16* aDest, uint32 aNumber ); VB-Syntax GetBlock16(ByVal aSlave As String, ByVal aSource As Long, aDest As Any, ByVal aNumber As Long) As Long Return value See chapter 4 Error Codes Parameter aSlave Target name aDest Buffer with data. aSource Source address with data to be copied to indel target. aNumber Number of 2-Byte values to be copied. Comment Read number aNumber of 16-Bit values from source address aSource and copy it to destination aDest. Seite 8/19 Rev 1.1 © 03/06/2010 INOC-Server 3.4 Inhaltsverzeichnis GetBit C-Syntax uint32 GetBit(char* aSlave, uint32 aAddress, uint32 aNumber, uint32* aValue ); VB-Syntax GetBit(ByVal aSlave As String, ByVal aAddress As Long, ByVal aNumber As Long, aValue As Long) As Long Return value See chapter 4 Error Codes Parameter aSlave Target name aAddress Baseaddress of bit field aNumber Bitoffset aValue Returnvalue of bit Comment Read a bit at address aAddress and store it in aValue, aNumber is the bit number Rev 1.1 © 03/06/2010 Seite 9/19 INOC-Server 3.5 PutBit C-Syntax uint32 PutBit(char* aSlave, uint32 aAddress, uint32 aNumber, uint32* aValue ); VB-Syntax PutBit(ByVal aSlave As String, ByVal aAddress As Long, ByVal aNumber As Long, aValue as Long) As Long Return value See chapter 4 Error Codes Parameter aSlave Target name aAddress Baseaddress of bit field aNumber Bitoffset aValue Returnvalue of bit Comment Set a bit at address aAddress and store it in aValue, aNumber is the bit number Seite 10/19 Rev 1.1 © 03/06/2010 INOC-Server 3.6 Inhaltsverzeichnis Further Bit Commands GetOutput C-Syntax uint32 GetOutput(char* aSlave, char* aOutput, uint32* aValue ); VB-Syntax GetOutput(ByVal aSlave As String, ByVal aOutput AS String, aValue As Long) As Long PutOutput C-Syntax uint32 PutOutput(char* aSlave, char* aOutput, uint32* aValue ); VB-Syntax PutOutput(ByVal aSlave As String, ByVal aOutput As String, aValue As Long) As Long GetInput C-Syntax uint32 GetInput(char* aSlave, char* aInput, uint32* aValue ); VB-Syntax GetInput(ByVal aSlave As String, ByVal aInput As String, aValue As Long) As Long PutInput C-Syntax uint32 PutInput(char* aSlave, char* aInput, uint32* aValue ); VB-Syntax PutInput (ByVal aSlave As String, ByVal aInput As String, aValue As Long) As Long GetFlag C-Syntax uint32 GetFlag(char* aSlave, char* aFlag, uint32* aValue ); VB-Syntax GetFlag (ByVal aSlave As String, ByVal aFlag As String, aValue As Long) As Long PutFlag C-Syntax uint32 PutFlag(char* aSlave, char* aFlag, uint32* aValue ); VB-Syntax PutFlag (ByVal aSlave As String, ByVal aFlag As String, aValue As Long) As Long Rev 1.1 © 03/06/2010 Seite 11/19 INOC-Server 3.7 Variable Commandos 3.7.1.1 Operators To access a variable in a tree the operator '.' must be used to separate the different folders inside the tree. Operator '.' Example GetVariable("MyTarget", "InfoLink.ErrorCounter", Result, 0); Syntax Object1.Object2. ... ObjectX.Variable Access a bit in a variable Operator ':' Example PutVariable("MyTarget", "InfoLink.ErrorCounter:13", 1, 0); Syntax Object1.Object2. ... ObjectX.Variable:Bitnummer Bit number uint8, int8 0...7 uint16, int16 0...15 uint32, int32 0...31 uint64, int64 0...63 Access variables inside an array Operators '[' and ']' Example GetVariable("MyTarget","InfoLink.InputGroupState[1]",Result,0); Syntax Object1.Object2. ... ObjectX.Variable[Index] Each variable has its own properties. To access the properties of a variable use the operator '!'. Operator '!' Properties of variable Example: GetVariable("MyTarget", "Software.Version!Address", Result, 0); Syntax: Object1.Object2. ... ObjectX.Variable!Eigenschaft Propertie Description Address Address of variable ArrayLength Number of elements within an array Characteristics Characteristics of a variable: Bit 00: 0: Read- write access; 0: read only Bit 01: 0: visible; 1: invisible Bit 02...03: format 00: exp (x.xxxxxx Exx) 01: hex (xxxxxxxxh) 10: dec (xxxx) 11: fix (xxxx.xxxxx) Bit 04...07: Number of decimal places (0...15) Bit 08...13: Position of decimal point at fixed-numbers (0...63) KeyLevel Key-Level can be used to manage access rights Maximum Maximum of variable Minimum Minimum of variable Size Size in bytes Type Datatype 0x0000 = type INCO object 0x0100 = type INCO variable 0x0101 = type INCO uint64 Seite 12/19 Rev 1.1 © 03/06/2010 INOC-Server Inhaltsverzeichnis 0x0102 = type INCO int64 0x0103 = type INCO uint32 0x0104 = type INCO int32 0x0105 = type INCO uint16 0x0106 = type INCO int16 0x0107 = type INCO uint8 0x0108 = type INCO int8 0x0109 = type INCO double 0x010a = type INCO float 0x010b = type INCO date/time 0x010c = type INCO bit 0x0200 = type INCO string 0x0300 = type INCO procedure Unit Unit, e.g. °, mm Member Name of next object or variable in tree. Members Number of objects or members within one branch. Object Name of next child object. Objects Number of objects (folders) within one branch. Variable Name of next variable in tree. Variables Number of variable within one branch. Rev 1.1 © 03/06/2010 Seite 13/19 INOC-Server 3.7.1.2 PutVariable C-Syntax uint32 PutVariable(char* aSlave, char* aName, void* aValue, uint32 aLength=0 ); VB-Syntax PutVBVariable(ByVal aSlave As String, ByVal aName As String, ByRef aValue As Variant, Optional ByVal aLength As Long = 0) As Long Return value See chapter 4 Error Codes Parameter aSlave Target name aName INCO-Variable name aValue new value aLength aLength=0: variable aValue is double; aLength>0: variable aValue ist a string with length aLength. Comment Write a value aValue to variable aName. 3.7.2 GetVariable C-Syntax uint32 GetVariable(char* aSlave, char* aName, void* aResult, uint32 aLength=0 ); VB-Syntax GetVBVariable(ByVal aSlave As String, ByVal aName As String, ByRef aResult As Variant, Optional ByVal aLength As Long = 0) As Long Return value See chapter 4 Error Codes Parameter aSlave Target name. aName INCO-Variable name aResult value of variable. aLength aLength=0: variable aValue is double; aLength>0: variable aValue ist a string with length aLength. Comment Read value from variable aName and store it in aResult. Lese den Wert der Variablen Name und speichere den Wert in Result. Seite 14/19 Rev 1.1 © 03/06/2010 INOC-Server 3.8 Inhaltsverzeichnis CallProcedure C-Syntax uint32 CallProcedure(char* aSlave, char* aName, double* aResult ); VB-Syntax CallProcedure(ByVal aSlave As String, ByVal aName As String, aResult As Any) as Long Return value See chapter 4 Error Codes Parameter aSlave Target name. aName Funciton name with arguments, max 15 arguments alowed. aResult Returnvalue is always double. Argument Convention Example int32 Number:L 1234:L float Number:F, Number 235.864:F or 258.569 LPCSTR "String" "Juhee" double Number:D 153814.2684:D Register function in master to make it public #include double MyRPCFunction(double d1, float f1, char *pTestname, long l1) { return d1+f1+l1+strlen(pTestname); } // --- module initialisation (called at system startup) --StartFunction(_INI_1000_RPCTest) { // Registriert die globale Funktion MyRPCFunction pINCOItems->Add(new CINCOProcedure(REG_TYP_FCT(double, MyRPCFunction,(double,float,char*,long)) )); } C-Beispiel #include #include #include "inco_32.h" // linken der INCO_32.lib #pragma comment(lib, "INCO_32.lib") void main() { // return value of CallProcedure is always double double Result; uint32 Error; // call function MyRPCFunction, Target name is PPC Error = CallProcedure("PPC","MyRPCFunction(23.5:d,23.6:f,\"Test\",45:l)",&Result) // show result if(!Error){ // print Result: 96.1 printf("Result: %g",Result); } } Rev 1.1 © 03/06/2010 Seite 15/19 INOC-Server VB-Beispiel ' return value of CallProcedure is always double Dim Result As Double Dim Error As Long ' call function MyRPCFunction, Target name is PPC Error = CallProcedure("PPC", "MyRPCFunction(23.5:d,23.6:f,""Test"",45:l)", Result) ' show result If Error = 0 Then ' 96.0000 MsgBox Result, vbOKOnly, "The result" End If 3.9 Special functions 3.9.1 GetError C-Syntax uint32 GetError(char* aSlave ); VB-Syntax GetError(ByVal aSlave As String) As Long Return value See chapter 4 Error Codes Parameter aSlave Name of Target Comment Error number of last error, this code will also be sent with the return value. 3.9.2 GetErrorDescription C-Syntax uint32 GetErrorDescription(char* aSlave, uint32 aError, char* aDescription, uint32 aLength ); VB-Syntax GetVBErrorDescription(ByVal aSlave As String, ByVal aError As Long, ByRef aDescription As String, ByVal aLength As Long) As Long Return value See chapter 4 Error Codes Parameter aSlave aError aDescription aLength Name of Target INCO Error code. Buffer for error message. Size of buffer Comment Delivers error message to an error code. Seite 16/19 Rev 1.1 © 03/06/2010 INOC-Server Inhaltsverzeichnis C-Beispiel // Buffer for error message char ErrorText[256]; // error code of Remote Procedure Call (INCO) uint32 Error = 0x050403; // get error description if(!GetErrorDescription("PPC",Error,ErrorText,sizeof(ErrorText)) ) { // print error message MessageBox(0,ErrorText,"Error:",MB_OK|MB_ICONASTERISK); } VB-Beispiel Dim Error As Long Dim ErrorText As String ' error code of Remote Procedure Call (INCO) Error = &H50403 ' get error description If GetVBErrorDescription("PPC", Error, ErrorText, 255) = 0 Then ' print error message MsgBox ErrorText, vbOKOnly + vbExclamation, "Error description" End If Rev 1.1 © 03/06/2010 Seite 17/19 INOC-Server 4 Error Codes Error Code Error Text Solution 0x06A4 0x076C 0x06A7 0x06BA 0x06B5 RPC error Remote Procedure Call error. NetBEUI Protokol not supported INOC-Server not found Versions error Install NetBEUI Protokol Start INCO-Server INCO-Server version must be the same as INCO_32.dll Die Versionsnummer des Servers (INCO_SRV.EXE) Check Windows Registry entries. Check Server-Registry entries. Check spelling, Target must be online PC not found in PC network Reboot target Reboot target Restart INCO-Server 0x10001 0x10002 0x10003 0x10004 0x10005 0x10006 0x10007 0x10008 0x10009 0x10010 0x10011 0x10012 0x10013 0x10014 0x10016 Error in Registry Error in Server-Registry Target not defined / accessable PC-Name not found No response from target Semaphore could not be assigned Semaphore could not be deleted Set Password String-Buffer to short Command not for this target not supported Server could not load MemDriver Timeout INCO-Communication Write into dualported memory failed No bootcode Access only with index 0x10017 0x40001 0x40002 0x40003 0x40004 0x40005 0x40006 0x50XFF 0x50101 0x50102 0x50103 0x50104 0x50105 0x501FF 0x50201 0x50202 0x50203 0x50204 0x50205 0x50206 0x50207 No PPC found at specified address Error initialise serial port Error close serial port Error flush serial buffer Protocol error while read Checksum error Protocol error while write Unknown frame Unknown address Wrong alignment Unknown address range sector erase error (writing to flash) writing error (writing to flash) Unknown block command Variable not found Variable read only Minimum of variable undercut Maximum of variable exceeded Wrong string lenght Array index to large Access denied (Key-Level) Seite 18/19 String to long for allocated buffer Reinstall INCO-Server Reboot target This target supports only index (no names) to access flags, digital inputs and outputs. Check address switch on PC-Card Check registry entries for serial port Check serial interface Check serial interface Bad communication, increase retries in INCO-Registry Bad communication Bad communication, increase retries in INCO-Registry Target does not support this INCO-frames Invalid address Wrong alignment of address Use valid address range Sector of Flash prom could not be erased. Write to Flash prom failed Check name of function call Check spelling, target must be online Key-Level to low Rev 1.1 © 03/06/2010 INOC-Server Inhaltsverzeichnis 0x50208 0x50209 0x5020A 0x502FF 0x50301 0x50302 0x50303 0x503FF 0x50401 0x50402 0x50403 0x50404 0x50405 0x50406 0x50407 Variable property not found Wrong bit-number Buffer to low Unknown call Unknown table name Unknown data set Not enough memory Unknown data base call RPC procedure not found RPC Item it not procedure Wrong number of RPC parameters Wrong parameter type Function not available Function in use Return value must not be float 0x504FF 0x50601 0x50602 0x50603 0x50604 0x50605 0x50606 0x50607 0x50608 0x50609 0x5060A Unknown RPC-call Invalid Task-ID Invalid Taskname Task does not support float numbers Invalid Breakpoint Breakpoint already set Wrong data length Unknown data request Read only Not enough memory for breakpoint Target does not support hardware reset Unknown RPC-call Wrong Flag, Input, Output number Bitfield not yet initialised Unknown call Error initialise serial port Error write to serial port Error read from serial port Timeout serial interface 0x506FF 0x50701 0x50702 0x507FF 0x70001 0x70002 0x70003 0x70004 Rev 1.1 © 03/06/2010 Variable does not have such properties Bit number to large, bit counter starts at 0 Enlarge buffer size Check function name Check function table name Check function data set Not enough memory for table Check function name Check function name It is a variable name not a procedure name Check parameter type Try again Try again Use Compilerdirective -DUse_Floating, to allow float numbers Check Task-ID Check Task-Name Activate float numbers for this task Writing data not allowed Wait until download has been done Parameters are wrong Increase timeout Seite 19/19