Пример #1
0
        public void SaveData(string filename)
        {
            try
            {
                DeviceDescription description = new DeviceDescription();
                description.Model        = DeviceInfo.Model;
                description.Manufacturer = DeviceInfo.Manufacturer;
                foreach (var property in DeviceInfo.AvaiableProperties)
                {
                    var prop = new DeviceProperty {
                        Code = property.Code
                    };
                    foreach (var propertyValue in property.Values)
                    {
                        prop.Values.Add(new DevicePropertyValue()
                        {
                            Value = propertyValue.Value
                        });
                    }
                    description.Properties.Add(prop);
                }

                XmlSerializer serializer = new XmlSerializer(typeof(DeviceDescription));
                // Create a FileStream to write with.

                Stream writer = new FileStream(filename, FileMode.Create);
                // Serialize the object, and close the TextWriter
                serializer.Serialize(writer, description);
                writer.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show("Unable to save data " + exception.Message);
            }
        }
        public PhoneInfoAndroidViewModel(DeviceProperty dp)
        {
            this.MarginInfo = new Thickness(0, 130, 0, 0);
            this.PhoneImage = "/Resources/Images/home_phone_android.png";

            // 设备名称
            this.DeviceName = dp.ModelNumber;

            var strDevInfo = "";

            // 操作系统
            strDevInfo += "操作系统: " + dp.OSVersion + "\n";
            // IMEI
            strDevInfo += "IMEI: " + dp.IMEI + "\n";
            // 品牌
            strDevInfo += "品牌: " + dp.Brand + "\n";
            // 型号
            strDevInfo += "型号: " + dp.ModelNumber + "\n";
            // 序列号
            strDevInfo += "序列号: " + dp.SerialNumber + "\n";
            // root状态
            strDevInfo += "root状态: ";
            if (dp.IsRooted)
            {
                strDevInfo += "Rooted\n";
            }
            else
            {
                strDevInfo += "Unroot\n";
            }

            this.DeviceInfo = strDevInfo;
        }
Пример #3
0
        private void AddPropertyForMapperAndDevice(sconnPropertyMapper maper, Device edited, int DevNo)
        {
            try
            {
                iotContext     cont = new iotContext();
                DeviceProperty prop = new DeviceProperty();
                prop.PropertyName = "Input" + maper.SeqNumber;                            //TODO read from name cfg

                Device storedDevice = cont.Devices.Where(d => d.Id == edited.Id).First(); //devRepo.GetById(edited.Id);
                prop.Device         = storedDevice;
                prop.LastUpdateTime = DateTime.Now;
                cont.Properties.Add(prop);
                cont.SaveChanges();


                DeviceParameter param = new DeviceParameter();
                param.Value = sconnConfigToStringVal(maper, site.siteCfg.deviceConfigs[DevNo]);
                ParameterType extType = ParamTypeForSconnMapper(maper);
                ParameterType inType  = cont.ParamTypes.Where(p => p.Id == extType.Id).First();
                param.Type     = inType;
                param.Property = prop;
                cont.Parameters.Add(param);
                cont.SaveChanges();

                maper.Parameter = param;
                cont.PropertyResultMappers.Add(maper);
                cont.SaveChanges();
            }
            catch (Exception e)
            {
                nlogger.ErrorException(e.Message, e);
            }
        }
Пример #4
0
        private void AddPropertyForMapperAndDevice(sconnConfigMapper maper, Device edited, int DevNo)
        {
            try
            {
                iotRepository <DeviceProperty> proprepo = new iotRepository <DeviceProperty>();
                DeviceProperty prop = new DeviceProperty();
                prop.PropertyName   = "Input" + maper.SeqNumber;  //TODO read from name cfg
                prop.Device         = edited;
                prop.LastUpdateTime = DateTime.Now;
                proprepo.Add(prop);
                List <DeviceProperty> storeprops = proprepo.GetAll().ToList();
                DeviceProperty        storedProp = (from s in storeprops
                                                    where s.PropertyName == prop.PropertyName
                                                    select s).First();

                //create parameter and bind mapper to it
                iotRepository <DeviceParameter> paramrepo = new iotRepository <DeviceParameter>();
                DeviceParameter param = new DeviceParameter();
                param.Value    = sconnConfigToStringVal(maper, site.siteCfg.deviceConfigs[DevNo]);
                param.Type     = ParamTypeForSconnMapper(maper);
                param.Property = storedProp;
                paramrepo.Add(param);
                List <DeviceParameter> storeparams = paramrepo.GetAll().ToList();
                DeviceParameter        storedParam = (from p in storeparams
                                                      where p.Property == param.Property
                                                      select p).First();

                maper.Parameter = storedParam;
                iotRepository <sconnConfigMapper> mapperRepo = new iotRepository <sconnConfigMapper>();
                mapperRepo.Add(maper);
            }
            catch (Exception e)
            {
            }
        }
Пример #5
0
        public int UpdateDeviceList()
        {
            mDevicePropertyList.Clear();

            int hr = NativeMethods.WWSpatialAudioUserDoEnumeration(mInstanceId);

            if (hr < 0)
            {
                mState = StateEnum.NoAudioDevice;
                return(hr);
            }

            int nDev = NativeMethods.WWSpatialAudioUserGetDeviceCount(mInstanceId);

            for (int i = 0; i < nDev; ++i)
            {
                var sadp = new NativeMethods.WWSpatialAudioDeviceProperty();
                NativeMethods.WWSpatialAudioUserGetDeviceProperty(mInstanceId, i, ref sadp);

                var dev = new DeviceProperty(i, sadp.devIdStr, sadp.name);
                mDevicePropertyList.Add(dev);
            }
            mState = StateEnum.Ready;
            return(0);
        }
Пример #6
0
        public GateEditDialog(GateProperty gatep, DeviceConfig devconf, Guid devc_id, DeviceProperty devp)
        {
            InitializeComponent();
            InitializeDeviceType();

            gatep_   = gatep;
            devconf_ = devconf;
            devc_id_ = devc_id;
            devp_    = (devp != null) ? (devp.Clone()) : (null);

            /* 初期値設定 */
            TBox_Alias.Text = gatep.Alias;
            CBox_DeviceType.SelectedItem = devc_id;

            Btn_SelectColor.BackColor = gatep_.Color;

            ChkBox_Notify_DataSendCompleted.Checked = devconf.DataSendCompletedNotify;
            ChkBox_Notify_DataRecvCompleted.Checked = devconf.DataRecvCompletedNotify;
            ChkBox_Notify_DeviceConnect.Checked     = devconf.DeviceConnectNotify;

            ChkBox_DataSendEnable.Checked = devconf.DataSendEnable;
            Num_DataSendQueueLimit.Value  = devconf.DataSendQueueLimit;

            ChkBox_DataRedirectEnable.Checked     = devconf.DataRedirectEnable;
            Num_DataRedirectQueueLimit.Value      = devconf.DataRedirectQueueLimit;
            TBox_SendDataRedirectTargetAlias.Text = gatep.SendRedirectAlias;
            TBox_RecvDataRedirectTargetAlias.Text = gatep.RecvRedirectAlias;

            TBox_ConnectCommand.Text = gatep.ConnectCommand;
        }
 public void DeleteDeviceProperty(DeviceProperty entity)
 {
     if (entity != null)
     {
         repository.Delete(entity);
     }
 }
 public void UpdateDeviceProperty(DeviceProperty entity)
 {
     if (entity != null)
     {
         repository.Update(entity);
     }
 }
        //public DeviceProperty GetByStdId(int? id)
        //{
        //    var student = repository.GetByStdId(id);
        //    return student;
        //}

        public void InsertStudent(DeviceProperty entity)
        {
            if (entity != null)
            {
                repository.Insert(entity);
            }
        }
Пример #10
0
 public GateObjectConfig(GateProperty gatep, DeviceConfig devconf, Guid devc_id, DeviceProperty devp)
 {
     GateProperty = gatep;
     DeviceConfig = devconf;
     DeviceClassID = devc_id;
     DeviceProperty = devp;
 }
Пример #11
0
        private void HandlePropertyRule(DeviceProperty p, string value)
        {
            if (p.Trigger == null || p.Trigger == "")
            {
                return;
            }

            var match = Regex.Match(p.Trigger, @"^(.*?):([RW]):(.*?)$", RegexOptions.Singleline);

            if (match.Success)
            {
                var vv = match.Groups[1].Value;
                var op = match.Groups[2].Value;
                var pr = match.Groups[3].Value;
                if (vv == value)
                {
                    ApcmEventConfig.CQ.Enqueue(new ApcmEventArgs
                    {
                        EventSrc = "WF",
                        Address  = pr,
                        Action   = op == "W" ? "WRITE" : "READ"
                    });
                }
            }
        }
Пример #12
0
        public DeviceInstanceImpl(DeviceConfig devconf, DeviceClass devd, DeviceProperty devp)
            : base(devconf, devd, devp)
        {
            devp_ = devp as DevicePropertyImpl;

            sampling_timer_.Elapsed += OnSampling;
            sampling_timer_.Interval = VOICE_OUTPUT_IVAL;
        }
Пример #13
0
 public Task <DeviceProperty> ReadPropertyAsync(DeviceProperty property)
 {
     return(Task.Run(() =>
     {
         DeviceProperty devparam = new DeviceProperty();
         return devparam;
     }));
 }
 public Device(IDeviceControlInterrupt interrupt) : base(interrupt)
 {
     Property = new DeviceProperty
     {
         DeviceID          = "123456789",
         DeviceName        = "TEST",
         DeviceDescription = "Test Divice"
     };
 }
Пример #15
0
        private void LoadConfigToProperty(DeviceProperty property)
        {
            int devAddr = IndexForHostDevice();

            foreach (var param in property.ResultParameters)
            {
                param.Value = sconnConfigToStringVal(param.sconnMappers.First(), site.siteCfg.deviceConfigs[devAddr]);
            }
        }
Пример #16
0
 public Device(IDeviceControlInterrupt interrupt) : base(interrupt)
 {
     Property = new DeviceProperty
     {
         DeviceID          = "0x1111",
         DeviceName        = "测试设备",
         DeviceDescription = ""
     };
 }
Пример #17
0
        public ActionResult PropertyStat(int propertyId)
        {
            var            icont               = (iotContext)System.Web.HttpContext.Current.Session["iotcontext"];
            string         domainId            = DomainSession.GetContextDomain(this.HttpContext);
            iotDomain      d                   = icont.Domains.First(dm => dm.DomainName.Equals(domainId));
            DeviceProperty prop                = icont.Properties.First(p => p.Id == propertyId);
            DevicePropertyStatisticModel model = new DevicePropertyStatisticModel(prop);

            return(View(model));
        }
Пример #18
0
        private void initAllDevComp()
        {
            fpc        = new FunctionParameterCollection();
            dev        = new Device();
            AllDevices = new DeviceCollection();
            devevent   = new DeviceEvent();
            devFunc    = new DeviceFunction();
            devProp    = new DeviceProperty();

            CondColl = new ConditionsCollection();
        }
Пример #19
0
        public static CodeArgument CreateFrom(DeviceProperty deviceProperty)
        {
            var codeArgument = new CodeArgument
            {
                Name       = Helpers.ToCamelCase(Helpers.ReplaceIllegals(deviceProperty.Name)),
                Type       = Helpers.DataTypeToString(deviceProperty.Type),
                EndpointID = deviceProperty.ID
            };

            return(codeArgument);
        }
Пример #20
0
 //Returns dynamic value in generic type
 public T getValue <T>(DeviceProperty dp)
 {
     if (this.DeviceValues.ContainsKey(dp))
     {
         return((T)this.DeviceValues[dp]);
     }
     else
     {
         return(default(T));
     }
 }
Пример #21
0
        public DevicePropertyStatisticModel(DeviceProperty prop)
        {
            //DeviceRestfulService cl = new DeviceRestfulService();
            //DeviceProperty prop = cl.DevicePropertieWithId(propId,);
            //if (prop != null)
            //{
            //    Property = prop;
            //}

            this.Property = prop;
        }
Пример #22
0
        public ServiceResponse <DevicePropertyDto> GetDeviceProperty(long id)
        {
            var            Rm     = new RepositoryManager(ServiceContext);
            DeviceProperty entity = Rm.DevicePropertyRepository.Get(id);

            if (entity == null)
            {
                throw new ServiceException(ExceptionType.Warning, Translate(MessagesConstants.WRN_RECORD_NOT_FOUND));
            }
            return(new ServiceResponse <DevicePropertyDto>(entity.CopyTo(new DevicePropertyDto())));
        }
Пример #23
0
        public static CodeProperty CreateFrom(DeviceProperty deviceProperty)
        {
            var codeProperty = new CodeProperty
            {
                EndpointID = deviceProperty.ID,
                Name       = Helpers.ToPascalCase(Helpers.ReplaceIllegals(deviceProperty.Name)),
                Type       = Helpers.DataTypeToString(deviceProperty.Type),
                CanSet     = deviceProperty.Access.HasFlag(AccessMode.CanWrite)
            };

            return(codeProperty);
        }
Пример #24
0
        /// <summary>
        /// 上报子设备属性
        /// </summary>
        /// <param name="deviceId">设备ID</param>
        /// <param name="services">服务属性列表</param>
        public void ReportSubDeviceProperties(string deviceId, List <ServiceProperty> services)
        {
            DeviceProperty deviceProperty = new DeviceProperty();

            deviceProperty.deviceId = deviceId;
            deviceProperty.services = services;

            List <DeviceProperty> deviceProperties = new List <DeviceProperty>();

            deviceProperties.Add(deviceProperty);
            ReportSubDeviceProperties(deviceProperties);
        }
Пример #25
0
        public ExtractTypePrimaryViewModel(ViewModelBase vmParent)
        {
            this.ViewModelParent = vmParent;

            this.listNormalTypes   = Globals.Instance.MainActGroup[0].Acts.ToList();
            this.listAdvancedTypes = Globals.Instance.MainActGroup[1].Acts.ToList();

            // 品种
            if (Globals.Instance.AndroidPhoneSelected != null)
            {
                string strConnection = ConfigurationManager.ConnectionStrings["mdb_phone"].ToString();
                string strQuery      = "select * from edec_support_act where BrandModelID = \"" + Globals.Instance.AndroidPhoneSelected.BrandModelID + "\"; ";

                DataTable dt = DatabaseUtil.Query(strQuery, strConnection);
                foreach (DataRow tmpdr in dt.Rows)
                {
                    var strActId = int.Parse(tmpdr["ACT_ID"].ToString());

                    var act = this.listNormalTypes.Where(x => x.Id == strActId).FirstOrDefault();
                    if (act == null)
                    {
                        act = this.listAdvancedTypes.Where(x => x.Id == strActId).FirstOrDefault();
                    }

                    if (act != null)
                    {
                        act.IsAvailable = true;
                    }
                }
            }
            else
            {
                // 自动连接,先能用所有的
                foreach (Act at in this.listNormalTypes)
                {
                    at.IsAvailable = true;
                }
            }

            MainViewModel mainVM = Globals.Instance.MainVM;

            if (mainVM.CurrentDevice != null)
            {
                DeviceProperty devProperty = mainVM.CurrentDevice.DeviceProperty;

                // 查看root状态,根据root状态设置root提取的可用性
                Act actRoot = this.listNormalTypes[4];
                actRoot.IsAvailable = devProperty.IsRooted;

                // 多中选一
            }
        }
Пример #26
0
        private void initAllDevComp()
        {
            fpc    = new FunctionParameterCollection();
            devCap = new DeviceCapabilities();

            dev          = new Device();
            devcol       = new DeviceCollection();
            devEventColl = new DeviceEventCollection();
            devfuncColl  = new DeviceFunctionCollection();
            devPropColl  = new DevicePropertyCollection();
            devevent     = new DeviceEvent();
            devFunc      = new DeviceFunction();
            devProp      = new DeviceProperty();
        }
Пример #27
0
        public bool ReadProperty(DeviceProperty property)
        {
            bool update = UpdateSite();

            if (update)
            {
                LoadConfigToProperty(property);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #28
0
 public bool PropertyUpdate(DeviceProperty Property)
 {
     try
     {
         iotSharedEntityContext <DeviceProperty> propCont = new iotSharedEntityContext <DeviceProperty>();
         propCont.UpdateWithHistory(Property);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #29
0
 public bool PropertyAdd(DeviceProperty prop)
 {
     try
     {
         iotSharedEntityContext <DeviceProperty> cont = new iotSharedEntityContext <DeviceProperty>();
         cont.Add(prop);
         return(true);
     }
     catch (Exception e)
     {
         nlogger.ErrorException(e.Message, e);
         return(false);
     }
 }
Пример #30
0
        public bool ReadProperty(DeviceProperty property)
        {
            // new a GET request
            Request request = new Request(Method.GET);

            request.URI = new Uri("coap://" + property.Device.EndpInfo.Hostname.ToString() + "/" + property.PropertyName);
            request.Send();

            // wait for one response
            Response response = request.WaitForResponse();


            return(false);
        }
Пример #31
0
 /// <summary>
 /// 属性,变量的初始化
 /// </summary>
 protected virtual void Init_Property()
 {
     DP = new DeviceProperty();
 }