Skip to content
Snippets Groups Projects
Commit 750e4964 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

correctecd example for latest DeviceAccess changes

parent 181b2f01
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,8 @@ class TimerDummyRegisterAccessor : public mtca4u::SyncNDRegisterAccessor<UserTyp ...@@ -75,6 +75,8 @@ class TimerDummyRegisterAccessor : public mtca4u::SyncNDRegisterAccessor<UserTyp
bool isReadable() const override { return true; } bool isReadable() const override { return true; }
bool isWriteable() const override { return false; } bool isWriteable() const override { return false; }
mtca4u::AccessModeFlags getAccessModeFlags() const override { return {mtca4u::AccessMode::wait_for_new_data}; }
bool mayReplaceOther(const boost::shared_ptr<mtca4u::TransferElement const> &) const override { return false; } bool mayReplaceOther(const boost::shared_ptr<mtca4u::TransferElement const> &) const override { return false; }
std::vector<boost::shared_ptr<mtca4u::TransferElement> > getHardwareAccessingElements() override { return { this->shared_from_this() }; } std::vector<boost::shared_ptr<mtca4u::TransferElement> > getHardwareAccessingElements() override { return { this->shared_from_this() }; }
......
...@@ -17,7 +17,7 @@ struct Automation : public ctk::ApplicationModule { ...@@ -17,7 +17,7 @@ struct Automation : public ctk::ApplicationModule {
ctk::ScalarPollInput<double> opSP{this, "opSP", "MV", "..."}; ctk::ScalarPollInput<double> opSP{this, "opSP", "MV", "..."};
ctk::ScalarOutput<double> curSP{this, "curSP", "MV", "..."}; ctk::ScalarOutput<double> curSP{this, "curSP", "MV", "..."};
ctk::ScalarPushInput<int> trigger{this, "trigger", "", "..."}; ctk::ScalarPushInput<int> trigger{this, "trigger", "", "..."};
void mainLoop() { void mainLoop() {
while(true) { while(true) {
trigger.read(); trigger.read();
...@@ -42,14 +42,15 @@ struct TableGeneration : public ctk::ApplicationModule { ...@@ -42,14 +42,15 @@ struct TableGeneration : public ctk::ApplicationModule {
ctk::ScalarPushInput<double> setpoint{this, "setpoint", "MV", "..."}; ctk::ScalarPushInput<double> setpoint{this, "setpoint", "MV", "..."};
}; };
TableParameters tableParameters{this, "tableParameters", "..."}; TableParameters tableParameters{this, "tableParameters", "..."};
ctk::ArrayOutput<int32_t> setpointTable{this, "setpointTable", "bits", tableLength, "..."}; ctk::ArrayOutput<int32_t> setpointTable{this, "setpointTable", "bits", tableLength, "..."};
ctk::ArrayOutput<int32_t> feedforwardTable{this, "feedforwardTable", "bits", tableLength, "..."}; ctk::ArrayOutput<int32_t> feedforwardTable{this, "feedforwardTable", "bits", tableLength, "..."};
void mainLoop() { void mainLoop() {
ctk::ReadAnyGroup tableParametersReadGroup = tableParameters.readAnyGroup();
while(true) { while(true) {
tableParameters.readAny(); // block until the any table parameter is changed tableParametersReadGroup.waitAny(); // block until the any table parameter is changed
for(size_t i = 0; i < tableLength; ++i) { for(size_t i = 0; i < tableLength; ++i) {
if(i < tableParameters.pulseLength * samplingFrequency) { if(i < tableParameters.pulseLength * samplingFrequency) {
setpointTable[i] = tableParameters.setpoint * bitScalingFactor; setpointTable[i] = tableParameters.setpoint * bitScalingFactor;
...@@ -60,7 +61,7 @@ struct TableGeneration : public ctk::ApplicationModule { ...@@ -60,7 +61,7 @@ struct TableGeneration : public ctk::ApplicationModule {
feedforwardTable[i] = 0; feedforwardTable[i] = 0;
} }
} }
setpointTable.write(); setpointTable.write();
feedforwardTable.write(); feedforwardTable.write();
} }
...@@ -76,9 +77,9 @@ struct ExampleApp : public ctk::Application { ...@@ -76,9 +77,9 @@ struct ExampleApp : public ctk::Application {
ctk::DeviceModule dev{"Device"}; ctk::DeviceModule dev{"Device"};
ctk::DeviceModule timer{"Timer"}; ctk::DeviceModule timer{"Timer"};
ctk::ControlSystemModule cs{"MyLocation"}; ctk::ControlSystemModule cs{"MyLocation"};
void defineConnections(); void defineConnections();
}; };
ExampleApp theExampleApp; ExampleApp theExampleApp;
...@@ -88,17 +89,17 @@ void ExampleApp::defineConnections() { ...@@ -88,17 +89,17 @@ void ExampleApp::defineConnections() {
cs("setpoint") >> automation.opSP; cs("setpoint") >> automation.opSP;
automation.curSP >> tableGeneration.tableParameters.setpoint >> cs("currentSetpoint"); automation.curSP >> tableGeneration.tableParameters.setpoint >> cs("currentSetpoint");
auto macropulseNr = timer("macropulseNr", typeid(int), 1, ctk::UpdateMode::push); auto macropulseNr = timer("macropulseNr", typeid(int), 1, ctk::UpdateMode::push);
macropulseNr >> automation.trigger; macropulseNr >> automation.trigger;
cs("pulseLength") >> tableGeneration.tableParameters.pulseLength; cs("pulseLength") >> tableGeneration.tableParameters.pulseLength;
tableGeneration.setpointTable >> dev("setpointTable"); tableGeneration.setpointTable >> dev("setpointTable");
tableGeneration.feedforwardTable >> dev("feedforwardTable"); tableGeneration.feedforwardTable >> dev("feedforwardTable");
dev("probeSignal", typeid(int), tableLength) [ macropulseNr ] >> cs("probeSignal"); dev("probeSignal", typeid(int), tableLength) [ macropulseNr ] >> cs("probeSignal");
dumpConnections(); dumpConnections();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment