Example #1
0
 public TelescopeTempControl() : base()
 {
     TelescopeTempControl_State = new TelescopeTempControlData();
     LogPrefix       = "TTC";
     ServerPort      = 1054;
     ParameterString = "-start";
 }
Example #2
0
        /// <summary>
        /// Handle response string from weather station with boltwood object
        /// </summary>
        /// <param name="responsest">Raw string as returned from WS</param>
        /// <returns>true if succesfull</returns>
        public bool Handle_JSON_Data_ServerResponse(string responsest, out string result)
        {
            bool res = false;

            result = "";

            if (responsest == null)
            {
                return(false);
            }

            //1. Split into lines
            string[] lines = responsest.Split(new string[] { "\r\n", "\n\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            //2. Loop through lines
            foreach (string curline in lines)
            {
                //3. Convert response to JSON
                try
                {
                    //Just for try
                    TelescopeTempControl_State = JsonConvert.DeserializeObject <TelescopeTempControlData>(curline);

                    Logging.AddLog(LogPrefix + " message: " + curline, LogLevel.Debug);

                    LastCommand_Result  = true;
                    LastCommand_Message = TelescopeTempControl_State.ToString();
                    result = TelescopeTempControl_State.ToString();
                    res    = true;
                }
                catch (Exception Ex)
                {
                    Logging.LogExceptionMessage(Ex, LogPrefix + " bad message");

                    //reset command result
                    LastCommand_Result  = false;
                    LastCommand_Message = "";
                    result = "";
                    res    = false;
                }
            }

            return(res);
        }