Skip to content
Snippets Groups Projects
Commit 0ef66acd authored by Armin Co's avatar Armin Co
Browse files

Subscribe to all data changes

parent e61f31fe
Branches
No related tags found
No related merge requests found
...@@ -90,10 +90,20 @@ void SmartOpcServer::run_server() ...@@ -90,10 +90,20 @@ void SmartOpcServer::run_server()
auto sub_production_enabled = m_server.CreateSubscription(100, subcl_production_enabled); auto sub_production_enabled = m_server.CreateSubscription(100, subcl_production_enabled);
sub_production_enabled->SubscribeDataChange(m_producing); sub_production_enabled->SubscribeDataChange(m_producing);
SubClientSimModeEnabled subcl_sim_mode_enabled{m_state_machine};
auto sub_sim_mode_enabled = m_server.CreateSubscription(100, subcl_sim_mode_enabled);
sub_sim_mode_enabled->SubscribeDataChange(m_sim_mode_enabled);
while(true) while(true)
{ {
m_state_machine.run(); m_state_machine.run();
// update opc objects
m_time.SetValue(Variant(m_state_machine.m_model.get_time()));
m_excess_power.SetValue(Variant(m_state_machine.m_model.get_excess_power()));
m_producing.SetValue(Variant(m_state_machine.m_model.get_producing_state()));
m_sim_mode_enabled.SetValue(Variant(m_state_machine.is_sim_mode_enabled()));
std::this_thread::sleep_for(std::chrono::seconds(1)); std::this_thread::sleep_for(std::chrono::seconds(1));
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment