Ejemplo n.º 1
0
        public IoT(DashBoard dashBoard, ServerMQTT mqtt, string mqttClientId, IRepository repository, IScenarioEngine engine)
        {
            this.dashBoard = dashBoard;
            system         = ActorSystem.Create("iot");
            orchastraion   = system.ActorOf(Orchestration.Props(this.dashBoard, mqttClientId, repository, engine), "orch");

            //AddGateway(new GatewayDashBoard("1"));
            //AddDevice(new GatewayDashBoard("1"), new DeviceDashBoard("2"));

            orchastraion.Tell(new SystemStart());

            this.mqtt        = mqtt;
            mqtt.ReceiveMsg += Mqtt_ReceiveMsg;
        }
Ejemplo n.º 2
0
 public static Props Props(DashBoard dashBoard, string MQTTClientId, IRepository repository, IScenarioEngine engine)
 {
     return(Akka.Actor.Props.Create(() => new Orchestration(dashBoard, MQTTClientId, repository, engine)));
 }
Ejemplo n.º 3
0
        public Orchestration(DashBoard dashBoard, string MQTTClientId, IRepository repository, IScenarioEngine engine)
        {
            deviceManager     = Context.ActorOf(DeviceManagerCoordinator.Props("patano", MQTTClientId, engine), "physicaldevice");
            dashboardManager  = Context.ActorOf(DashdoardCoordinator.Props("dashboard", dashBoard), "dashboard");
            repositoryManager = Context.ActorOf(RepositoryCoordinator.Props(repository), "repo");

            Receive <GatewayCreated>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalCreated);
                dashboardManager.Tell(msg.GatewayDashBoardCreated);
                repositoryManager.Tell(msg.GatewayRepositoryCreated);
            });

            Receive <DeviceCreated>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalCreated);
                dashboardManager.Tell(msg.DeviceDashBoardCreated);
                repositoryManager.Tell(msg.DeviceRepositoryCreated);
            });

            Receive <GatewayDroped>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalDroped);
                dashboardManager.Tell(msg.GatewayDashBoardDroped);
                repositoryManager.Tell(msg.GatewayRepositoryDroped);
            });

            Receive <DeviceDroped>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalDroped);
                dashboardManager.Tell(msg.DeviceDashBoardDroped);
                repositoryManager.Tell(msg.DeviceRepositoryDroped);
            });

            Receive <GatewaySended>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalSended);
                dashboardManager.Tell(msg.GatewayDashBoardSended);
                repositoryManager.Tell(msg.GatewayRepositorySended);
            });

            Receive <DeviceSended>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalSended);
                dashboardManager.Tell(msg.DeviceDashBoardSended);
                repositoryManager.Tell(msg.DeviceRepositorySended);
            });

            Receive <GatewayStarted>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalStarted);
                dashboardManager.Tell(msg.GatewayDashBoardStarted);
                repositoryManager.Tell(msg.GatewayRepositoryStarted);
            });

            Receive <DeviceStarted>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalStarted);
                dashboardManager.Tell(msg.DeviceDashBoardStarted);
                repositoryManager.Tell(msg.DeviceRepositoryStarted);
            });

            Receive <GatewayDisconnected>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalDisconnected);
                dashboardManager.Tell(msg.GatewayDashBoardDisconnected);
                repositoryManager.Tell(msg.GatewayRepositoryDisconnected);
            });

            Receive <DeviceDisconnected>(msg =>
            {
                deviceManager.Tell(msg.DeviceDashBoardDisconnected);
                dashboardManager.Tell(msg.DeviceDashBoardDisconnected);
                repositoryManager.Tell(msg.DeviceRepositoryDisconnected);
            });

            Receive <GatewaySet>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalSet);
                dashboardManager.Tell(msg.GatewayDashBoardSet);
                repositoryManager.Tell(msg.GatewayRepositorySet);
            });

            Receive <DeviceSet>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalSet);
                dashboardManager.Tell(msg.DeviceDashBoardSet);
                repositoryManager.Tell(msg.DeviceRepositorySet);
            });

            Receive <GatewayUpdate>(msg =>
            {
                dashboardManager.Tell(msg.GatewayDashBoardUpdate);
                repositoryManager.Tell(msg.GatewayRepositoryUpdate);
            });

            Receive <DeviceUpdate>(msg =>
            {
                dashboardManager.Tell(msg.DeviceDashBoardUpdate);
                repositoryManager.Tell(msg.DeviceRepositoryUpdate);
            });

            Receive <GatewayStatus>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalStatus);
            });

            Receive <DeviceStatus>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalStatus);
            });

            Receive <GetGatewaysBoard>(msg =>
            {
                var result = dashboardManager.Ask <List <GatewayDashBoard> >(msg).Result;
                Sender.Tell(result);
            });

            Receive <StatusChanged>(msg => { dashBoard.HasChange(); });

            Receive <SystemStart>(msg => InitSystem());

            Receive <Evalutate>(msg => deviceManager.Tell(msg.EvalutatePhysical));

            Receive <PhysicalSetEnd>(msg
                                     => Self.Tell(new Evalutate()));
        }