public LogicalHardwareNode(Node node)
     : base(0, 0)
 {
     this.nodeId = node.nodeId;
     this.Title = node.GetSimpleName1();
     this.gateway = LogicalHardwareNodesEngine.gateway;
     this.Type = "Nodes/HardwareNode";
     CreateInputsOutputs(node);
 }
        public SensorsLinksEngine(Gateway gateway, ISensorsLinksRepository db)
        {
            this.db = db;
            this.gateway = gateway;

            gateway.OnClearNodesListEvent += OnClearNodesListEvent;
            gateway.OnSensorUpdatedEvent += OnSensorUpdatedEvent;

            db.CreateDb();
            GetLinksFromRepository();
        }
        public void ConnectToGateway(Gateway gateway)
        {
            this.gateway = gateway;

            gateway.OnSensorUpdatedEvent += OnSensorUpdatedEvent;

            updateDbTimer.Elapsed += UpdateDbTimer;

            updateDbTimer.Interval = writeInterval;
            updateDbTimer.Start();
        }
        public SensorsTasksEngine(Gateway gateway, ISensorsTasksRepository db)
        {
            this.db = db;
            this.gateway = gateway;

            gateway.OnClearNodesListEvent += OnClearNodesListEvent;

            updateTasksTimer.Elapsed += UpdateTasks;
            updateTasksTimer.Interval = updateTasksInterval;

            db.CreateDb();
            GetTasksFromRepository();

            Start();
        }
        public LogicalNodesEngine(Gateway gateway, ILogicalNodesRepository db = null)
        {
            LogicalNodesEngine.logicalNodesEngine = this;

            this.db = db;

            hardwareNodesEngine = new LogicalHardwareNodesEngine(gateway, this);

            updateNodesTimer.Elapsed += UpdateNodes;
            updateNodesTimer.Interval = updateNodesInterval;

            if (db != null)
            {
                db.CreateDb();
                GetNodesFromRepository();
            }
        }
        public void ConnectToGateway(Gateway gateway)
        {
            this.gateway = gateway;

            List<Message> messages = GetMessages();
            foreach (var message in messages)
                gateway.messagesLog.AddNewMessage(message);

            List<Node> nodes = GetNodes();
            foreach (var node in nodes)
                gateway.AddNode(node);

            gateway.messagesLog.OnNewMessageLogged += OnNewMessage;
            gateway.messagesLog.OnClearMessages += OnClearMessages;

            gateway.OnClearNodesListEvent += OnClearNodesListEvent;

            gateway.OnNewNodeEvent += OnNodeUpdated;
            gateway.OnNodeUpdatedEvent += OnNodeUpdated;
            gateway.OnNewSensorEvent += OnSensorUpdated;
            gateway.OnSensorUpdatedEvent += OnSensorUpdated;

            if (writeInterval > 0)
            {
                updateDbTimer.Interval = writeInterval;
                updateDbTimer.Start();
            }
        }
 public LogicalHardwareNode()
     : base()
 {
     this.gateway = LogicalHardwareNodesEngine.gateway;
 }