Exemplo n.º 1
0
        /// <summary>
        /// 생성자
        /// 초기화
        /// </summary>
        public Controller(String elevatorIP, int elevatorPort, String webappAddress, String buildingID, String timeInterval)
        {
            protocol = new Protocol();
            protocol.AddProtocolItem(Marshal.SizeOf(typeof(StatusNotification)), true, new CheckFunction(StatusNotificationCheck), new CatchFunction(StatusNotificationCatch));

            this.targetIPAddress = elevatorIP;
            this.targetPort      = elevatorPort;
            this.buildingID      = buildingID;
            this.azureWebAppURL  = webappAddress;
            this.deviceID        = deviceID;

            unitDataController = new UnitDataController();
            httpClientTransfer = new HttpClientTransfer();

            var    moduleId = Environment.GetEnvironmentVariable("IOTEDGE_MODULEID");
            string deviceId = Environment.GetEnvironmentVariable("IOTEDGE_DEVICEID");

            deviceID = $"{deviceId}/{moduleId}";

            unitDataController.webappUrl  = azureWebAppURL;
            unitDataController.buildingid = buildingID;
            unitDataController.deviceid   = deviceID;

            comCheckTimer          = new Timer();
            comCheckTimer.Interval = int.Parse(timeInterval) * 1000;

            comCheckTimer.Elapsed += new ElapsedEventHandler(CommCheck);
            comCheckTimer.Enabled  = true;

            Console.WriteLine($"Device ID : {deviceId} Module ID : {moduleId}");

            StartAsyncSocket(targetIPAddress, targetPort);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 생성자
        /// 초기화
        /// </summary>
        public Controller()
        {
            protocol = new Protocol();
            protocol.AddProtocolItem(Marshal.SizeOf(typeof(StatusNotification)), true, new CheckFunction(StatusNotificationCheck), new CatchFunction(StatusNotificationCatch));

            unitDataController = new UnitDataController();
            httpClientTransfer = new HttpClientTransfer();

            unitDataController.webappUrl  = azureWebAppURL;
            unitDataController.buildingid = buildingID;

            var    moduleId = Environment.GetEnvironmentVariable("IOTEDGE_MODULEID");
            string deviceId = Environment.GetEnvironmentVariable("IOTEDGE_DEVICEID");

            unitDataController.deviceid = $"{deviceId}/{moduleId}";

            comCheckTimer          = new Timer();
            comCheckTimer.Interval = 30000;

            comCheckTimer.Elapsed += new ElapsedEventHandler(CommCheck);
            comCheckTimer.Enabled  = true;

            StartAsyncSocket(targetIPAddress, targetPort);
        }