Search in sources :

Example 1 with SystemPresenterFactory

use of il.ac.technion.cs.smarthouse.system_presenter.SystemPresenterFactory in project Smartcity-Smarthouse by TechnionYP5777.

the class Entry method main.

public static void main(final String[] args) {
    SensorsSimulator simulator = new SensorsSimulator().setGeneralStreamingInteval(TimeUnit.SECONDS.toMillis(5));
    SystemPresenterFactory factory = new SystemPresenterFactory().initMode(SystemMode.USER_MODE).enableModePopup(false).setUseCloudServer(false).enableLocalDatabase(false);
    new Reflections("il.ac.technion.cs.smarthouse.applications", new SubTypesScanner(false)).getSubTypesOf(SmarthouseApplication.class).forEach(cls -> {
        factory.addApplicationToInstall(new ApplicationPath(PathType.CLASS, cls));
        if (Simulatable.class.isAssignableFrom(cls))
            try {
                simulator.addAllSensor(((Simulatable) cls.newInstance()).getSimulatedSensors());
            } catch (InstantiationException | IllegalAccessException e) {
            // Ignoring
            }
    });
    factory.build();
    new Thread() {

        @Override
        public void interrupt() {
            simulator.stopSendingMsgsInAllSensors();
            super.interrupt();
        }

        @Override
        public void run() {
            simulator.startSendingMsgsInAllSensors();
            JavaFxHelper.startGui(new DeveloperSimulatorGui().setSimulator(simulator));
            super.run();
        }
    }.start();
}
Also used : SensorsSimulator(il.ac.technion.cs.smarthouse.sensors.simulator.SensorsSimulator) SystemPresenterFactory(il.ac.technion.cs.smarthouse.system_presenter.SystemPresenterFactory) Simulatable(il.ac.technion.cs.smarthouse.sensors.Simulatable) DeveloperSimulatorGui(il.ac.technion.cs.smarthouse.DeveloperSimulator.DeveloperSimulatorGui) SubTypesScanner(org.reflections.scanners.SubTypesScanner) SmarthouseApplication(il.ac.technion.cs.smarthouse.developers_api.SmarthouseApplication) ApplicationPath(il.ac.technion.cs.smarthouse.system.applications.installer.ApplicationPath) Reflections(org.reflections.Reflections)

Example 2 with SystemPresenterFactory

use of il.ac.technion.cs.smarthouse.system_presenter.SystemPresenterFactory in project Smartcity-Smarthouse by TechnionYP5777.

the class SmarthouseApplication method launch.

/**
 * A static launch function for testing. You can use it the main function in
 * order to run the house with the application installed on it.
 *
 * @param simluator
 * @param showSimulatorGui
 * @throws Exception
 */
protected static void launch(final SensorsSimulator simluator, final Boolean showSimulatorGui) throws Exception {
    final SystemPresenter p = new SystemPresenterFactory().setUseCloudServer(false).setRegularFileSystemListeners(false).addApplicationToInstall(new ApplicationPath(PathType.CLASS_NAME, new Throwable().getStackTrace()[1].getClassName())).initMode(SystemMode.DEVELOPER_MODE).enableModePopup(false).build();
    Optional.ofNullable(simluator).ifPresent(s -> new Thread() {

        @Override
        public void interrupt() {
            s.stopSendingMsgsInAllSensors();
            super.interrupt();
        }

        @Override
        public void run() {
            s.startSendingMsgsInAllSensors();
            if (showSimulatorGui)
                JavaFxHelper.startGui(new DeveloperSimulatorGui().setSimulator(s));
            super.run();
        }
    }.start());
    p.getSystemView().gotoAppsTab();
}
Also used : SystemPresenterFactory(il.ac.technion.cs.smarthouse.system_presenter.SystemPresenterFactory) DeveloperSimulatorGui(il.ac.technion.cs.smarthouse.DeveloperSimulator.DeveloperSimulatorGui) SystemPresenter(il.ac.technion.cs.smarthouse.system_presenter.SystemPresenter) ApplicationPath(il.ac.technion.cs.smarthouse.system.applications.installer.ApplicationPath)

Aggregations

DeveloperSimulatorGui (il.ac.technion.cs.smarthouse.DeveloperSimulator.DeveloperSimulatorGui)2 ApplicationPath (il.ac.technion.cs.smarthouse.system.applications.installer.ApplicationPath)2 SystemPresenterFactory (il.ac.technion.cs.smarthouse.system_presenter.SystemPresenterFactory)2 SmarthouseApplication (il.ac.technion.cs.smarthouse.developers_api.SmarthouseApplication)1 Simulatable (il.ac.technion.cs.smarthouse.sensors.Simulatable)1 SensorsSimulator (il.ac.technion.cs.smarthouse.sensors.simulator.SensorsSimulator)1 SystemPresenter (il.ac.technion.cs.smarthouse.system_presenter.SystemPresenter)1 Reflections (org.reflections.Reflections)1 SubTypesScanner (org.reflections.scanners.SubTypesScanner)1