コード例 #1
0
        private static void ActionRepairLinux(AlarmMessage alarmMessage)
        {
            WriteHighlightedMessage(
                GetDeviceIdHint(alarmMessage.ioTHubDeviceID) +
                " Repair! Depreciation=" + alarmMessage.reading +
                ", MessageID=" + alarmMessage.messageID +
                ", Threshold=" + alarmMessage.threshold,
                ConsoleColor.DarkRed);

            C2DCommandLinux c2dCommand = new C2DCommandLinux();

            c2dCommand.Name       = C2DCommandLinux.COMMAND_REPAIR_WARNING;
            c2dCommand.Parameters = new JObject();

            SendCloudToDeviceLinuxCommand(
                _serviceClient,
                alarmMessage.ioTHubDeviceID,
                c2dCommand).Wait();
        }
コード例 #2
0
        private static void ActionCutOutSpeedLinux(AlarmMessage alarmMessage)
        {
            WriteHighlightedMessage(
                GetDeviceIdHint(alarmMessage.ioTHubDeviceID) +
                " CutOutSpeed! Speed=" + alarmMessage.reading +
                ", MessageID=" + alarmMessage.messageID +
                ", Threshold=" + alarmMessage.threshold,
                ConsoleColor.DarkYellow);

            C2DCommandLinux c2dCommand = new C2DCommandLinux();

            c2dCommand.Name       = C2DCommandLinux.COMMAND_CUTOUT_SPEED_WARNING;
            c2dCommand.Parameters = new JObject();

            SendCloudToDeviceLinuxCommand(
                _serviceClient,
                alarmMessage.ioTHubDeviceID,
                c2dCommand).Wait();
        }
コード例 #3
0
        private static void ActionResetDepreciationLinux(string ioTHubDeviceID, string time)
        {
            WriteHighlightedMessage(
                GetDeviceIdHint(ioTHubDeviceID) +
                " Depreciation Reset!" +
                ", Time=" + time,
                ConsoleColor.DarkCyan);

            C2DCommandLinux c2dCommand = new C2DCommandLinux();

            c2dCommand.Name = C2DCommandLinux.COMMAND_RESET_DEPRECIATION;
            JObject jObj = new JObject();

            jObj.Add("Depreciation", 1);
            c2dCommand.Parameters = jObj;

            SendCloudToDeviceLinuxCommand(
                _serviceClient,
                ioTHubDeviceID,
                c2dCommand).Wait();
        }
コード例 #4
0
        private static void ActionEnableLinuxWindTurbine(string ioTHubDeviceID, string on, string time)
        {
            WriteHighlightedMessage(
                GetDeviceIdHint(ioTHubDeviceID) +
                " WindTurbine Enable=" + on +
                ", Time=" + time,
                ConsoleColor.DarkGreen);

            C2DCommandLinux c2dCommand = new C2DCommandLinux();

            c2dCommand.Name = C2DCommandLinux.COMMAND_TURN_ONOFF;
            JObject jObj  = new JObject();
            int     onoff = on.Equals("1") ? 1 : 0;

            jObj.Add("On", onoff);
            c2dCommand.Parameters = jObj;

            SendCloudToDeviceLinuxCommand(
                _serviceClient,
                ioTHubDeviceID,
                c2dCommand).Wait();
        }
コード例 #5
0
 private async static Task SendCloudToDeviceLinuxCommand(ServiceClient serviceClient, String deviceId, C2DCommandLinux command)
 {
     var commandMessage = new Message(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(command)));
     await serviceClient.SendAsync(deviceId, commandMessage);
 }