You have to create an instance of rlOpcXmlDa within main.cpp.
//*************************************************************************** // main.cpp - description // ------------------- // begin : Mo Aug 27 10:17:41 2007 // generated by : pvdevelop (C) 2000-2007 by Lehrig Software Engineering // email : lehrig@t-online.de //*************************************************************************** #include "pvapp.h" // todo: comment me out. you can insert these objects as extern in your masks. //rlModbusClient modbus(modbusdaemon_MAILBOX,modbusdaemon_SHARED_MEMORY,modbusdaemon_SHARED_MEMORY_SIZE); //rlSiemensTCPClient siemensTCP(siemensdaemon_MAILBOX,siemensdaemon_SHARED_MEMORY,siemensdaemon_SHARED_MEMORY_SIZE); //rlPPIClient ppi(ppidaemon_MAILBOX,ppidaemon_SHARED_MEMORY,ppidaemon_SHARED_MEMORY_SIZE); rlOpcXmlDa opc;
Now your maskX_slots.h may look as follows.
//############################################################### //# mask1_slots.h for ProcessViewServer created: Mo Aug 27 10:17:41 2007 //# please fill out these slots //# here you find all possible events //# Yours: Lehrig Software Engineering //############################################################### //*************************************************************************** // main.cpp - description // ------------------- // begin : Mo Aug 27 10:17:41 2007 // generated by : pvdevelop (C) 2000-2007 by Lehrig Software Engineering // email : lehrig@t-online.de //*************************************************************************** #include "pvapp.h" // todo: comment me out. you can insert these objects as extern in your masks. //rlModbusClient modbus(modbusdaemon_MAILBOX,modbusdaemon_SHARED_MEMORY,modbusdaemon_SHARED_MEMORY_SIZE); //rlSiemensTCPClient siemensTCP(siemensdaemon_MAILBOX,siemensdaemon_SHARED_MEMORY,siemensdaemon_SHARED_MEMORY_SIZE); //rlPPIClient ppi(ppidaemon_MAILBOX,ppidaemon_SHARED_MEMORY,ppidaemon_SHARED_MEMORY_SIZE); // todo: uncomment me if you want to use this data aquisiton // also uncomment this classes in main.cpp and pvapp.h // also remember to uncomment rllib in the project file //extern rlModbusClient modbus; //extern rlSiemensTCPClient siemensTCP; //extern rlPPIClient ppi; extern rlOpcXmlDa opc; typedef struct // (todo: define your data structure here) { } DATA; static int slotInit(PARAM *p, DATA *d) { if(p == NULL || d == NULL) return -1; //memset(d,0,sizeof(DATA)); return 0; } static int slotNullEvent(PARAM *p, DATA *d) { if(p == NULL || d == NULL) return -1; int i; const char *cptr; for(i=ID_MAIN_WIDGET+1; i<ID_END_OF_WIDGETS; i++) { cptr = toolTip[i]; if(*cptr != '#' && *cptr > ' ') // if there is a variable name { pvPrintf(p,i,"%s=%s",cptr,opc.stringValue(cptr)); } } pvPrintf(p,labelReadErrorCount,"readErrorCount=%d",opc.readErrorCount()); pvPrintf(p,labelWriteErrorCount,"writeErrorCount=%d",opc.writeErrorCount()); return 0; } static int slotButtonEvent(PARAM *p, int id, DATA *d) { if(p == NULL || id == 0 || d == NULL) return -1; int ival; float fval; switch(id) { case buttonInt16: ival = opc.intValue("test/Int16"); ival += 1; opc.writeIntValue("test/Int16",ival); break; case buttonInt32: ival = opc.intValue("test/Int32"); ival += 1; opc.writeIntValue("test/Int32",ival); break; case buttonFloat: fval = opc.floatValue("test/float"); fval += 1.0f; opc.writeFloatValue("test/float",fval); break; case buttonDouble: fval = opc.floatValue("test/double"); fval += 1.0f; opc.writeFloatValue("test/double",fval); break; case buttonHello: opc.writeStringValue("test/string","hello"); break; case buttonWorld: opc.writeStringValue("test/string","world"); break; default: break; } return 0; }