コード例 #1
0
        // The 'send' command actions
        private void Send_Command(object sender, EventArgs e)
        {
            // Collapse all LoopingSelectors
            UnExpandLoopingSelectors(pivot, null);

            // Save the heatpump state
            App.ViewModel.settings.HeatpumpsSettings = JsonFunctions.SerializeToJsonString(App.ViewModel.heatpumps);
            App.ViewModel.settings.Save();

            // Show the progress bar and dim the app
            ModalUtils.ShowProgressBar((DependencyObject)this, LayoutRoot);

            // Create the command to send
            Heatpump selectedHeatpump = pivot.SelectedItem as Heatpump;
            HeatPumpStateCommand heatpumpCommand = new HeatPumpStateCommand();

            heatpumpCommand.command = "command";
            heatpumpCommand.identity = selectedHeatpump.controllerIdentity;
            heatpumpCommand.channel = App.ViewModel.settings.pushChannel.ChannelUri.Host + ":" +
                                      App.ViewModel.settings.pushChannel.ChannelUri.Port + ":" +
                                      App.ViewModel.settings.pushChannel.ChannelUri.AbsolutePath;
            heatpumpCommand.model = selectedHeatpump.heatpumpTypeName;

            heatpumpCommand.power = (selectedHeatpump.powerState == true) ? 1 : 0;
            heatpumpCommand.mode = (int)selectedHeatpump.operatingModes.SelectedItem;
            heatpumpCommand.fan = (int)selectedHeatpump.fanSpeeds.SelectedItem;
            heatpumpCommand.temperature = (int)selectedHeatpump.temperatures.SelectedItem;

            NetworkFunctions.SendHeatpumpCommand(heatpumpCommand);

            // Set the timeout for sending the command
            ModalUtils.timeoutTimer.Interval = TimeSpan.FromSeconds(15);
            ModalUtils.timeoutTimer.Tick += sendCommandTimeout;
            ModalUtils.timeoutTimer.Start();
        }
コード例 #2
0
        // Send the 'command' command as Json over the network
        public static void SendHeatpumpCommand(HeatPumpStateCommand heatpumpCommand)
        {
            if (HomeWifiConnected())
            {
                heatpumpCommand.channel = null;
            }

            SendJson(heatpumpCommand);
        }