public IHttpActionResult PutDeviceAttributes(int id, DeviceAttributes deviceAttributes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Entry(deviceAttributes).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeviceAttributesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            deviceMethods.SaveToDeviseALog(deviceAttributes);

            return(Ok(deviceAttributes));
        }
        /// <summary>
        /// Gets a device attrbute based on the attribute name
        /// </summary>
        /// <param name="attributeName">The name of the desired attribute</param>
        /// <returns>Returns a device attrbute based on the attribute name</returns>
        public string GetDeviceAttribute(string attributeName)
        {
            string attributeValue = null;

            if (DeviceAttributes.ContainsKey(attributeName))
            {
                attributeValue = DeviceAttributes[attributeName];
            }

            return(attributeValue);
        }
        public async Task <IHttpActionResult> GetDeviceAttributes(int id)
        {
            DeviceAttributes deviceAttributes = await db.DeviceAttributes.FindAsync(id);

            if (deviceAttributes == null)
            {
                return(NotFound());
            }

            return(Ok(deviceAttributes));
        }
        public async Task <IHttpActionResult> DeleteDeviceAttributes(int id)
        {
            DeviceAttributes deviceAttributes = await db.DeviceAttributes.FindAsync(id);

            if (deviceAttributes == null)
            {
                return(NotFound());
            }

            db.DeviceAttributes.Remove(deviceAttributes);
            await db.SaveChangesAsync();

            return(Ok(deviceAttributes));
        }
        public async Task <IHttpActionResult> PostDeviceAttributes(DeviceAttributes deviceAttributes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DeviceAttributes.Add(deviceAttributes);
            await db.SaveChangesAsync();

            deviceMethods.SaveToDeviseALog(deviceAttributes);

            return(CreatedAtRoute("DefaultApi", new { id = deviceAttributes.Id }, deviceAttributes));
        }
Exemple #6
0
        public void AttributesSetTest()
        {
            // Arrange
            uint             nItems   = 3;
            DeviceAttributes expected = DeviceAttributes.Reflective | DeviceAttributes.Matte;

            using (var psd = ProfileSequenceDescriptor.Create(null, nItems))
            {
                ProfileSequenceItem item = psd[0];

                // Act
                item.Attributes = expected;

                // Assert
                DeviceAttributes actual = item.Attributes;
                Assert.AreEqual(expected, actual);
            }
        }
        public IHttpActionResult SaveToDeviseALog(DeviceAttributes deviceAttributes)
        {
            DeviceAttributesLog deviceAttributesLog = new DeviceAttributesLog()
            {
                BatteryLowLevel             = deviceAttributes.BatteryLowLevel,
                BatteryShutdownLevel        = deviceAttributes.BatteryShutdownLevel,
                BatteryTopLevel             = deviceAttributes.BatteryTopLevel,
                CellNumber                  = deviceAttributes.CellNumber,
                CurrentAssignedCustomerName = deviceAttributes.CurrentAssignedCustomerName,
                CurrentLocationLatitude     = deviceAttributes.CurrentLocationLatitude,
                CurrentLocationLongitude    = deviceAttributes.CurrentLocationLongitude,
                CurrentLocationTimeZone     = deviceAttributes.CurrentLocationTimeZone,
                CustomerPhoneNumber         = deviceAttributes.CustomerPhoneNumber,
                DeviceAttributesId          = deviceAttributes.Id,
                EnergyMode                  = deviceAttributes.EnergyMode,
                FirmwareBranch              = deviceAttributes.FirmwareBranch,
                FirmwareCommit              = deviceAttributes.FirmwareCommit,
                FirmwareName                = deviceAttributes.FirmwareName,
                GatewayPhoneNumber          = deviceAttributes.GatewayPhoneNumber,
                HardwareVersion             = deviceAttributes.HardwareVersion,
                IMEI = deviceAttributes.IMEI,
                Name = deviceAttributes.Name,
                NotesAboutTheDevice  = deviceAttributes.NotesAboutTheDevice,
                NumberOfSleepPeriods = deviceAttributes.NumberOfSleepPeriods,
                OperationMode        = deviceAttributes.OperationMode,
                Operator             = deviceAttributes.Operator,
                SignalQuality        = deviceAttributes.SignalQuality,
                SIMnumber            = deviceAttributes.SIMnumber,
                SIMtype         = deviceAttributes.SIMtype,
                SleepPeriod     = deviceAttributes.SleepPeriod,
                Status          = deviceAttributes.Status,
                TimeOfAlert     = deviceAttributes.TimeOfAlert,
                VoltageFeedback = deviceAttributes.VoltageFeedback,
                WaterHighLevel  = deviceAttributes.WaterHighLevel,
                WaterLowLevel   = deviceAttributes.WaterLowLevel,

                SMSId = deviceAttributes.SMSId
            };

            db.DeviceAttributesLogs.Add(deviceAttributesLog);
            db.SaveChanges();
            return(Ok(deviceAttributesLog));
        }
        private unsafe LivePacketDevice(pcap_if *device)
        {
            List <DeviceAddress> list        = new List <DeviceAddress>();
            pcap_addr *          pcapAddress = (pcap_addr *)*(long *)((IntPtr)device + 24L);

            if ((IntPtr)pcapAddress != IntPtr.Zero)
            {
                do
                {
                    DeviceAddress deviceAddress = new DeviceAddress(pcapAddress);
                    list.Add(deviceAddress);
                    pcapAddress = (pcap_addr *)*(long *)pcapAddress;
                }while ((IntPtr)pcapAddress != IntPtr.Zero);
            }
            this._name        = new string((sbyte *)*(long *)((IntPtr)device + 8L));
            this._description = new string((sbyte *)*(long *)((IntPtr)device + 16L));
            this._attributes  = (DeviceAttributes) * (int *)((IntPtr)device + 32L);
            this._addresses   = new ReadOnlyCollection <DeviceAddress>((IList <DeviceAddress>)list);
        }
Exemple #9
0
        public SMSparse(SMS sms)
        {
            TankToadContext td = new TankToadContext();

            _sms         = sms;
            _error       = new List <string>();
            _diagnostics = new Diagnostics();
            _data        = new List <Data>();
            _device      = td.DeviceAttributes
                           .Where(d => d.CellNumber == sms.From)
                           .FirstOrDefault();
            if (_device == null)
            {
                ErrorList.Add("No device");
                return;
            }

            InitDSC();

            Regex DATregex = new Regex(@"^DAT:");

            if (DATregex.Matches(_sms.Body).Count > 0)
            {
                DAT();
            }
            Regex RPTregex = new Regex(@"^RPT:");

            if (RPTregex.Matches(_sms.Body).Count > 0)
            {
                RPT();
            }

            bool ifDAT = DATregex.Matches(_sms.Body).Count > 0;
            bool ifRPT = RPTregex.Matches(_sms.Body).Count > 0;

            if (!(ifRPT || ifDAT))
            {
                ErrorList.Add("SMS type");
            }
        }
 public static extern bool HidD_GetAttributes(SafeFileHandle handle, ref DeviceAttributes attributes);
Exemple #11
0
 public static extern bool HidD_GetAttributes(
     IntPtr hidDeviceObject,
     out DeviceAttributes attributes);
Exemple #12
0
        public static extern bool HidD_GetAttributes(
			IntPtr hidDeviceObject,
			out DeviceAttributes attributes);
Exemple #13
0
        private void RPT()
        {
            TankToadContext td = new TankToadContext();

            var device = td.DeviceAttributes
                         .Where(d => d.CellNumber == _sms.From)
                         .FirstOrDefault();

            if (device == null)
            {
                ErrorList.Add("No Device");
                return;
            }

            Regex lines      = new Regex(@"^(.+)$", RegexOptions.Multiline);
            var   linesMatch = lines.Matches(_sms.Body);

            if (linesMatch.Count <= 1)
            {
                ErrorList.Add("No Body");
                return;
            }

            var body = linesMatch[1].Value;

            //user number
            var userNumberReg0 = (new Regex(@"ADD:\+(\d+)\D"));
            var userNumberStr0 = userNumberReg0.Match(body).Value;
            var userNumberReg1 = (new Regex(@"\+(\d+)"));
            var userNumber     = userNumberReg1.Match(userNumberStr0).Value;

            if (userNumber.Length == 0)
            {
                _error.Add("user number");
                return;
            }
            device.CustomerPhoneNumber = userNumber;

            //gateway number
            var gatewayNumberReg0 = (new Regex(@"ADM:\+(\d+)\D"));
            var gatewayNumberStr0 = gatewayNumberReg0.Match(body).Value;
            var gatewayNumberReg1 = (new Regex(@"\+(\d+)"));
            var gatewayNumber     = gatewayNumberReg1.Match(gatewayNumberStr0).Value;

            if (gatewayNumber.Length == 0)
            {
                _error.Add("gateway number");
                return;
            }
            device.GatewayPhoneNumber = gatewayNumber;

            //WLL
            var WLL_Reg0 = (new Regex(@"WLL:(\d+)\D"));
            var WLL_Str0 = WLL_Reg0.Match(body).Value;
            var WLL_Reg1 = (new Regex(@"(\d+)"));
            var WLL_str1 = WLL_Reg1.Match(WLL_Str0).Value;

            if (WLL_str1.Length == 0)
            {
                _error.Add("WLL");
                return;
            }
            int WLL = int.Parse(WLL_str1);

            device.WaterLowLevel = WLL;

            //WHL
            var WHL_Reg0 = (new Regex(@"WHL:(\d+)\D"));
            var WHL_Str0 = WHL_Reg0.Match(body).Value;
            var WHL_Reg1 = (new Regex(@"(\d+)"));
            var WHL_str1 = WHL_Reg1.Match(WHL_Str0).Value;

            if (WHL_str1.Length == 0)
            {
                _error.Add("WHL");
                return;
            }
            int WHL = int.Parse(WHL_str1);

            device.WaterHighLevel = WHL;

            //BLL
            var BLL_Reg0 = (new Regex(@"BLL:(\d+)\D"));
            var BLL_Str0 = BLL_Reg0.Match(body).Value;
            var BLL_Reg1 = (new Regex(@"(\d+)"));
            var BLL_str1 = BLL_Reg1.Match(BLL_Str0).Value;

            if (BLL_str1.Length == 0)
            {
                _error.Add("BLL");
                return;
            }
            int BLL = int.Parse(BLL_str1);

            device.BatteryLowLevel = BLL;

            //BSL
            var BSL_Reg0 = (new Regex(@"BSL:(\d+)\D"));
            var BSL_Str0 = BSL_Reg0.Match(body).Value;
            var BSL_Reg1 = (new Regex(@"(\d+)"));
            var BSL_str1 = BSL_Reg1.Match(BSL_Str0).Value;

            if (BSL_str1.Length == 0)
            {
                _error.Add("BSL");
                return;
            }
            int BSL = int.Parse(BSL_str1);

            device.BatteryShutdownLevel = BSL;

            //BTL
            var BTL_Reg0 = (new Regex(@"BTL:(\d+)\D"));
            var BTL_Str0 = BTL_Reg0.Match(body).Value;
            var BTL_Reg1 = (new Regex(@"(\d+)"));
            var BTL_str1 = BTL_Reg1.Match(BTL_Str0).Value;

            if (BTL_str1.Length == 0)
            {
                _error.Add("BTL");
                return;
            }
            int BTL = int.Parse(BTL_str1);

            device.BatteryTopLevel = BTL;

            //TOA
            var TOA_Reg0 = (new Regex(@"TOA:(\d+)/(\d+)/(\d+):(\d+):(\d+)\D"));
            var TOA_Str0 = TOA_Reg0.Match(body).Value;
            var TOA_Reg1 = (new Regex(@":(\d+):(\d+)\D"));
            var TOA_str1 = TOA_Reg1.Match(TOA_Str0).Value;
            var TOA_Reg2 = (new Regex(@"(\d+):(\d+)"));
            var TOA_str2 = TOA_Reg2.Match(TOA_str1).Value;

            if (TOA_str2.Length == 0)
            {
                _error.Add("TOA");
                return;
            }
            device.TimeOfAlert = TOA_str2;

            //CSP
            var CSP_Reg0 = (new Regex(@"CSP:(\d+)\D"));
            var CSP_Str0 = CSP_Reg0.Match(body).Value;
            var CSP_Reg1 = (new Regex(@"(\d+)"));
            var CSP_str1 = CSP_Reg1.Match(CSP_Str0).Value;

            if (CSP_str1.Length == 0)
            {
                _error.Add("CSP");
                return;
            }
            int CSP = int.Parse(CSP_str1);

            device.SleepPeriod = CSP;

            //ANS
            var ANS_Reg0 = (new Regex(@"ANS:(\d+)\D"));
            var ANS_Str0 = ANS_Reg0.Match(body).Value;
            var ANS_Reg1 = (new Regex(@"(\d+)"));
            var ANS_str1 = ANS_Reg1.Match(ANS_Str0).Value;

            if (ANS_str1.Length == 0)
            {
                _error.Add("ANS");
                return;
            }
            int ANS = int.Parse(ANS_str1);

            device.NumberOfSleepPeriods = ANS;

            //CEM
            var CEM_Reg0 = (new Regex(@"CEM:(\d+)\D"));
            var CEM_Str0 = CEM_Reg0.Match(body).Value;
            var CEM_Reg1 = (new Regex(@"(\d+)"));
            var CEM_str1 = CEM_Reg1.Match(CEM_Str0).Value;

            if (CEM_str1.Length == 0)
            {
                _error.Add("CEM");
                return;
            }
            int CEM = int.Parse(CEM_str1);

            device.EnergyMode = CEM;

            //COM
            var COM_Reg0 = (new Regex(@"COM:(\d+)\D"));
            var COM_Str0 = COM_Reg0.Match(body).Value;
            var COM_Reg1 = (new Regex(@"(\d+)"));
            var COM_str1 = COM_Reg1.Match(COM_Str0).Value;

            if (COM_str1.Length == 0)
            {
                _error.Add("COM");
                return;
            }
            int COM = int.Parse(COM_str1);

            device.OperationMode = COM;

            //VFC
            var VFC_Reg0 = (new Regex(@"VFC:(\d+)$"));
            var VFC_Str0 = VFC_Reg0.Match(body).Value;
            var VFC_Reg1 = (new Regex(@"(\d+)"));
            var VFC_str1 = VFC_Reg1.Match(VFC_Str0).Value;

            if (VFC_str1.Length == 0)
            {
                _error.Add("VFC");
                return;
            }
            int VFC = int.Parse(VFC_str1);

            device.VoltageFeedback = VFC;

            //smsId
            device.SMSId = _sms.Id;

            device.UpdateDate = DateTime.UtcNow;

            _editedDevice = device;
        }
 private unsafe void SetAttributes(DeviceAttributes value) => SeqDesc->attributes = Convert.ToUInt64(value);
Exemple #15
0
 public static extern bool HidD_GetAttributes(
     SafeHandle hidDeviceObject,
     out DeviceAttributes attributes);