Exemple #1
0
void App_Start(int argCount, char **arguments) {
    auto portMap = _createPortMap(argCount, arguments);

    auto i2CFactory = I2CFactory();
    auto serialFactory = SerialFactory();
    auto powerFactory = PowerFactoryAdaptor(i2CFactory, serialFactory);
    auto sensorFactory = SensorFactoryAdaptor(i2CFactory, serialFactory);

    auto loggerStream = _getSocketStream(portMap, "loggerPort");
    auto scriptLogger = std::make_shared<ScriptLogger>(loggerStream ? *loggerStream : std::cout);

    ThrustController tc(serialFactory, scriptLogger);
    ImuSensor subSensors(sensorFactory, scriptLogger);
    auto pm = PowerManager(powerFactory);
    auto lights = serialFactory.createHeadlights();

    auto dispatcherStream = _getSocketStream(portMap, "dispatcherPort");
    std::istream& inputStream = dispatcherStream ? *dispatcherStream : std::cin;
    std::ostream& outputStream = dispatcherStream ? *dispatcherStream : std::cout;
    CommandDispatcher cd(inputStream, outputStream, subSensors, tc, pm, *lights);
    scriptLogger->info("Ready!");
    cd.runLoop();
    if(dispatcherStream) dispatcherStream->disconnect();
    std::cout << "\n- End of Line -\n";
}
Exemple #2
0
void ShutDown(void const * instance)
{
	extern void PowerManager(int);
	extern volatile int Activity;
	if(Activity)
    {
		Activity = 0;
		ShutDownCount = 0;
	}
	if(ShutDownCount++ == 5)
		PowerManager(0);
}