示例#1
0
        public Gateway(IGatewayConnectionPort connectionPort, IMySensorsRepository db = null, IMySensorsMessagesRepository hisotryDb = null)
        {
            this.db        = db;
            this.hisotryDb = hisotryDb;

            nodes = db?.GetNodes() ?? new List <Node>();

            gatewayAliveChecker = new GatewayAliveChecker(this);

            this.connectionPort = connectionPort;
            this.connectionPort.OnDataReceived += RecieveMessage;
            this.connectionPort.OnDisconnected += OnConnectionPortDisconnected;
            this.connectionPort.OnConnected    += TryToCommunicateWithGateway;
            this.connectionPort.OnLogError     += LogError;
            this.connectionPort.OnLogInfo      += LogInfo;
            this.connectionPort.OnLogMessage   += LogMessage;
        }
示例#2
0
        public Gateway(IGatewayConnectionPort connectionPort, IMySensorsRepository db = null, IMySensorsMessagesRepository hisotryDb = null)
        {
            this.db = db;
            this.hisotryDb = hisotryDb;

            nodes = db?.GetNodes() ?? new List<Node>();

            gatewayAliveChecker = new GatewayAliveChecker(this);

            this.connectionPort = connectionPort;
            this.connectionPort.OnDataReceived += RecieveMessage;
            this.connectionPort.OnDisconnected += OnConnectionPortDisconnected;
            this.connectionPort.OnConnected += TryToCommunicateWithGateway;
            this.connectionPort.OnLogError += LogError;
            this.connectionPort.OnLogInfo += LogInfo;
            this.connectionPort.OnLogMessage += LogMessage;
        }