Exemplo n.º 1
0
 private void CheckFirmwareFlash(DeviceDescrip device, string firmwareFilePath)
 {
     lock (_lock)
     {
         _actionFinished = false;
     }
     _actionStatus = BE.Instance.RequestFieldUpgrade(device, firmwareFilePath, new BackEnd.Action.CallBack(CallBack));
     Log("--------------Updating firmware on " + device.jsonStrings.Name + " -------------------");
     WaitUntilActionFinished();
     Log("Callback Received");
     Log(_actionStatus);
 }
Exemplo n.º 2
0
 private void SaveConfigsToDevice(DeviceDescrip device, string saveParamData)
 {
     lock (_lock)
     {
         _actionFinished = false;
     }
     _actionStatus = BE.Instance.SaveConfigs(device, saveParamData, new BackEnd.Action.CallBack(CallBack));
     Log("---------------- Saving configs for device " + device.jsonStrings.Name + "------------");
     WaitUntilActionFinished();
     Log("Callback Received");
     Log(_actionStatus);
 }
        /// <summary>
        /// Creates a flat array with every element at the moment of the call.  This is useful
        /// for looping through each discovered ECU while removing stale ECUs in the inner loop.
        /// Inner lopo should call Get() to confirm element still exists.
        /// </summary>
        /// <returns> Flat array of key value pairs</returns>
        public DeviceDescrip[] ToArray()
        {
            DeviceDescrip[] retval = new DeviceDescrip[_map.Count()];

            int i = 0;

            foreach (var elem in _map)
            {
                retval[i++] = elem.Value;
            }

            return(retval);
        }
Exemplo n.º 4
0
 public Status StartTesting(uint tests, DeviceDescrip deviceToUse, string firmwareFilePath, string paramData)
 {
     _tests        = tests;
     _device       = deviceToUse;
     _firmwarePath = firmwareFilePath;
     _configData   = paramData;
     if (_runningThread == null)
     {
         dotNET.Thread t = new dotNET.Thread(TestThread);
         t.Start();
         _runningThread = t;
         return(Status.Ok);
     }
     else
     {
         return(Status.Busy);
     }
 }
        public bool ChangeID(DeviceDescrip dd, byte newID)
        {
            DeviceDescrip ddRef;

            if (_map.TryGetValue(dd.ToKeyValue(), out ddRef))
            {
                /* remove the original */
                _map.Remove(ddRef.ToKeyValue());

                /* modify the ID manually, this should match the next device poll */
                ddRef.deviceID = (byte)newID;

                /* re-insert */
                Insert(ddRef);
                return(true);
            }
            return(false);
        }
        public void Insert(DeviceDescrip dd)
        {
            DeviceDescrip ddRef;

            if (_map.TryGetValue(dd.ToKeyValue(), out ddRef))
            {
                /* already there - update strings */
                ddRef.jsonStrings     = dd.jsonStrings;
                ddRef.updateTimestamp = DateTime.UtcNow;
                /* do not update configs, this comes from a seperate command */

                _map[ddRef.ToKeyValue()] = ddRef;
            }
            else
            {
                /* first insert */
                dd.updateTimestamp = DateTime.UtcNow;
                _map.Add(dd.ToKeyValue(), dd);
            }
        }
        public bool Remove(DeviceDescrip dd)
        {
            bool existed = _map.Remove(dd.ToKeyValue());

            return(existed);
        }
        public bool Get(string model, byte deviceID, out DeviceDescrip ddRef)
        {
            string keyValue = DeviceDescrip.KeyValue.ToKeyValue(model, deviceID);

            return(_map.TryGetValue(keyValue, out ddRef));
        }