|
|
|
@ -58,99 +58,101 @@ goCbEventHandler(MmsGooseControlBlock goCb, int event, void* parameter)
|
|
|
|
|
printf(" GoEna: %i\n", MmsGooseControlBlock_getGoEna(goCb));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main(int argc, char** argv)
|
|
|
|
|
{
|
|
|
|
|
IedServerConfig config = IedServerConfig_create();
|
|
|
|
|
|
|
|
|
|
iedServer = IedServer_createWithConfig(&iedModel, NULL, config);
|
|
|
|
|
iedServer = IedServer_createWithConfig(&iedModel, NULL, config);
|
|
|
|
|
|
|
|
|
|
IedServerConfig_destroy(config);
|
|
|
|
|
IedServerConfig_destroy(config);
|
|
|
|
|
|
|
|
|
|
if (argc > 1) {
|
|
|
|
|
char* ethernetIfcID = argv[1];
|
|
|
|
|
if (argc > 1) {
|
|
|
|
|
char* ethernetIfcID = argv[1];
|
|
|
|
|
|
|
|
|
|
printf("Using GOOSE interface: %s\n", ethernetIfcID);
|
|
|
|
|
printf("Using GOOSE interface: %s\n", ethernetIfcID);
|
|
|
|
|
|
|
|
|
|
/* set GOOSE interface for all GOOSE publishers (GCBs) */
|
|
|
|
|
IedServer_setGooseInterfaceId(iedServer, ethernetIfcID);
|
|
|
|
|
}
|
|
|
|
|
/* set GOOSE interface for all GOOSE publishers (GCBs) */
|
|
|
|
|
IedServer_setGooseInterfaceId(iedServer, ethernetIfcID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (argc > 2) {
|
|
|
|
|
char* ethernetIfcID = argv[2];
|
|
|
|
|
if (argc > 2) {
|
|
|
|
|
char* ethernetIfcID = argv[2];
|
|
|
|
|
|
|
|
|
|
printf("Using GOOSE interface for GenericIO/LLN0.gcbAnalogValues: %s\n", ethernetIfcID);
|
|
|
|
|
printf("Using GOOSE interface for GenericIO/LLN0.gcbAnalogValues: %s\n", ethernetIfcID);
|
|
|
|
|
|
|
|
|
|
/* set GOOSE interface for a particular GOOSE publisher (GCB) */
|
|
|
|
|
IedServer_setGooseInterfaceIdEx(iedServer, IEDMODEL_GenericIO_LLN0, "gcbAnalogValues", ethernetIfcID);
|
|
|
|
|
}
|
|
|
|
|
IedServer_setGooseInterfaceIdEx(iedServer, IEDMODEL_GenericIO_LLN0, "gcbAnalogValues", ethernetIfcID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IedServer_setGoCBHandler(iedServer, goCbEventHandler, NULL);
|
|
|
|
|
IedServer_setGoCBHandler(iedServer, goCbEventHandler, NULL);
|
|
|
|
|
|
|
|
|
|
/* MMS server will be instructed to start listening to client connections. */
|
|
|
|
|
IedServer_start(iedServer, 102);
|
|
|
|
|
/* MMS server will be instructed to start listening to client connections. */
|
|
|
|
|
IedServer_start(iedServer, 102);
|
|
|
|
|
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO1, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO1);
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO1, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO1);
|
|
|
|
|
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO2, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO2);
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO2, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO2);
|
|
|
|
|
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO3, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO3);
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO3, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO3);
|
|
|
|
|
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO4);
|
|
|
|
|
IedServer_setControlHandler(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4, (ControlHandler) controlHandlerForBinaryOutput,
|
|
|
|
|
IEDMODEL_GenericIO_GGIO1_SPCSO4);
|
|
|
|
|
|
|
|
|
|
if (!IedServer_isRunning(iedServer)) {
|
|
|
|
|
printf("Starting server failed! Exit.\n");
|
|
|
|
|
IedServer_destroy(iedServer);
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
if (!IedServer_isRunning(iedServer)) {
|
|
|
|
|
printf("Starting server failed! Exit.\n");
|
|
|
|
|
IedServer_destroy(iedServer);
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Start GOOSE publishing */
|
|
|
|
|
IedServer_enableGoosePublishing(iedServer);
|
|
|
|
|
/* Start GOOSE publishing */
|
|
|
|
|
IedServer_enableGoosePublishing(iedServer);
|
|
|
|
|
|
|
|
|
|
running = 1;
|
|
|
|
|
running = 1;
|
|
|
|
|
|
|
|
|
|
signal(SIGINT, sigint_handler);
|
|
|
|
|
signal(SIGINT, sigint_handler);
|
|
|
|
|
|
|
|
|
|
float anIn1 = 0.f;
|
|
|
|
|
float anIn1 = 0.f;
|
|
|
|
|
|
|
|
|
|
int eventCount = 10;
|
|
|
|
|
int eventCount = 10;
|
|
|
|
|
|
|
|
|
|
while (running) {
|
|
|
|
|
while (running) {
|
|
|
|
|
|
|
|
|
|
IedServer_lockDataModel(iedServer);
|
|
|
|
|
IedServer_lockDataModel(iedServer);
|
|
|
|
|
|
|
|
|
|
IedServer_updateUTCTimeAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_AnIn1_t, Hal_getTimeInMs());
|
|
|
|
|
IedServer_updateFloatAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_AnIn1_mag_f, anIn1);
|
|
|
|
|
IedServer_updateFloatAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_AnIn1_mag_f, anIn1);
|
|
|
|
|
|
|
|
|
|
if (eventCount) {
|
|
|
|
|
IedServer_updateUTCTimeAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_t, Hal_getTimeInMs());
|
|
|
|
|
if (eventCount) {
|
|
|
|
|
IedServer_updateUTCTimeAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_t, Hal_getTimeInMs());
|
|
|
|
|
|
|
|
|
|
if (eventCount % 2) {
|
|
|
|
|
IedServer_updateQuality(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_q, QUALITY_VALIDITY_GOOD);
|
|
|
|
|
IedServer_updateBooleanAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_stVal, true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (eventCount % 2) {
|
|
|
|
|
IedServer_updateQuality(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_q, QUALITY_VALIDITY_GOOD);
|
|
|
|
|
IedServer_updateBooleanAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_stVal, true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
IedServer_updateQuality(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_q, QUALITY_VALIDITY_INVALID);
|
|
|
|
|
IedServer_updateBooleanAttributeValue(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO4_stVal, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eventCount--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eventCount--;
|
|
|
|
|
}
|
|
|
|
|
IedServer_unlockDataModel(iedServer);
|
|
|
|
|
|
|
|
|
|
IedServer_unlockDataModel(iedServer);
|
|
|
|
|
anIn1 += 0.1;
|
|
|
|
|
|
|
|
|
|
anIn1 += 0.1;
|
|
|
|
|
Thread_sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Thread_sleep(1000);
|
|
|
|
|
}
|
|
|
|
|
/* stop MMS server - close TCP server socket and all client sockets */
|
|
|
|
|
IedServer_stop(iedServer);
|
|
|
|
|
|
|
|
|
|
/* stop MMS server - close TCP server socket and all client sockets */
|
|
|
|
|
IedServer_stop(iedServer);
|
|
|
|
|
/* Cleanup - free all resources */
|
|
|
|
|
IedServer_destroy(iedServer);
|
|
|
|
|
|
|
|
|
|
/* Cleanup - free all resources */
|
|
|
|
|
IedServer_destroy(iedServer);
|
|
|
|
|
return 0;
|
|
|
|
|
return 0;
|
|
|
|
|
} /* main() */
|
|
|
|
|