#include <iostream>
using namespace std::chrono_literals;
{
state_t off{ this }, blinking{ this },
blink_on{ initial_substate_of{ blinking } },
blink_off{ substate_of{ blinking } };
public :
{
off.just_switch_to< turn_on_off >( blinking );
blinking.just_switch_to< turn_on_off >(
off );
blink_on
.on_enter( []{ std::cout << "ON" << std::endl; } )
.on_exit( []{ std::cout << "off" << std::endl; } )
.time_limit( std::chrono::milliseconds{1250}, blink_off );
blink_off
.time_limit( std::chrono::milliseconds{750}, blink_on );
}
};
int main()
{
try
{
return coop.
make_agent< blinking_led >()->so_direct_mbox();
} );
std::cout << "Turn blinking on for 10s" << std::endl;
std::this_thread::sleep_for( 10s );
std::cout << "Turn blinking off for 5s" << std::endl;
std::this_thread::sleep_for( 5s );
std::cout << "Turn blinking on for 5s" << std::endl;
std::this_thread::sleep_for( 5s );
std::cout << "Stopping..." << std::endl;
} );
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
}
return 0;
}
A helper header file for including all public SObjectizer stuff.
Agent * make_agent(Args &&... args)
Helper method for simplification of agents creation.
void stop() noexcept
Send a shutdown signal to the Run-Time.
decltype(auto) introduce_coop(Args &&... args)
Helper method for simplification of cooperation creation and registration.
A base class for agent signals.
void launch(Init_Routine &&init_routine)
Launch a SObjectizer Environment with default parameters.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
@ off
Tracking is disabled.