PublishModule module increments or decrements a value cyclicallyEventModule module allows to click on a toggle to set if the first module should increment or decrement the value, and shows the valuePublishModule in C.
PublishModule which:EventModule which:
PublishModule in C:
applications.xml XML file has to be modified to switch from a Java module implementation to a basic C module implementation.
applications.xml XML file, by modifying the PublishModule configuration:<application name="publishAppli"> <modules> <cModule name="PublishModule"> <cImplementation path="PublishModule" /> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </cModule> </modules> </application>As you can see, we specified that the implementation of the
PublishModule is in the PublishModule.dll dll, in the same directory as the application.xml file.
PublishModule project in Visual Studio. See the Setting a CodeBlocks project for a C module for more information on how to do it.
startNotify(long service), endNotify(), andreceiveBoolean(char* dataName, int value) functions must be definedsetIntInvoker(void (*intInvokerInst)(char*, int)) function callback must be definedpublish(long service) function must be defined__declspec(dllexport) void start(void (*startInvoke)(long), void (*endInvoke)); __declspec(dllexport) void setIntInvoker(void (*intInvokerInst)(char*, int)); __declspec(dllexport) void end(); __declspec(dllexport) void startNotify(long service); __declspec(dllexport) void receiveInt(char* data, int value); __declspec(dllexport) void receiveBoolean(char* data, int value); __declspec(dllexport) void endNotify(long service); __declspec(dllexport) void publish(long service); static int count = 0; static int step = 1; static void (*startInvokeInst)(long); static void (*endInvokeInst)(); static void (*intInvokerInst)(char*, int);
#include <stdio.h> #include "module1.h" void start(void (*startInvoke)(long), void (*endInvoke)()) { startInvokeInst = startInvoke; endInvokeInst = endInvoke; } void end() { } void setIntInvoker(void (*intInvoker)(char*, int)) { intInvokerInst = intInvoker; } void startNotify(long service) { } void receiveBoolean(char* data, int value) { if (value) { step = -1; } else { step = 1; } } void endNotify(long service) { } void publish(long service) { count += step; startInvokeInst(2); intInvokerInst("value", count); endInvokeInst(); }
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence