From 100fec2942c159258a07bdd0d8365475c9112d3d Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 2 Mar 2020 13:55:39 -0800 Subject: [PATCH] add ticker example --- example/Makefile | 3 ++ example/ticker.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 example/ticker.cpp diff --git a/example/Makefile b/example/Makefile index 50ab285..5e9ded6 100644 --- a/example/Makefile +++ b/example/Makefile @@ -13,6 +13,9 @@ mailbox_SRCS += mailbox.cpp TESTPROD += spam spam_SRCS += spam.cpp +TESTPROD += ticker +ticker_SRCS += ticker.cpp + PROD_SYS_LIBS += event_core PROD_SYS_LIBS_DEFAULT += event_pthreads diff --git a/example/ticker.cpp b/example/ticker.cpp new file mode 100644 index 0000000..c9d9195 --- /dev/null +++ b/example/ticker.cpp @@ -0,0 +1,110 @@ +/** + * Copyright - See the COPYRIGHT that is included with this distribution. + * pvxs is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + */ +/** + * Serves a single integer PV which increments at a pre-defined rate. + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +using namespace pvxs; + +int main(int argc, char* argv[]) +{ + double delay = 1.0; + + if(argc<=1) { + std::cerr<<"Usage: "< [rateHz]\n"; + return 1; + } + + if(argc>=3) { + double rate = 0.0; + + if(epicsParseDouble(argv[2], &rate, nullptr) || rate<=0.0) { + std::cerr<<"Rate must be a positive number, not "<