- added missing example to git for release 0.9
parent
04ffbdc89a
commit
6e5d911166
@ -0,0 +1,30 @@
|
||||
|
||||
set(sv_publisher_example_SRCS
|
||||
sv_publisher_example.c
|
||||
)
|
||||
|
||||
IF(WIN32)
|
||||
|
||||
set_source_files_properties(${sv_publisher_example_SRCS}
|
||||
PROPERTIES LANGUAGE CXX)
|
||||
add_executable(sv_publisher_example
|
||||
${sv_publisher_example_SRCS}
|
||||
)
|
||||
|
||||
target_link_libraries(sv_publisher_example
|
||||
iec61850
|
||||
)
|
||||
|
||||
ELSE(WIN32)
|
||||
|
||||
add_executable(sv_publisher_example
|
||||
${sv_publisher_example_SRCS}
|
||||
)
|
||||
|
||||
target_link_libraries(sv_publisher_example
|
||||
iec61850
|
||||
)
|
||||
|
||||
ENDIF(WIN32)
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
LIBIEC_HOME=../..
|
||||
|
||||
PROJECT_BINARY_NAME = sv_publisher
|
||||
PROJECT_SOURCES += sv_publisher_example.c
|
||||
|
||||
INCLUDES += -I.
|
||||
|
||||
include $(LIBIEC_HOME)/make/target_system.mk
|
||||
include $(LIBIEC_HOME)/make/stack_includes.mk
|
||||
|
||||
all: $(PROJECT_BINARY_NAME)
|
||||
|
||||
include $(LIBIEC_HOME)/make/common_targets.mk
|
||||
|
||||
$(PROJECT_BINARY_NAME): $(PROJECT_SOURCES) $(LIB_NAME)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $(PROJECT_BINARY_NAME) $(PROJECT_SOURCES) $(INCLUDES) $(LIB_NAME) $(LDLIBS)
|
||||
|
||||
clean:
|
||||
rm -f $(PROJECT_BINARY_NAME)
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* sv_subscriber_example.c
|
||||
*
|
||||
* Example program for Sampled Values (SV) subscriber
|
||||
*
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include "hal_thread.h"
|
||||
#include "sv_publisher.h"
|
||||
|
||||
static bool running = true;
|
||||
|
||||
void sigint_handler(int signalId)
|
||||
{
|
||||
running = 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
SampledValuesPublisher svPublisher = SampledValuesPublisher_create("eth1");
|
||||
|
||||
SV_ASDU asdu1 = SampledValuesPublisher_addASDU(svPublisher, "svpub1", NULL, 1);
|
||||
|
||||
int float1 = SV_ASDU_addFLOAT(asdu1);
|
||||
int float2 = SV_ASDU_addFLOAT(asdu1);
|
||||
|
||||
SV_ASDU asdu2 = SampledValuesPublisher_addASDU(svPublisher, "svpub2", NULL, 1);
|
||||
|
||||
int float3 = SV_ASDU_addFLOAT(asdu2);
|
||||
int float4 = SV_ASDU_addFLOAT(asdu2);
|
||||
|
||||
SampledValuesPublisher_setupComplete(svPublisher);
|
||||
|
||||
float fVal1 = 1234.5678f;
|
||||
float fVal2 = 0.12345f;
|
||||
|
||||
int i;
|
||||
|
||||
while (running) {
|
||||
SV_ASDU_setFLOAT(asdu1, float1, fVal1);
|
||||
SV_ASDU_setFLOAT(asdu1, float2, fVal2);
|
||||
|
||||
SV_ASDU_increaseSmpCnt(asdu1);
|
||||
SV_ASDU_increaseSmpCnt(asdu2);
|
||||
|
||||
fVal1 += 1.1f;
|
||||
fVal2 += 0.1f;
|
||||
|
||||
SampledValuesPublisher_publish(svPublisher);
|
||||
|
||||
Thread_sleep(50);
|
||||
}
|
||||
|
||||
SampledValuesPublisher_destroy(svPublisher);
|
||||
}
|
Loading…
Reference in New Issue