Beispiel #1
0
        public static DeviceTime FillDeviceTime(RobotRaconteurNode node, DeviceInfo device_info, ulong seqno)
        {
            var ret = new DeviceTime();

            ret.device_seqno = seqno;
            ret.device_ts    = TimeSpec2Now(node, device_info);
            ret.device_utc   = UtcNow(node, device_info);
            return(ret);
        }
Beispiel #2
0
        public bool Save([FromBody] DeviceTime devicetime)
        {
            DeviceTime temp = db.dbdao.GetById <DeviceTime>(devicetime.id.ToString());

            if (temp != null)
            {
                return(dbdao.DbUpdate(devicetime));
            }
            else
            {
                return(dbdao.DbInsert(devicetime));
            }
            //return device.id;
        }
        private void LoadDeviceTime(bool failureMessage)
        {
            DeviceTime time = Helpers.ReadDeviceTime(DevicePort);

            if (time != null)
            {
                TextBoxDeviceTime.Text = DateTime.Parse(time.Time).ToString(
                    "dd/MM/yyyy HH:mm:ss") + " UTC (" + (time.IsTimeValid ? "VALID" : "INVALID") + ")";
            }
            else
            {
                TextBoxDeviceTime.Text = "Unable to read device time";
                if (failureMessage)
                {
                    MessageBox.Show("Unable to read device time.");
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Get the device time
        /// </summary>
        /// <returns>Return the device time</returns>
        public DeviceTime GetDeviceTime()
        {
            DeviceTime dev_time = new DeviceTime();

            //Prepare the command
            string comando = "{\"time\":{\"get_time\":null}}";

            //Send the command to the device and get the Json string result
            string sJsonResult = this.ExecuteAndRead(comando);

            try
            {
                JObject json_object = JObject.Parse(sJsonResult);
                dev_time.LoadFromJson(json_object["time"]["get_time"]);
            }
            catch (Exception ex)
            {
                throw new NonCompatibleDeviceException(ex.Message, ex);
            }

            return(dev_time);
        }