Beispiel #1
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]);
        }
        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];
        }
Beispiel #3
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);
        }
Beispiel #4
0
        private void CamInitDelay_Tick(object sender, EventArgs e)
        {
            HTuple Information, InfoBoards, AvailableDevices, MisconfiguredDevices, DeviceName, Suggestions, Generic, TmpString, MAC;

            ((Timer)sender).Stop();
            ((Timer)sender).Dispose();
            try
            {
                HOperatorSet.InfoFramegrabber("GigEVision", "info_boards", out Information, out InfoBoards);
                Log("Device Found: " + InfoBoards.Length.ToString());
                HOperatorSet.TupleRegexpSelect(InfoBoards, "status:misconfigured", out MisconfiguredDevices);
                Log("Misconfigured Device: " + MisconfiguredDevices.Length.ToString());
                if (MisconfiguredDevices.Length > 0)
                {
                    Log("Fixing misconfigured devices. ");
                    HOperatorSet.TupleRegexpMatch(MisconfiguredDevices, "suggestion:[^ ]+", out Suggestions);
                    Log(Suggestions.ToString());
                    for (int i = 0; i < Suggestions.Length; i++)
                    {
                        HOperatorSet.TupleStrLastN(Suggestions, 11, out Generic);
                        HOperatorSet.TupleStrLastN(Generic, 11, out TmpString);
                        HOperatorSet.TupleStrFirstN(TmpString, 11, out MAC);
                        HOperatorSet.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "progressive", -1, "default", Generic, "false", "default", MAC, 0, -1, out TmpString);
                        HOperatorSet.CloseFramegrabber(TmpString);
                    }
                }

                HOperatorSet.InfoFramegrabber("GigEVision", "info_boards", out Information, out InfoBoards);
                HOperatorSet.TupleRegexpSelect(InfoBoards, "status:available", out AvailableDevices);
                if (AvailableDevices.Length > 0)
                {
                    HOperatorSet.TupleRegexpMatch(AvailableDevices, "device:[^ ]+", out DeviceName);
                    HOperatorSet.TupleStrLastN(DeviceName, 7, out DeviceName);
                    Log(DeviceName.ToString());
                    for (int i = 0; i < DeviceName.Length; i++)
                    {
                        HOperatorSet.OpenFramegrabber("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1, "default", -1, "false", "default", DeviceName[i], 0, -1, out TmpString);
                        AcqHandle.TupleConcat(TmpString);
                        AcqHandle[i] = TmpString;
                    }
                }

                //HOperatorSet.OpenFramegrabber ("GigEVision", 0, 0, 0, 0, 0, 0, "default", -1, "default", -1, "false", "default", "00305313ce47_Basler_acA250014gm", 0, -1, out AcqHandle);
            }
            catch (Exception ex)
            {
                Log(ex.Message);
            }
        }
Beispiel #5
0
 public override void FromString(params string[] ParaList)
 {
     if (ParaList.Length != GuiStringListNumber)
     {
         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];
 }
        public override void FromString(params string[] ParaList)
        {
            InputTypeDic.Clear();
            AccuracyDic.Clear();

            InputTypeDic.Add(0x00, "Normal");
            InputTypeDic.Add(0x01, "4-20mA");
            InputTypeDic.Add(0x02, "0-20mA");
            for (byte i = 3; i < 11; i++)
            {
                InputTypeDic.Add(i, $"Reserved{i}");
            }

            AccuracyDic.Add(0x0A, "10bits sampling");
            AccuracyDic.Add(0x0C, "12bits sampling");
            AccuracyDic.Add(0x10, "16bits sampling");

            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);
            }
            var L1 = GuiStringList[0].Split('_');

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

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

            Function = 0x32;

            //GlobalIndex
            GlobalIndex = int.Parse(GuiStringList[2]);

            for (int i = 0; i < 4; i++)
            {
                ChInputTypeArr[i] = InputTypeDic.Where(a => a.Value.Equals(GuiStringList[2 * i + 3])).First().Key;
                ChAccuracyArr[i]  = AccuracyDic.Where(a => a.Value.Equals(GuiStringList[2 * i + 4])).First().Key;
            }
        }
        public override List <string> ToStringList()
        {
            GuiStringList.Clear();
            //Name_LocalIndex
            GuiStringList.Add($"{DeviceName.ToString()}_{LocalIndex}");
            //Function
            GuiStringList.Add("AIx4Ch. 4-20mA");
            //GlobalIndex
            GuiStringList.Add($"{GlobalIndex}");

            for (int i = 0; i < 4; i++)
            {
                GuiStringList.Add($"{InputTypeDic[ChInputTypeArr[i]]}");
                GuiStringList.Add($"{AccuracyDic[ChAccuracyArr[i]]}");
            }

            return(GuiStringList);
        }
Beispiel #8
0
        public override void FromString(params string[] ParaList)
        {
            if (ParaList.Length != GuiStringListNumber)
            {
                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(StrEnumType.Where(a => a.Value.Equals(GuiStringList[3])).FirstOrDefault().Key.ToString(), out EnumHL1001Type type);
            Type = type;
        }
        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);
            }


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

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


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

            Function = 0x51;

            //GlobalIndex
            GlobalIndex = int.TryParse(GuiStringList[2], out int globalIndex) ? globalIndex : 0;

            //CounterLimitH
            CounterLimitH = byte.TryParse(GuiStringList[3], out byte counterLimitH)? counterLimitH : (byte)0;

            //CounterLimitL
            CounterLimitL = byte.TryParse(GuiStringList[4], out byte counterLimitL) ? counterLimitL : (byte)0;

            //ResPara
            for (int i = 0; i < 6; i++)
            {
                ResParaArr[i] = byte.TryParse(GuiStringList[i + 5], out byte resPara)? resPara:(byte)0;
            }
        }
        public override List <string> ToStringList()
        {
            GuiStringList.Clear();
            //Name_LocalIndex
            GuiStringList.Add($"{DeviceName.ToString()}_{LocalIndex}");
            //Function
            GuiStringList.Add("DI8xDC24V");
            //GlobalIndex
            GuiStringList.Add($"{GlobalIndex}");
            //LimitH
            GuiStringList.Add($"{CounterLimitH}");
            //LimitL
            GuiStringList.Add($"{CounterLimitL}");

            for (int i = 0; i < 6; i++)
            {
                GuiStringList.Add($"{ResParaArr[i]}");
            }

            return(GuiStringList);
        }
Beispiel #11
0
        public override void FromString(params string[] ParaList)
        {
            EnumHL3001Type     type;
            EnumHL3001Accuracy acc;

            if (ParaList.Length != GuiStringListNumber)
            {
                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(StrEnumType.Where(a => a.Value.Equals(GuiStringList[3])).FirstOrDefault().Key.ToString(), out type);
            Enum.TryParse(StrEnumAccuracy.Where(a => a.Value.Equals(GuiStringList[4])).FirstOrDefault().Key.ToString(), out acc);
            Ch1_Input_Type = type;
            Ch1_Accuracy   = acc;
            Enum.TryParse(StrEnumType.Where(a => a.Value.Equals(GuiStringList[5])).FirstOrDefault().Key.ToString(), out type);
            Enum.TryParse(StrEnumAccuracy.Where(a => a.Value.Equals(GuiStringList[6])).FirstOrDefault().Key.ToString(), out acc);
            Ch2_Input_Type = type;
            Ch2_Accuracy   = acc;


            Enum.TryParse(StrEnumType.Where(a => a.Value.Equals(GuiStringList[7])).FirstOrDefault().Key.ToString(), out type);
            Enum.TryParse(StrEnumAccuracy.Where(a => a.Value.Equals(GuiStringList[8])).FirstOrDefault().Key.ToString(), out acc);
            Ch3_Input_Type = type;
            Ch3_Accuracy   = acc;

            Enum.TryParse(StrEnumType.Where(a => a.Value.Equals(GuiStringList[9])).FirstOrDefault().Key.ToString(), out type);
            Enum.TryParse(StrEnumAccuracy.Where(a => a.Value.Equals(GuiStringList[10])).FirstOrDefault().Key.ToString(), out acc);
            Ch4_Input_Type = type;
            Ch4_Accuracy   = acc;
        }
        public override List <string> ToStringList()
        {
            GuiStringList.Clear();

            //Name_LocalIndex
            GuiStringList.Add($"{DeviceName.ToString()}_{LocalIndex}");
            //Function
            GuiStringList.Add("AbsEncoder SSI");
            //GlobalIndex
            GuiStringList.Add($"{GlobalIndex}");
            //Resolution
            GuiStringList.Add($"{ResolutionDic[Resolution]}");
            //Revolution
            GuiStringList.Add($"{RevolutionDic[Revolution]}");

            GuiStringList.Add($"{PresetValue}");

            for (int i = 0; i < 5; i++)
            {
                GuiStringList.Add($"{ResParaArr[i]}");
            }

            return(GuiStringList);
        }
        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];
            CounterLimitH = GuiStringList[3];
            CounterLimitL = GuiStringList[4];
            ResPara1      = GuiStringList[5];
            ResPara2      = GuiStringList[6];
            ResPara3      = GuiStringList[7];
            ResPara4      = GuiStringList[8];
            ResPara5      = GuiStringList[9];
            ResPara6      = GuiStringList[10];
        }
        public override void FromString(params string[] ParaList)
        {
            TypeDic.Clear();
            for (int i = 0; i < TypeList.Count(); i++)
            {
                TypeDic.Add(TypeList[i], TypeStringList[i]);
            }

            if (ParaList.Length != GuiStringListNumber)
            {
                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 = 0x11;

            //GlobalIndex
            GlobalIndex = int.Parse(GuiStringList[2]);

            //Type
            Type = TypeDic.Where(a => a.Value.Equals(GuiStringList[3])).First().Key;
        }
Beispiel #15
0
    public override string ToString()
    {
        var  sb      = new StringBuilder("DeviceInfo(");
        bool __first = true;

        if (DeviceName != null && __isset.deviceName)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("DeviceName: ");
            DeviceName.ToString(sb);
        }
        if (SystemName != null && __isset.systemName)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("SystemName: ");
            SystemName.ToString(sb);
        }
        if (SystemVersion != null && __isset.systemVersion)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("SystemVersion: ");
            SystemVersion.ToString(sb);
        }
        if (Model != null && __isset.model)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("Model: ");
            Model.ToString(sb);
        }
        if (__isset.carrierCode)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("CarrierCode: ");
            CarrierCode.ToString(sb);
        }
        if (CarrierName != null && __isset.carrierName)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("CarrierName: ");
            CarrierName.ToString(sb);
        }
        if (__isset.applicationType)
        {
            if (!__first)
            {
                sb.Append(", ");
            }
            __first = false;
            sb.Append("ApplicationType: ");
            ApplicationType.ToString(sb);
        }
        sb.Append(")");
        return(sb.ToString());
    }
        public override void FromString(params string[] ParaList)
        {
            ResolutionDic.Clear();
            RevolutionDic.Clear();
            ResolutionDic.Add(0, "Normal");
            RevolutionDic.Add(0, "Normal");
            for (byte i = 1; i < 17; i++)
            {
                ResolutionDic.Add(i, $"{i}bits");
                RevolutionDic.Add(i, $"{i}bits");
            }

            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);
            }

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

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


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

            Function = 0x52;

            //GlobalIndex
            GlobalIndex = int.Parse(GuiStringList[2]);

            //Resolution
            Resolution = ResolutionDic.Where(a => a.Value.Equals(GuiStringList[3])).First().Key;

            //Revolution
            Revolution = RevolutionDic.Where(a => a.Value.Equals(GuiStringList[4])).First().Key;

            //PresetValue
            if (UInt32.TryParse(GuiStringList[5], out UInt32 presetValue))
            {
                PresetValue = presetValue;
            }
            else
            {
                PresetValue = 0;
            }

            //ResPara
            for (int i = 0; i < 5; i++)
            {
                if (byte.TryParse(GuiStringList[i + 6], out byte resValue))
                {
                    ResParaArr[i] = resValue;
                }
                else
                {
                    ResParaArr[i] = 0;
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// 获取未知设备信息
        /// </summary>
        /// <param name="DeviceIndex"></param>
        /// <param name="ClassName"></param>
        /// <param name="DeviceName"></param>
        /// <returns></returns>
        public static int EnumerateDevices(List <string> NameList, List <string> IDList, List <string> MfgList, List <string> TypeList, List <string> IsInstallDriversList)
        {
            Guid   myGUID   = System.Guid.Empty;
            IntPtr hDevInfo = SetupDiGetClassDevsA(ref myGUID, 0, IntPtr.Zero, DIGCF_ALLCLASSES);

            if (hDevInfo.ToInt32() == -1)
            {
                //设备不可用

                return(-3);
            }
            SP_DEVINFO_DATA DeviceInfoData = new SP_DEVINFO_DATA();

            DeviceInfoData.cbSize = 28;
            //正常状态
            DeviceInfoData.DevInst   = 0;
            DeviceInfoData.ClassGuid = System.Guid.Empty;
            DeviceInfoData.Reserved  = 0;
            UInt32 i;

            for (i = 0; SetupDiEnumDeviceInfo(hDevInfo, i, DeviceInfoData); i++)
            {
                //设备名称
                StringBuilder DeviceName = new StringBuilder("");
                //设备ID
                StringBuilder DeviceID = new StringBuilder("");
                //设备供应商
                StringBuilder Mfg = new StringBuilder("");
                //设备类型
                StringBuilder DeviceType = new StringBuilder("");
                //设备类型
                StringBuilder IsInstallDrivers = new StringBuilder("");
                DeviceName.Capacity       = MAX_DEV_LEN;
                DeviceID.Capacity         = MAX_DEV_LEN;
                DeviceType.Capacity       = MAX_DEV_LEN;
                Mfg.Capacity              = MAX_DEV_LEN;
                IsInstallDrivers.Capacity = MAX_DEV_LEN;
                bool resName = SetupDiGetDeviceRegistryPropertyA(hDevInfo, DeviceInfoData, SPDRP_DEVICEDESC, 0, DeviceName, MAX_DEV_LEN, IntPtr.Zero);
                if (!resName)
                {
                    //设备名称未知
                    DeviceName = new StringBuilder("");
                }
                bool resClass = SetupDiGetDeviceRegistryPropertyA(hDevInfo, DeviceInfoData, SPDRP_CLASS, 0, DeviceType, MAX_DEV_LEN, IntPtr.Zero);
                if (!resClass)
                {
                    //设备类型未知
                    DeviceType = new StringBuilder("");
                }
                //设备ID
                bool resHardwareID = SetupDiGetDeviceRegistryPropertyA(hDevInfo,
                                                                       DeviceInfoData, SPDRP_HARDWAREID, 0, DeviceID, MAX_DEV_LEN, IntPtr.Zero);
                if (!resHardwareID)
                {
                    //设备ID未知
                    DeviceID = new StringBuilder("");
                }

                //设备供应商
                bool resMfg = SetupDiGetDeviceRegistryPropertyA(hDevInfo,
                                                                DeviceInfoData, SPDRP_MFG, 0, Mfg, MAX_DEV_LEN, IntPtr.Zero);
                if (!resMfg)
                {
                    //设备供应商未知
                    Mfg = new StringBuilder("");
                }

                bool resIsInstallDrivers = SetupDiGetDeviceRegistryPropertyA(hDevInfo,
                                                                             DeviceInfoData, SPDRP_DRIVER, 0, IsInstallDrivers, MAX_DEV_LEN, IntPtr.Zero);
                if (!resIsInstallDrivers)
                {
                    //设备是否安装驱动
                    IsInstallDrivers = new StringBuilder("");
                }

                if (string.IsNullOrEmpty(DeviceType.ToString()))
                {
                    if (!string.IsNullOrEmpty(DeviceName.ToString()) && !string.IsNullOrEmpty(DeviceID.ToString()))
                    {
                        TypeList.Add("其它设备");
                        NameList.Add(DeviceName.ToString());
                        IDList.Add(DeviceID.ToString());
                        MfgList.Add(Mfg.ToString());
                        IsInstallDriversList.Add(IsInstallDrivers.ToString());
                    }
                }
            }
            //释放当前设备占用内存
            SetupDiDestroyDeviceInfoList(hDevInfo);
            return(0);
        }