Exemplo n.º 1
0
        private async void SendTDSOffset()
        {
            //todo:fix this method
            return;

            var offsetString = tbTDSOffset.Text;

            if (string.IsNullOrWhiteSpace(offsetString))
            {
                tbTDSOffset.Text = _settings.TDSSettings.Offset.ToString();
                return;
            }
            double offset = Convert.ToDouble(offsetString);

            _settings.TDSSettings.Offset = offset;

            Settings.Save(_settings);

            try
            {
                await Task.Run(() =>
                {
                    System.Net.WebClient wc = new System.Net.WebClient();

                    //http://192.168.10.102/SetPHOffset/3.4

                    string webData         = wc.DownloadString(string.Format("http://{0}/SetTDSOffset/{1}", _settings.SensorIP, _settings.TDSSettings.Offset));
                    WaterSensorMessage msg = WaterSensorMessage.Deserialize(webData);
                    Logging.Log(msg.msg);
                    Status.SetStatus("Updated TDS Offset");
                });
            }
            catch (Exception ex)
            {
                Logging.LogError(ex.Message);
                Status.SetStatus("Failed to update TDS Offset", Status.StatusType.ConnError);
            }
        }
Exemplo n.º 2
0
        private async void SendPHOffset()
        {
            //todo:fix this method
            return;

            var offsetString = tbPHOffset.Text;

            if (string.IsNullOrWhiteSpace(offsetString))
            {
                tbPHOffset.Text = _settings.PHSettings.Offset.ToString();
                return;
            }
            double offset = Convert.ToDouble(offsetString);

            if (cbOffsetNegative.Checked)
            {
                offset = offset * -1;
            }

            _settings.PHSettings.Offset = offset;

            Settings.Save(_settings);

            try
            {
                await Task.Run(() =>
                {
                    System.Net.WebClient wc = new System.Net.WebClient();

                    //http://192.168.10.102/SetPHOffset/3.4

                    string webData         = wc.DownloadString(string.Format("http://{0}/SetPHOffset/{1}", _settings.SensorIP, _settings.PHSettings.Offset));
                    WaterSensorMessage msg = WaterSensorMessage.Deserialize(webData);
                    Logging.Log(msg.msg);
                    Status.SetStatus("Updated PH Offset");
                });
            }
            catch (Exception ex)
            {
                Logging.LogError(ex.Message);
                Status.SetStatus("Failed to Update PH Offset", Status.StatusType.ConnError);
            }


            //if (!_isConnected) return;
            //// Create command FloatAddition, which will wait for a return command FloatAdditionResult
            //var command = new SendCommand((int)Command.SetPHOffset, (int)Command.SetPHOffsetResult, 1000);



            //command.AddArgument((float)offset);

            //// Send command
            //var cmdResult = _cmdMessenger.SendCommand(command);

            //// Check if received a (valid) response
            //if (cmdResult.Ok)
            //{
            //    // Read returned argument
            //    var returnedOffset = cmdResult.ReadFloatArg();
            //    if (Math.Round(returnedOffset, 2) != Math.Round(offset, 2))
            //        LogCommand("Returned Offset doesnt match: " + returnedOffset);

            //}
            //else
            //    LogCommand("Offset - No response!");

            // Stop running loop
            //RunLoop = false;
        }