1、Description of the interface for asynchronous calls of functions located in DLLsfrom IEC-Program (PLC-program)1. Intruduction1.1. OverviewThe realtimeextension of 3S-company for WindowsNT4.0 consists of a kernel-part and an applicationpart. The kernelpart is a krnelmodedriver, which works as a tasks
2、cheduler and a PLC. With the programmingsystem CoDeSys, tasks can be programmed and configured to work in realtime. Within these tasks, realtime-dedicated functions can be managed. This means, for example, no Windows-API-calls are possible, IOs are updated by direct hardwareaccess and so on.The appl
3、icationpart is implemented as systemservice, means here we can do all the things, which need Windows-API-calls, like networking and others.Now there is a need to start these jobs from the PLC (running in the kernel, in our realtimetasks). So we implemented an interface, which allows us to call funct
4、ions within DLLs.In the IEC-Program (CoDeSys) the call to a library-functionblock leads to a call of a DLL-function in usermode (Windows-API).The work of the DLL-function is done in the context of an own thread for each call. So more than one call can be active at a time and all the calls are contro
5、lled by timeouts and exceptionhandlers.1.2. Which DLLs are loadedUsed DLLs are made visible to the system by registry-entries:InHKEY_LOCAL_MACHINESoftware3S Smart Software SolutionsCodesys SPRTPLCExternal DLLsthere must exist a value for each DLL that should be used. The form is:Valuename: Dllx, whe
6、re x is a number starting from 0.Value: The filename of the DLL, with or without (if located in system32) path.All these Dlls (no matter how many) are loaded to memory with Start system, and unloaded with Stop system.Example for an entry:Dll0 d:WorkspaceAsynchDllAsynchDll.dll2. The interface and the
7、 toolkitAll the functions in a DLL can be called through the library functionblock DllCall aufgerufen werden.The parameters are : bEnable At a rising edge the job is started.szFunktionName The name of the function to be called.ulSizeIn Size of the inputbuffer in bytes.ulSizeOut Size of the outputbuf
8、fer in bytes.pAdrIn address of the inputdata (address of a structure in IEC.)pAdrOut address of outputdata (address of a structure in IEC.)The returnvalue of iStatus is one of:STATUS_NOTENABLED,STATUS_PROCESSING,STATUS_READY,STATUS_ERROR,STATUS_TIMEOUT,STATUS_EXCEPTION,STATUS_USERTERMINATEDThe funct
9、ionblock must be called cyclic, to make changes of enable visible to the PLC and give the PLC the possibility to set the current state.The functionblock is part of the library DllCall.lib.The library DllCall.lib is based on the library SysLibSystemCall.lib, which must be included manually into the p
10、rogram.The functions within the DLL, must fit the following prototype:typedef BOOL (_cdecl *PFCUSTOMDLLFUNCTION)(char* pBufferIn, int iSizeIn, char* pBufferOut, int iSizeOut);The returnvalue maintains the states STATUS_ERROR (returnvalue FALSE) or STATUS_READY of DllCall.The communication between the PLC and the DLL is implemented with sharedmemory-channels and is limited to 100bytes (total) input- and outputdata.The name of the function must not be longer than 80 bytes.