Skip to content

Commit 751f563

Browse files
Improved BuR Driver
1 parent c37095d commit 751f563

12 files changed

+1434
-7
lines changed

Drivers/BuR/ACT/LibMCDriver_BuR.xml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,74 @@
5151
<error name="INVALIDSTATENAME" code="9" description="invalid state name" />
5252

5353
<error name="DRIVERERROR" code="1000" description="a driver error occured" />
54+
<error name="DRIVERNOTINITIALISED" code="1001" description="the driver is not initialised" />
55+
<error name="DRIVERNOTCONNECTED" code="1002" description="the driver is not connected" />
56+
<error name="INVALIDDRIVERPROTOCOL" code="1003" description="invalid driver protocol definition" />
57+
<error name="COULDNOTPARSEDRIVERPROTOCOL" code="1004" description="could not parse driver protocol" />
58+
<error name="NOSTATUSDBDEFINITION" code="1005" description="no status db definition" />
59+
<error name="NOSTATUSDBNUMBER" code="1006" description="no status db number" />
60+
<error name="INVALIDSTATUSDBNUMBER" code="1007" description="invalid status db number" />
61+
<error name="NOSTATUSDBSIZE" code="1008" description="no status db size" />
62+
<error name="INVALIDSTATUSDBSIZE" code="1009" description="invalid status db size" />
63+
<error name="NONAMEATTRIBUTE" code="1010" description="no name attribute" />
64+
<error name="NOADDRESSEATTRIBUTE" code="1011" description="no address attribute" />
65+
<error name="NODESCRIPTIONATTRIBUTE" code="1012" description="no description attribute" />
66+
<error name="NOBITATTRIBUTE" code="1013" description="no bit attribute" />
67+
68+
<error name="INVALIDNAMEATTRIBUTE" code="1014" description="invalid name attribute" />
69+
<error name="INVALIDADDRESSEATTRIBUTE" code="1015" description="invalid address attribute" />
70+
<error name="INVALIDDESCRIPTIONATTRIBUTE" code="1016" description="invalid description attribute" />
71+
<error name="INVALIDBITATTRIBUTE" code="1017" description="invalid bit attribute" />
72+
<error name="INVALIDCPUTYPE" code="1018" description="invalid cpu type" />
73+
74+
<error name="NOCONTROLDBDEFINITION" code="1019" description="no control db definition" />
75+
<error name="NOCONTROLDBNUMBER" code="1020" description="no control db number" />
76+
<error name="INVALIDCONTROLDBNUMBER" code="1021" description="invalid control db number" />
77+
78+
<error name="UNKNOWNCOMMANDNAME" code="1022" description="unknown command name" />
79+
<error name="NOCOMMANDNAME" code="1023" description="no command name" />
80+
<error name="NOCOMMANDID" code="1024" description="no command id" />
81+
<error name="INVALIDCOMMANDNAME" code="1025" description="invalid command name" />
82+
<error name="INVALIDCOMMANDID" code="1026" description="invalid command id" />
83+
84+
<error name="COMMANDHASALREADYBEENEXECUTED" code="1027" description="command has already been executed" />
85+
<error name="COMMANDHASNOTBEENEXECUTED" code="1028" description="command has not been executed" />
86+
<error name="INVALIDSEQUENCEID" code="1029" description="invalid sequence id" />
87+
<error name="COMMANDSEQUENCEERROR" code="1030" description="command sequence communication error" />
88+
<error name="COMMANDREACTIONTIMEOUT" code="1031" description="command reaction timeout" />
89+
<error name="NOCOMMANDSDEFINITION" code="1032" description="no commands definition" />
90+
91+
<error name="NOVERSIONDEFINITION" code="1033" description="no version definition" />
92+
<error name="NOMAJORVERSION" code="1034" description="no major version" />
93+
<error name="NOMINORVERSION" code="1035" description="no minor version" />
94+
<error name="NOPATCHVERSION" code="1036" description="no patch version" />
95+
<error name="NOCONTROLDBSIZE" code="1037" description="no control db size" />
96+
<error name="INVALIDCONTROLDBSIZE" code="1038" description="invalid control db size" />
97+
98+
<error name="COULDNOTFINDADDRESS" code="1039" description="could not find address" />
99+
<error name="FIELDISNOINTPARAM" code="1040" description="field is no int parameter" />
100+
<error name="FIELDISNODINTPARAM" code="1041" description="field is no dint parameter" />
101+
<error name="FIELDISNOSTRINGPARAM" code="1042" description="field is no string parameter" />
102+
<error name="NOLENGTHATTRIBUTE" code="1043" description="no length attribute" />
103+
<error name="INVALIDLENGTHATTRIBUTE" code="1044" description="invalid length attribute" />
104+
105+
<error name="COMMANDPARAMETERNAMEMISSING" code="1045" description="command parameter name missing" />
106+
<error name="COMMANDPARAMETERDESCRIPTIONMISSING" code="1046" description="command parameter description missing" />
107+
<error name="COMMANDPARAMETERFIELDMISSING" code="1047" description="command parameter field missing" />
108+
<error name="COMMANDPARAMETERNOTFOUND" code="1048" description="command parameter not found" />
109+
<error name="COMMANDFIELDNOTFOUND" code="1049" description="command field not found" />
110+
<error name="INVALIDPARAMETERTYPE" code="1050" description="command field parameter is of wrong type" />
111+
<error name="COMMANDPARAMETEROUTOFBOUNDS" code="1051" description="command field parameter is out of bounds" />
112+
113+
<error name="INVALIDPARAMETERADDRESS" code="1052" description="invalid parameter address" />
114+
<error name="STRINGPARAMETEROVERFLOW" code="1053" description="string parameter overflow" />
115+
<error name="RECEIVEDINVALIDPACKETSIGNATURE" code="1054" description="received invalid packet signature" />
116+
<error name="INVALIDTCPCONNECTIONPOINTER" code="1055" description="invalid tcp connection pointer" />
117+
<error name="INVALIDCLIENTSEQUENCEID" code="1056" description="Invalid client sequence id" />
118+
<error name="INVALIDCLIENTID" code="1057" description="Invalid client id" />
119+
<error name="PACKETQUEUEOVERFLOW" code="1058" description="Packet queue overflow." />
120+
121+
54122
</errors>
55123

56124

@@ -64,6 +132,25 @@ This base Driver interface MUST be in Sync with LibMCDriver.xml
64132
</class>
65133

66134

135+
<class name="PLCCommand" parent="Base">
136+
137+
<method name="SetIntegerParameter" description="Sets an integer parameter of the command">
138+
<param name="ParameterName" type="string" pass="in" description="Parameter Value" />
139+
<param name="Value" type="int32" pass="in" description="Parameter Value" />
140+
</method>
141+
142+
<method name="SetBoolParameter" description="Sets a bool parameter of the command">
143+
<param name="ParameterName" type="string" pass="in" description="Parameter Value" />
144+
<param name="Value" type="bool" pass="in" description="Parameter Value" />
145+
</method>
146+
147+
<method name="SetDoubleParameter" description="Sets a double parameter of the command">
148+
<param name="ParameterName" type="string" pass="in" description="Parameter Value" />
149+
<param name="Value" type="double" pass="in" description="Parameter Value" />
150+
</method>
151+
152+
</class>
153+
67154
<class name="Driver" parent="Base" description="An abstract Machine Control Driver">
68155

69156
<method name="Configure" description = "Configures a driver with its specific configuration data.">

Drivers/BuR/Headers/CppDynamic/libmcdriver_bur_abi.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,40 @@ extern "C" {
6161
Class definition for Base
6262
**************************************************************************************************************************/
6363

64+
/*************************************************************************************************************************
65+
Class definition for PLCCommand
66+
**************************************************************************************************************************/
67+
68+
/**
69+
* Sets an integer parameter of the command
70+
*
71+
* @param[in] pPLCCommand - PLCCommand instance.
72+
* @param[in] pParameterName - Parameter Value
73+
* @param[in] nValue - Parameter Value
74+
* @return error code or 0 (success)
75+
*/
76+
LIBMCDRIVER_BUR_DECLSPEC LibMCDriver_BuRResult libmcdriver_bur_plccommand_setintegerparameter(LibMCDriver_BuR_PLCCommand pPLCCommand, const char * pParameterName, LibMCDriver_BuR_int32 nValue);
77+
78+
/**
79+
* Sets a bool parameter of the command
80+
*
81+
* @param[in] pPLCCommand - PLCCommand instance.
82+
* @param[in] pParameterName - Parameter Value
83+
* @param[in] bValue - Parameter Value
84+
* @return error code or 0 (success)
85+
*/
86+
LIBMCDRIVER_BUR_DECLSPEC LibMCDriver_BuRResult libmcdriver_bur_plccommand_setboolparameter(LibMCDriver_BuR_PLCCommand pPLCCommand, const char * pParameterName, bool bValue);
87+
88+
/**
89+
* Sets a double parameter of the command
90+
*
91+
* @param[in] pPLCCommand - PLCCommand instance.
92+
* @param[in] pParameterName - Parameter Value
93+
* @param[in] dValue - Parameter Value
94+
* @return error code or 0 (success)
95+
*/
96+
LIBMCDRIVER_BUR_DECLSPEC LibMCDriver_BuRResult libmcdriver_bur_plccommand_setdoubleparameter(LibMCDriver_BuR_PLCCommand pPLCCommand, const char * pParameterName, LibMCDriver_BuR_double dValue);
97+
6498
/*************************************************************************************************************************
6599
Class definition for Driver
66100
**************************************************************************************************************************/

Drivers/BuR/Headers/CppDynamic/libmcdriver_bur_dynamic.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,40 @@ Interface version: 1.0.0
4848
Class definition for Base
4949
**************************************************************************************************************************/
5050

51+
/*************************************************************************************************************************
52+
Class definition for PLCCommand
53+
**************************************************************************************************************************/
54+
55+
/**
56+
* Sets an integer parameter of the command
57+
*
58+
* @param[in] pPLCCommand - PLCCommand instance.
59+
* @param[in] pParameterName - Parameter Value
60+
* @param[in] nValue - Parameter Value
61+
* @return error code or 0 (success)
62+
*/
63+
typedef LibMCDriver_BuRResult (*PLibMCDriver_BuRPLCCommand_SetIntegerParameterPtr) (LibMCDriver_BuR_PLCCommand pPLCCommand, const char * pParameterName, LibMCDriver_BuR_int32 nValue);
64+
65+
/**
66+
* Sets a bool parameter of the command
67+
*
68+
* @param[in] pPLCCommand - PLCCommand instance.
69+
* @param[in] pParameterName - Parameter Value
70+
* @param[in] bValue - Parameter Value
71+
* @return error code or 0 (success)
72+
*/
73+
typedef LibMCDriver_BuRResult (*PLibMCDriver_BuRPLCCommand_SetBoolParameterPtr) (LibMCDriver_BuR_PLCCommand pPLCCommand, const char * pParameterName, bool bValue);
74+
75+
/**
76+
* Sets a double parameter of the command
77+
*
78+
* @param[in] pPLCCommand - PLCCommand instance.
79+
* @param[in] pParameterName - Parameter Value
80+
* @param[in] dValue - Parameter Value
81+
* @return error code or 0 (success)
82+
*/
83+
typedef LibMCDriver_BuRResult (*PLibMCDriver_BuRPLCCommand_SetDoubleParameterPtr) (LibMCDriver_BuR_PLCCommand pPLCCommand, const char * pParameterName, LibMCDriver_BuR_double dValue);
84+
5185
/*************************************************************************************************************************
5286
Class definition for Driver
5387
**************************************************************************************************************************/
@@ -218,6 +252,9 @@ typedef LibMCDriver_BuRResult (*PLibMCDriver_BuRCreateDriverPtr) (const char * p
218252

219253
typedef struct {
220254
void * m_LibraryHandle;
255+
PLibMCDriver_BuRPLCCommand_SetIntegerParameterPtr m_PLCCommand_SetIntegerParameter;
256+
PLibMCDriver_BuRPLCCommand_SetBoolParameterPtr m_PLCCommand_SetBoolParameter;
257+
PLibMCDriver_BuRPLCCommand_SetDoubleParameterPtr m_PLCCommand_SetDoubleParameter;
221258
PLibMCDriver_BuRDriver_ConfigurePtr m_Driver_Configure;
222259
PLibMCDriver_BuRDriver_GetNamePtr m_Driver_GetName;
223260
PLibMCDriver_BuRDriver_GetTypePtr m_Driver_GetType;

Drivers/BuR/Headers/CppDynamic/libmcdriver_bur_dynamic.hpp

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ namespace LibMCDriver_BuR {
6161
**************************************************************************************************************************/
6262
class CWrapper;
6363
class CBase;
64+
class CPLCCommand;
6465
class CDriver;
6566
class CDriver_BuR;
6667

@@ -69,6 +70,7 @@ class CDriver_BuR;
6970
**************************************************************************************************************************/
7071
typedef CWrapper CLibMCDriver_BuRWrapper;
7172
typedef CBase CLibMCDriver_BuRBase;
73+
typedef CPLCCommand CLibMCDriver_BuRPLCCommand;
7274
typedef CDriver CLibMCDriver_BuRDriver;
7375
typedef CDriver_BuR CLibMCDriver_BuRDriver_BuR;
7476

@@ -77,6 +79,7 @@ typedef CDriver_BuR CLibMCDriver_BuRDriver_BuR;
7779
**************************************************************************************************************************/
7880
typedef std::shared_ptr<CWrapper> PWrapper;
7981
typedef std::shared_ptr<CBase> PBase;
82+
typedef std::shared_ptr<CPLCCommand> PPLCCommand;
8083
typedef std::shared_ptr<CDriver> PDriver;
8184
typedef std::shared_ptr<CDriver_BuR> PDriver_BuR;
8285

@@ -85,6 +88,7 @@ typedef std::shared_ptr<CDriver_BuR> PDriver_BuR;
8588
**************************************************************************************************************************/
8689
typedef PWrapper PLibMCDriver_BuRWrapper;
8790
typedef PBase PLibMCDriver_BuRBase;
91+
typedef PPLCCommand PLibMCDriver_BuRPLCCommand;
8892
typedef PDriver PLibMCDriver_BuRDriver;
8993
typedef PDriver_BuR PLibMCDriver_BuRDriver_BuR;
9094

@@ -264,6 +268,7 @@ class CWrapper {
264268
LibMCDriver_BuRResult loadWrapperTableFromSymbolLookupMethod(sLibMCDriver_BuRDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod);
265269

266270
friend class CBase;
271+
friend class CPLCCommand;
267272
friend class CDriver;
268273
friend class CDriver_BuR;
269274

@@ -326,6 +331,25 @@ class CBase {
326331
friend class CWrapper;
327332
};
328333

334+
/*************************************************************************************************************************
335+
Class CPLCCommand
336+
**************************************************************************************************************************/
337+
class CPLCCommand : public CBase {
338+
public:
339+
340+
/**
341+
* CPLCCommand::CPLCCommand - Constructor for PLCCommand class.
342+
*/
343+
CPLCCommand(CWrapper* pWrapper, LibMCDriver_BuRHandle pHandle)
344+
: CBase(pWrapper, pHandle)
345+
{
346+
}
347+
348+
inline void SetIntegerParameter(const std::string & sParameterName, const LibMCDriver_BuR_int32 nValue);
349+
inline void SetBoolParameter(const std::string & sParameterName, const bool bValue);
350+
inline void SetDoubleParameter(const std::string & sParameterName, const LibMCDriver_BuR_double dValue);
351+
};
352+
329353
/*************************************************************************************************************************
330354
Class CDriver
331355
**************************************************************************************************************************/
@@ -487,6 +511,9 @@ class CDriver_BuR : public CDriver {
487511
return LIBMCDRIVER_BUR_ERROR_INVALIDPARAM;
488512

489513
pWrapperTable->m_LibraryHandle = nullptr;
514+
pWrapperTable->m_PLCCommand_SetIntegerParameter = nullptr;
515+
pWrapperTable->m_PLCCommand_SetBoolParameter = nullptr;
516+
pWrapperTable->m_PLCCommand_SetDoubleParameter = nullptr;
490517
pWrapperTable->m_Driver_Configure = nullptr;
491518
pWrapperTable->m_Driver_GetName = nullptr;
492519
pWrapperTable->m_Driver_GetType = nullptr;
@@ -550,6 +577,33 @@ class CDriver_BuR : public CDriver {
550577
dlerror();
551578
#endif // _WIN32
552579

580+
#ifdef _WIN32
581+
pWrapperTable->m_PLCCommand_SetIntegerParameter = (PLibMCDriver_BuRPLCCommand_SetIntegerParameterPtr) GetProcAddress(hLibrary, "libmcdriver_bur_plccommand_setintegerparameter");
582+
#else // _WIN32
583+
pWrapperTable->m_PLCCommand_SetIntegerParameter = (PLibMCDriver_BuRPLCCommand_SetIntegerParameterPtr) dlsym(hLibrary, "libmcdriver_bur_plccommand_setintegerparameter");
584+
dlerror();
585+
#endif // _WIN32
586+
if (pWrapperTable->m_PLCCommand_SetIntegerParameter == nullptr)
587+
return LIBMCDRIVER_BUR_ERROR_COULDNOTFINDLIBRARYEXPORT;
588+
589+
#ifdef _WIN32
590+
pWrapperTable->m_PLCCommand_SetBoolParameter = (PLibMCDriver_BuRPLCCommand_SetBoolParameterPtr) GetProcAddress(hLibrary, "libmcdriver_bur_plccommand_setboolparameter");
591+
#else // _WIN32
592+
pWrapperTable->m_PLCCommand_SetBoolParameter = (PLibMCDriver_BuRPLCCommand_SetBoolParameterPtr) dlsym(hLibrary, "libmcdriver_bur_plccommand_setboolparameter");
593+
dlerror();
594+
#endif // _WIN32
595+
if (pWrapperTable->m_PLCCommand_SetBoolParameter == nullptr)
596+
return LIBMCDRIVER_BUR_ERROR_COULDNOTFINDLIBRARYEXPORT;
597+
598+
#ifdef _WIN32
599+
pWrapperTable->m_PLCCommand_SetDoubleParameter = (PLibMCDriver_BuRPLCCommand_SetDoubleParameterPtr) GetProcAddress(hLibrary, "libmcdriver_bur_plccommand_setdoubleparameter");
600+
#else // _WIN32
601+
pWrapperTable->m_PLCCommand_SetDoubleParameter = (PLibMCDriver_BuRPLCCommand_SetDoubleParameterPtr) dlsym(hLibrary, "libmcdriver_bur_plccommand_setdoubleparameter");
602+
dlerror();
603+
#endif // _WIN32
604+
if (pWrapperTable->m_PLCCommand_SetDoubleParameter == nullptr)
605+
return LIBMCDRIVER_BUR_ERROR_COULDNOTFINDLIBRARYEXPORT;
606+
553607
#ifdef _WIN32
554608
pWrapperTable->m_Driver_Configure = (PLibMCDriver_BuRDriver_ConfigurePtr) GetProcAddress(hLibrary, "libmcdriver_bur_driver_configure");
555609
#else // _WIN32
@@ -701,6 +755,18 @@ class CDriver_BuR : public CDriver {
701755
SymbolLookupType pLookup = (SymbolLookupType)pSymbolLookupMethod;
702756

703757
LibMCDriver_BuRResult eLookupError = LIBMCDRIVER_BUR_SUCCESS;
758+
eLookupError = (*pLookup)("libmcdriver_bur_plccommand_setintegerparameter", (void**)&(pWrapperTable->m_PLCCommand_SetIntegerParameter));
759+
if ( (eLookupError != 0) || (pWrapperTable->m_PLCCommand_SetIntegerParameter == nullptr) )
760+
return LIBMCDRIVER_BUR_ERROR_COULDNOTFINDLIBRARYEXPORT;
761+
762+
eLookupError = (*pLookup)("libmcdriver_bur_plccommand_setboolparameter", (void**)&(pWrapperTable->m_PLCCommand_SetBoolParameter));
763+
if ( (eLookupError != 0) || (pWrapperTable->m_PLCCommand_SetBoolParameter == nullptr) )
764+
return LIBMCDRIVER_BUR_ERROR_COULDNOTFINDLIBRARYEXPORT;
765+
766+
eLookupError = (*pLookup)("libmcdriver_bur_plccommand_setdoubleparameter", (void**)&(pWrapperTable->m_PLCCommand_SetDoubleParameter));
767+
if ( (eLookupError != 0) || (pWrapperTable->m_PLCCommand_SetDoubleParameter == nullptr) )
768+
return LIBMCDRIVER_BUR_ERROR_COULDNOTFINDLIBRARYEXPORT;
769+
704770
eLookupError = (*pLookup)("libmcdriver_bur_driver_configure", (void**)&(pWrapperTable->m_Driver_Configure));
705771
if ( (eLookupError != 0) || (pWrapperTable->m_Driver_Configure == nullptr) )
706772
return LIBMCDRIVER_BUR_ERROR_COULDNOTFINDLIBRARYEXPORT;
@@ -770,6 +836,40 @@ class CDriver_BuR : public CDriver {
770836
* Method definitions for class CBase
771837
*/
772838

839+
/**
840+
* Method definitions for class CPLCCommand
841+
*/
842+
843+
/**
844+
* CPLCCommand::SetIntegerParameter - Sets an integer parameter of the command
845+
* @param[in] sParameterName - Parameter Value
846+
* @param[in] nValue - Parameter Value
847+
*/
848+
void CPLCCommand::SetIntegerParameter(const std::string & sParameterName, const LibMCDriver_BuR_int32 nValue)
849+
{
850+
CheckError(m_pWrapper->m_WrapperTable.m_PLCCommand_SetIntegerParameter(m_pHandle, sParameterName.c_str(), nValue));
851+
}
852+
853+
/**
854+
* CPLCCommand::SetBoolParameter - Sets a bool parameter of the command
855+
* @param[in] sParameterName - Parameter Value
856+
* @param[in] bValue - Parameter Value
857+
*/
858+
void CPLCCommand::SetBoolParameter(const std::string & sParameterName, const bool bValue)
859+
{
860+
CheckError(m_pWrapper->m_WrapperTable.m_PLCCommand_SetBoolParameter(m_pHandle, sParameterName.c_str(), bValue));
861+
}
862+
863+
/**
864+
* CPLCCommand::SetDoubleParameter - Sets a double parameter of the command
865+
* @param[in] sParameterName - Parameter Value
866+
* @param[in] dValue - Parameter Value
867+
*/
868+
void CPLCCommand::SetDoubleParameter(const std::string & sParameterName, const LibMCDriver_BuR_double dValue)
869+
{
870+
CheckError(m_pWrapper->m_WrapperTable.m_PLCCommand_SetDoubleParameter(m_pHandle, sParameterName.c_str(), dValue));
871+
}
872+
773873
/**
774874
* Method definitions for class CDriver
775875
*/

0 commit comments

Comments
 (0)