Пример #1
0
 /// <summary>
 /// 导入数据
 /// </summary>
 /// <param name="json"></param>
 public static bool Load(string json)
 {
     try
     {
         DataModel data = JsonConvert.DeserializeObject <DataModel>(json);
         if (data.devName != null)
         {
             foreach (var mac in data.devName.Keys)
             {
                 DeviceName.SetDeviceName(mac, data.devName[mac]);
             }
         }
         if (data.devType != null)
         {
             foreach (var mac in data.devType.Keys)
             {
                 DeviceType.SetDeviceType(mac, (Model.DeviceType)data.devType[mac]);
             }
         }
         if (data.whiteList != null)
         {
             SetSetting("DeviceWhiteList", JsonConvert.SerializeObject(data.whiteList));
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        string deviceProtocol = "com.app.myprotocol";          // MRI device-specific protocol

        private bool ConnectToDevice(string accessoryId)
        {
            _streamDelegate = StreamDelegate.SharedController();

            _accessoryList = EAAccessoryManager.SharedAccessoryManager.ConnectedAccessories;

            foreach (EAAccessory accessory in _accessoryList)
            {
                var accId         = accessory.ValueForKey((NSString)"connectionID");
                var accessoryName = accessory.ValueForKey((NSString)"name");
                var accString     = accId.ToString();

                if (DeviceName.Contains(accessoryName.ToString()))
                {
                    _selectedAccessory = accessory;
                    _streamDelegate.SetupController(accessory, deviceProtocol);
                    _streamDelegate.OpenSession();

                    Console.WriteLine("Already connected via bluetooth");

                    return(true);
                }
            }
            return(false);
        }
        public List <DeviceName> GetAll()
        {
            List <DeviceName> returnMe = new List <DeviceName>();

            using (SqlConnection connection = new SqlConnection(this._connString))
            {
                using (SqlCommand sqlCommand = new SqlCommand
                {
                    Connection = connection,
                    CommandType = CommandType.Text,
                    CommandText = "SELECT * FROM DeviceNames;"
                })
                {
                    sqlCommand.Connection.Open();
                    SqlDataReader dbDataReader = sqlCommand.ExecuteReader();

                    if (dbDataReader.HasRows)
                    {
                        while (dbDataReader.Read())
                        {
                            DeviceName obj = dataReaderToObject(dbDataReader);
                            if (obj != null)
                            {
                                returnMe.Add(obj);
                            }
                        }
                    }

                    sqlCommand.Connection.Close();
                }
            }
            return(returnMe);
        }
Пример #4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (DeviceName.Length != 0)
            {
                hash ^= DeviceName.GetHashCode();
            }
            if (InterfaceName.Length != 0)
            {
                hash ^= InterfaceName.GetHashCode();
            }
            if (Address.Length != 0)
            {
                hash ^= Address.GetHashCode();
            }
            if (DeviceDetails.Length != 0)
            {
                hash ^= DeviceDetails.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #5
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("DeviceNames/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyDeviceName = new DeviceName();

            if (await TryUpdateModelAsync <DeviceName>(
                    emptyDeviceName,
                    "devicename",                     // Prefix for form value
                    d => d.Name,
                    d => d.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.DeviceName.Add(emptyDeviceName);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
Пример #6
0
        public override void FromString(params string[] ParaList)
        {
            if (ParaList.Length != 3)
            {
                throw new Exception($"Wrong para number when parse {DeviceName.ToString()} formstring");
            }
            GuiStringList.Clear();
            foreach (var it in ParaList)
            {
                GuiStringList.Add(it);
            }

            var L1 = GuiStringList[0].Split('_');

            //Name
            Enum.TryParse(L1[0], out EnumDeviceName Dn);
            DeviceName = Dn;

            //LocalIndex
            LocalIndex = int.Parse(L1[1]);

            Function = 0x23;

            //GlobalIndex
            GlobalIndex = int.Parse(GuiStringList[2]);
        }
Пример #7
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (Control != 0)
        {
            hash ^= Control.GetHashCode();
        }
        if (Status != 0)
        {
            hash ^= Status.GetHashCode();
        }
        if (DeviceName.Length != 0)
        {
            hash ^= DeviceName.GetHashCode();
        }
        if (DeviceId.Length != 0)
        {
            hash ^= DeviceId.GetHashCode();
        }
        if (Operator.Length != 0)
        {
            hash ^= Operator.GetHashCode();
        }
        return(hash);
    }
Пример #8
0
    //===========================  unity Send
//	public void initialPluginnnn(){
//		//Debug.Log("inital OnUnity");
//		_InitGSensor();
//	}
//	public void  onUnityStartScan (){
//		//Debug.Log("OnUnityStartScan");
//		_onUnityStartScan();
//	}

    public static void OnUnityStartScan()
    {
        Debug.Log("OnUnityStartScan");
        _onUnityStartScan();

        DeviceName.Clear();
    }
Пример #9
0
 public DeviceLicense(DeviceName name, DeviceType type, DirectionType direction, byte value)
 {
     _name      = name;
     _type      = type;
     _direction = direction;
     SetValue(value);
 }
Пример #10
0
        /// <summary>
        /// strDevName device subnet id and device id
        /// </summary>
        /// <param name="strDevName"></param>
        public override void DownLoadInformationFrmDevice(string strDevName, int intDeviceType, int intActivePage, int num1, int num2)// 0 mean all, else that tab only
        {
            Boolean BlnIsSuccess = false;

            if (strDevName == null)
            {
                return;
            }
            string strMainRemark = strDevName.Split('\\')[1].Trim();

            DeviceName = strDevName.Split('\\')[0].Trim();

            byte bytSubID = byte.Parse(DeviceName.Split('-')[0].ToString());
            byte bytDevID = byte.Parse(DeviceName.Split('-')[1].ToString());

            byte[] ArayTmp = null;

            base.DownLoadInformationFrmDevice(strDevName, intDeviceType, intActivePage, 0, 0);

            // 读取回路信息
            Chans = new BasicCurtain();
            Chans.ReadCurtainSetupInformation(bytSubID, bytDevID, 1, intDeviceType);
            MyRead2UpFlags[0] = true;
            if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy)
            {
                CsConst.calculationWorker.ReportProgress(100, null);
            }
            BlnIsSuccess = true;
            return;
        }
Пример #11
0
        public override void FromString(params string[] ParaList)
        {
            if (ParaList.Length != 11)
            {
                throw new Exception($"Wrong para number when parse {DeviceName.ToString()} formstring");
            }
            GuiStringList.Clear();
            foreach (var it in ParaList)
            {
                GuiStringList.Add(it);
            }



            Name          = GuiStringList[0];
            Function      = GuiStringList[1];
            Plug_Sequence = GuiStringList[2];

            Enum.TryParse(StrEnumResolution.Where(a => a.Value.Equals(GuiStringList[3])).First().Key.ToString(), out EnumHL5002Resolution resolution);
            Enum.TryParse(StrEnumRevolution.Where(a => a.Value.Equals(GuiStringList[4])).First().Key.ToString(), out EnumHL5002Revolution revolution);
            Resolution = resolution;
            Revolution = revolution;

            PresetValue = GuiStringList[5];


            ResPara1 = GuiStringList[6];
            ResPara2 = GuiStringList[7];
            ResPara3 = GuiStringList[8];
            ResPara4 = GuiStringList[9];
            ResPara5 = GuiStringList[10];
        }
Пример #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = AlertID;
         hashCode = (hashCode * 397) ^ Code;
         hashCode = (hashCode * 397) ^ (Source != null ? Source.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Severity != null ? Severity.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Created.GetHashCode();
         hashCode = (hashCode * 397) ^ SnoozedEndDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (ThresholdValue1 != null ? ThresholdValue1.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ThresholdValue2 != null ? ThresholdValue2.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ThresholdValue3 != null ? ThresholdValue3.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ThresholdValue4 != null ? ThresholdValue4.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ThresholdValue5 != null ? ThresholdValue5.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DeviceGuid != null ? DeviceGuid.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AdditionalInfo != null ? AdditionalInfo.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AlertCategoryID != null ? AlertCategoryID.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Archived.GetHashCode();
         hashCode = (hashCode * 397) ^ ArchivedDate.GetHashCode();
         hashCode = (hashCode * 397) ^ TicketID.GetHashCode();
         hashCode = (hashCode * 397) ^ (AlertMessage != null ? AlertMessage.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DeviceName != null ? DeviceName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CustomerID;
         hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MessageTemplate != null ? MessageTemplate.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ FolderID.GetHashCode();
         hashCode = (hashCode * 397) ^ PollingCyclesCount.GetHashCode();
         return(hashCode);
     }
 }
Пример #13
0
 public DeviceLicense(DeviceName name, DeviceType type, DirectionType direction, byte levelID, byte functionControl)
 {
     _name            = name;
     _type            = type;
     _levelID         = levelID;
     _direction       = direction;
     _functionControl = functionControl;
 }
Пример #14
0
        public override int GetHashCode()
        {
            int hashFullName   = FullName == null ? 0 : FullName.GetHashCode();
            int hashDeviceName = DeviceName == null ? 0 : DeviceName.GetHashCode();
            int hashCOMPort    = COMPort == null ? 0 : COMPort.GetHashCode();

            return(hashFullName ^ hashDeviceName ^ hashCOMPort);
        }
Пример #15
0
        public IConfiguration AddDeviceEmulation(DeviceName deviceName,
                                                 ScreenOrientation screenOrientation = ScreenOrientation.Portrait,
                                                 string baselineEnvName = null)
        {
            ChromeEmulationInfo emulationInfo = new ChromeEmulationInfo(deviceName, screenOrientation);

            return(AddBrowser(emulationInfo));
        }
Пример #16
0
            /// <summary>
            /// 导出数据
            /// </summary>
            /// <returns></returns>
            public static string Export()
            {
                var res = new DataModel();

                res.devName = DeviceName.GetDeviceName();
                res.devType = DeviceType.GetDeviceType();
                return(JsonConvert.SerializeObject(res));
            }
Пример #17
0
 /// <summary>
 /// Computes the hash code for the current metadata object.
 /// </summary>
 /// <returns>
 /// The hash code for the current metadata object, extracted from a combination
 /// of hashes for the device name and various version numbers.
 /// </returns>
 public override int GetHashCode()
 {
     return(17 * DeviceName.GetHashCode() +
            8971 * FirmwareVersion.GetHashCode() +
            2803 * ProtocolVersion.GetHashCode() +
            691 * HardwareVersion.GetHashCode() +
            1409 * AssemblyNumber.GetHashCode() +
            2333 * PrereleaseVersion.GetHashCode());
 }
    private void Start()
    {
        string initialRecordingDeviceName = settings.RecordingDeviceName.IsNullOrEmpty() || !Microphone.devices.Contains(settings.RecordingDeviceName)
            ? Microphone.devices.FirstOrDefault()
            : settings.RecordingDeviceName;

        SetRecordingDevice(initialRecordingDeviceName, settings.SampleRate);
        DeviceName.Subscribe(newValue => settings.RecordingDeviceName = newValue);
    }
Пример #19
0
            public override int GetHashCode()
            {
                int result = DeviceName.GetHashCode();

                result = 31 * result + Interval;
                result = 31 * result + Timeout;
                result = 31 * result + EqualityComparer <byte[]> .Default.GetHashCode(ScanResponse);;
                return(result);
            }
Пример #20
0
        public static void ReadFile()
        {
            string DeviceName;
            string TableConfig;

            using (System.IO.StreamReader file =
                       new System.IO.StreamReader(@"D:\jinchen\projects\webapi2\source1.txt", true))
            {
                try
                {
                    int    counter = 0;
                    string line;
                    while ((line = file.ReadLine()) != null)
                    {
                        //  System.Console.WriteLine(line);

                        string[] sA = line.Split('\t');

                        int ln = sA.Length;
                        if (ln > 0)
                        {
                            DeviceName = sA[0] as string;
                            DeviceName = DeviceName.Trim();
                            if (DeviceName == "")
                            {
                                continue;
                            }

                            if (ln > 1)
                            {
                                for (int i = 1; i < ln; i++)
                                {
                                    TableConfig = sA[i] as string;
                                    TableConfig = TableConfig.Trim();
                                    if (TableConfig == "")
                                    {
                                        continue;
                                    }
                                    Console.Write(DeviceName + "  ");
                                    GenerateSQLFile(DeviceName, TableConfig);
                                    Console.Write(TableConfig + "  ");
                                    Console.WriteLine("  ");
                                    counter++;
                                }
                            }
                        }
                    }

                    Console.WriteLine(counter);
                }
                catch (System.NullReferenceException e)
                {
                    file.Close();
                }
            }
        }
Пример #21
0
        public uint AbrirDispositoPeloID(DeviceName id)
        {
            uint Retorno = m_NBioAPI.OpenDevice((short)id);

            if (Retorno == NBioAPI.Error.NONE)
            {
                throw new Exception("Não foi possível abrir o dispositivo informado.");
            }
            return(Retorno);
        }
        public override bool CanDoDelete()
        {
            bool canDelete = true;

            if (IsEdit() && DeviceName.EndsWith("SAMP0"))
            {
                canDelete = false;
            }
            return(canDelete);
        }
Пример #23
0
    public static void onChoseToConnectDevice(string key)
    {
        if (DeviceName.Contains(key))
        {
            int temp = DeviceName.IndexOf(key);
//			if(temp==-1)
//				return;
            Debug.Log("!!!!!!!!   onChoseToConnectDevice in unity" + temp + "   " + key);
            _onChoseToConnectDevice(temp);
        }
    }
Пример #24
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (Photos != null)
         {
             hashCode = hashCode * 59 + Photos.GetHashCode();
         }
         if (Gear != null)
         {
             hashCode = hashCode * 59 + Gear.GetHashCode();
         }
         if (Calories != null)
         {
             hashCode = hashCode * 59 + Calories.GetHashCode();
         }
         if (SegmentEfforts != null)
         {
             hashCode = hashCode * 59 + SegmentEfforts.GetHashCode();
         }
         if (DeviceName != null)
         {
             hashCode = hashCode * 59 + DeviceName.GetHashCode();
         }
         if (EmbedToken != null)
         {
             hashCode = hashCode * 59 + EmbedToken.GetHashCode();
         }
         if (SplitsMetric != null)
         {
             hashCode = hashCode * 59 + SplitsMetric.GetHashCode();
         }
         if (SplitsStandard != null)
         {
             hashCode = hashCode * 59 + SplitsStandard.GetHashCode();
         }
         if (Laps != null)
         {
             hashCode = hashCode * 59 + Laps.GetHashCode();
         }
         if (BestEfforts != null)
         {
             hashCode = hashCode * 59 + BestEfforts.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #25
0
 public bool Equals(Device other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(DeviceName.ToLower() == other.DeviceName.ToLower());
 }
Пример #26
0
        public DeviceLicense(DeviceName name, DeviceType type, DirectionType direction, UInt16 value, bool singleton)
        {
            _name      = name;
            _type      = type;
            _direction = direction;
            _singleton = singleton;

            byte high = (byte)(value >> 8);
            byte low  = (byte)(value & 0x00FF);

            SetValue(new byte[] { high, low });
        }
Пример #27
0
        public override List <string> ToStringList()
        {
            GuiStringList.Clear();
            //Name_LocalIndex
            GuiStringList.Add($"{DeviceName.ToString()}_{LocalIndex}");
            //Function
            GuiStringList.Add("DO8xDC24V 2.0A");
            //GlobalIndex
            GuiStringList.Add($"{GlobalIndex}");

            return(GuiStringList);
        }
        public ThermometerValuesUpdated(DeviceId deviceId, EventId eventId, DeviceName deviceName,
                                        Temperature temperature, UnitOfMeasurement unitOfMeasurement, CommunicationDate communicationDate, AccountInfo who, When when)
            : base(deviceId, who, when)
        {
            this.EventId = eventId;

            this.DeviceId          = deviceId;
            this.DeviceName        = deviceName;
            this.Temperature       = temperature;
            this.UnitOfMeasurement = unitOfMeasurement;
            this.CommunicationDate = communicationDate;
        }
Пример #29
0
        public LocalAudioSource GetLocalAudioDevice(DeviceName deviceName)
        {
            var devices = _audioSources;

            if (devices != null)
            {
                return(devices.FirstOrDefault(s => s.Name == deviceName.Name && s.Id == deviceName.DeviceId) ??
                       devices.FirstOrDefault(s => s.Name == deviceName.Name) ??
                       devices.FirstOrDefault(s => s.Id == deviceName.DeviceId));
            }
            return(null);
        }
Пример #30
0
        private static async Task <DeviceName> LoadJsonDeviceNameAsync(string path)
        {
            DeviceName parameters = new DeviceName();

            using (StreamReader r = new StreamReader(path))
            {
                string json = await r.ReadToEndAsync();

                parameters = JsonConvert.DeserializeObject <DeviceName>(json);
            }

            return(parameters);
        }
Пример #31
0
        public static DeviceName[] List(DOMAIN domain)
        {
            IntPtr NamesHandle;

            // first, get the data, using an opaque token for the string array
            int status = FLIList(domain, out NamesHandle);
            if (0 != status)
                throw new Win32Exception(-status);

            // now marshal the string array into the return type we actually want
            List<DeviceName> NameList = new List<DeviceName>();
            IntPtr p = NamesHandle;
            string s;
            while (IntPtr.Zero != p)
            {
                // manually bring the string into managed memory
                s = ((StringWrapper)Marshal.PtrToStructure(p, typeof(StringWrapper))).s;
                if (null == s)
                    break;

                // parse it according to FLI SDK spec
                int DelimPos = s.IndexOf(';');
                DeviceName dn = new DeviceName();
                dn.FileName = (-1 == DelimPos ? s : s.Substring(0, DelimPos));
                dn.ModelName = (-1 == DelimPos ? null : s.Substring(DelimPos + 1, s.Length - (DelimPos + 1)));
                // and accumulate into our list
                NameList.Add(dn);

                // move to the next pointer
                p += sizeof(int);
            }

            // don't bother the caller with memory management now that we've made our own copy
            FLIFreeList(NamesHandle);

            // render the result to the caller!
            return NameList.ToArray();
        }