public override bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            GetTasksFromDB();

            return base.OnAddToEngine(engine);
        }
        public override bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            GetTasksFromDB();

            return(base.OnAddToEngine(engine));
        }
Example #3
0
        public override bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            if (Settings["WriteInDatabase"].Value == "true")
                GetStatesFromRepository();

            return base.OnAddToEngine(engine);
        }
Example #4
0
        public override bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            if (string.IsNullOrEmpty(Settings["Name"].Value))
                Settings["Name"].Value = GeneratePanelName();

            base.OnAddToEngine(engine);
            return true;
        }
Example #5
0
        public override bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            if (Settings["WriteInDatabase"].Value == "true")
            {
                GetStatesFromRepository();
            }

            return(base.OnAddToEngine(engine));
        }
Example #6
0
        public override bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            if (string.IsNullOrEmpty(Settings["Name"].Value))
            {
                Settings["Name"].Value = GeneratePanelName();
            }

            base.OnAddToEngine(engine);
            return(true);
        }
Example #7
0
        public virtual void OnRemove()
        {
            foreach (var input in Inputs)
            {
                input.OnInputChange -= engine.OnInputChange;
            }

            foreach (var output in Outputs)
            {
                output.OnOutputChange -= engine.OnOutputChange;
            }

            engine = null;
        }
        private static void OnSystemControllerStarted()
        {
            nodesEngine = SystemController.nodesEngine;

            if (nodesEngine != null)
            {
                nodesEngine.OnNewNode += OnNewNode;
                nodesEngine.OnNodeUpdatedInEditor += OnNodeUpdated;
                nodesEngine.OnRemoveNode += OnRemoveNode;
                nodesEngine.OnRemoveLink += OnRemoveLink;
                nodesEngine.OnNewLink += OnNewLink;
                nodesEngine.OnNodeActivity += OnNodeActivity;
                nodesEngine.OnRemoveAllNodesAndLinks += OnRemoveAllNodesAndLinks;
            }
        }
Example #9
0
        public virtual bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            foreach (var input in Inputs)
            {
                input.OnInputChange += engine.OnInputChange;
            }

            foreach (var output in Outputs)
            {
                output.OnOutputChange += engine.OnOutputChange;
            }

            return(true);
        }
        public MySensorsNodesEngine(Gateway gateway, NodesEngine engine)
        {
            MySensorsNodesEngine.gateway = gateway;
            MySensorsNodesEngine.mySensorsNodesEngine = this;
            MySensorsNodesEngine.engine = engine;

            gateway.OnNewNode += CreateOrUpdateNode;
            gateway.OnNodeUpdated += CreateOrUpdateNode;
            gateway.OnNewSensor += CreateOrUpdateSensor;
            gateway.OnSensorUpdated += CreateOrUpdateSensor;
            gateway.OnRemoveAllNodes += OnGatewayRemoveAllNodes;
            gateway.OnRemoveNode += OnGatewayRemoveNode;
            gateway.OnNodeBatteryUpdated += OnNodeBatteryUpdated;
            engine.OnRemoveAllNodesAndLinks += OnEngineRemoveAllNodesAndLinks;
            engine.OnRemoveNode += OnEngineRemoveNode;
            CreateAndAddMySensorsNodes();
        }
        public static string SerializePanel(string panelId, NodesEngine engine)
        {
            Node panel = engine.GetNode(panelId) as PanelNode;
            if (panel == null)
            {
                engine.LogEngineError($"Can`t serialize Panel [{panelId}]. Does not exist.");
                return null;
            }

            List<Node> nodesList = new List<Node>();
            nodesList.Add(panel);
            nodesList.AddRange(engine.GetNodesForPanel(panelId, true));

            List<Link> linksList = engine.GetLinksForPanel(panelId, true);

            return SerializeNodesAndLinks(nodesList, linksList);
        }
        public MySensorsNodesEngine(Gateway gateway, NodesEngine engine)
        {
            MySensorsNodesEngine.gateway = gateway;
            MySensorsNodesEngine.mySensorsNodesEngine = this;
            MySensorsNodesEngine.engine = engine;

            gateway.OnNewNode               += CreateOrUpdateNode;
            gateway.OnNodeUpdated           += CreateOrUpdateNode;
            gateway.OnNewSensor             += CreateOrUpdateSensor;
            gateway.OnSensorUpdated         += CreateOrUpdateSensor;
            gateway.OnRemoveAllNodes        += OnGatewayRemoveAllNodes;
            gateway.OnRemoveNode            += OnGatewayRemoveNode;
            gateway.OnNodeBatteryUpdated    += OnNodeBatteryUpdated;
            engine.OnRemoveAllNodesAndLinks += OnEngineRemoveAllNodesAndLinks;
            engine.OnRemoveNode             += OnEngineRemoveNode;
            CreateAndAddMySensorsNodes();
        }
        public UiNodesEngine(NodesEngine engine)
        {
            UiNodesEngine.engine = engine;
            engine.OnNewNode += OnNewNode;
            engine.OnRemoveNode += OnRemoveNode;
            engine.OnNodeUpdatedOnDashboard += OnNodeUpdatedOnDashboard;

            List<UiNode> nodes;

            lock (engine.nodesLock)
                nodes = engine.GetNodes()
                    .OfType<UiNode>()
                    .ToList();

            foreach (var node in nodes)
                node.OnAddToUiEngine(this);
        }
        public static string SerializePanel(string panelId, NodesEngine engine)
        {
            Node panel = engine.GetNode(panelId) as PanelNode;

            if (panel == null)
            {
                engine.LogEngineError($"Can`t serialize Panel [{panelId}]. Does not exist.");
                return(null);
            }

            List <Node> nodesList = new List <Node>();

            nodesList.Add(panel);
            nodesList.AddRange(engine.GetNodesForPanel(panelId, true));

            List <Link> linksList = engine.GetLinksForPanel(panelId, true);

            return(SerializeNodesAndLinks(nodesList, linksList));
        }
        public UiNodesEngine(NodesEngine engine)
        {
            UiNodesEngine.engine             = engine;
            engine.OnNewNode                += OnNewNode;
            engine.OnRemoveNode             += OnRemoveNode;
            engine.OnNodeUpdatedOnDashboard += OnNodeUpdatedOnDashboard;

            List <UiNode> nodes;

            lock (engine.nodesLock)
                nodes = engine.GetNodes()
                        .OfType <UiNode>()
                        .ToList();

            foreach (var node in nodes)
            {
                node.OnAddToUiEngine(this);
            }
        }
        private static void OnSystemControllerStarted()
        {
            nodesEngine = SystemController.nodesEngine;
            uiNodesEngine = SystemController.uiNodesEngine;

            if (nodesEngine != null)
            {
                nodesEngine.OnRemoveAllNodesAndLinks += OnRemoveAllNodesAndLinks;
            }

            if (uiNodesEngine != null)
            {
                uiNodesEngine.OnUiNodeUpdated += OnUiNodeUpdated;
                uiNodesEngine.OnNewUiNode += OnNewUiNode;
                uiNodesEngine.OnRemoveUiNode += OnRemoveUiNode;
                uiNodesEngine.OnPanelNodeUpdated += OnPanelNodeUpdated;
                uiNodesEngine.OnHideFromHomePage += OnHideFromHomePage;
            }
        }
        public override bool OnAddToEngine(NodesEngine engine)
        {
            if (PanelId == engine.MAIN_PANEL_ID)
            {
                LogError("Can`t create input for main panel.");
                return false;
            }

            var panel = engine.GetPanelNode(PanelId);
            if (panel == null)
            {
                LogError($"Can`t create panel input. Panel [{PanelId}] does not exist.");
                return false;
            }

            panel.AddInputNode(this);

            base.OnAddToEngine(engine);
            return true;
        }
Example #18
0
        public NodesEngine(INodesRepository nodesDb = null, INodesDataRepository dataDb = null)
        {
            NodesEngine.nodesEngine = this;

            this.nodesDb = nodesDb;
            this.dataDb  = dataDb;

            lastUpdateTime = DateTime.Now;

            activityTimer.Elapsed += UpdateShowActivity;
            activityTimer.Interval = SHOW_ACTIVITY_INTERVAL;
            activityTimer.Start();

            if (nodesDb != null)
            {
                GetNodesFromRepository();
                GetLinksFromRepository();
            }

            UpdateNodesLoop();
        }
Example #19
0
        public override bool OnAddToEngine(NodesEngine engine)
        {
            if (PanelId == engine.MAIN_PANEL_ID)
            {
                LogError("Can`t create output for main panel.");
                return(false);
            }

            var panel = engine.GetPanelNode(PanelId);

            if (panel == null)
            {
                LogError($"Can`t create panel output. Panel [{PanelId}] does not exist.");
                return(false);
            }

            panel.AddOutputNode(this);

            base.OnAddToEngine(engine);
            return(true);
        }
        public NodesEngine(INodesRepository nodesDb = null, INodesDataRepository dataDb = null)
        {

            NodesEngine.nodesEngine = this;

            this.nodesDb = nodesDb;
            this.dataDb = dataDb;

            lastUpdateTime = DateTime.Now;

            activityTimer.Elapsed += UpdateShowActivity;
            activityTimer.Interval = SHOW_ACTIVITY_INTERVAL;
            activityTimer.Start();

            if (nodesDb != null)
            {
                GetNodesFromRepository();
                GetLinksFromRepository();
            }

            UpdateNodesLoop();
        }
Example #21
0
        public virtual bool OnAddToEngine(NodesEngine engine)
        {
            this.engine = engine;

            foreach (var input in Inputs)
                input.OnInputChange += engine.OnInputChange;

            foreach (var output in Outputs)
                output.OnOutputChange += engine.OnOutputChange;

            return true;
        }
        public static void StartNodesEngine()
        {
            if (Boolean.Parse(configuration["Develop:GenerateNodesJsListFileOnStart"]))
                GenerateNodesJsListFile();

            nodesEngine = new NodesEngine(nodesDb, nodesDataDb);
            nodesEngine.SetUpdateInterval(nodesEngineConfig.UpdateInterval);
            nodesEngine.OnLogEngineInfo += logs.AddNodesEngineInfo;
            nodesEngine.OnLogEngineError += logs.AddNodesEngineError;
            nodesEngine.OnLogNodeInfo += logs.AddNodeInfo;
            nodesEngine.OnLogNodeError += logs.AddNodeError;

            if (gateway != null && nodesEngine != null)
                mySensorsNodesEngine = new MySensorsNodesEngine(gateway, nodesEngine);
            else
                mySensorsNodesEngine = null;

            uiNodesEngine = new UiNodesEngine(nodesEngine);

            if (!nodesEngineConfig.Enable) return;

            logs.AddSystemInfo("Starting nodes engine... ");
            nodesEngine.Start();

            logs.AddSystemInfo("Nodes engine started.");
        }
 public UITimerController()
 {
     engine = SystemController.nodesEngine;
 }
Example #24
0
        public virtual void OnRemove()
        {
            foreach (var input in Inputs)
                input.OnInputChange -= engine.OnInputChange;

            foreach (var output in Outputs)
                output.OnOutputChange -= engine.OnOutputChange;

            engine = null;
        }