/// <summary> /// Changes the properties of a device by calling the <see cref="SetupDiSetClassInstallParams"/> and <see cref="SetupDiChangeState"/> functions /// </summary> /// <param name="installFunction">The function to call</param> /// <param name="stateChange">The new state</param> /// <param name="scope">Scope for the change</param> /// <param name="hardwareProfile">HardwareProfile to use</param> public void ChangeProperty(DIF installFunction, DICS stateChange, DICS_FLAGS scope, uint hardwareProfile) { var p = new SP_PROPCHANGE_PARAMS(); p.ClassInstallHeader.cbSize = (uint)Marshal.SizeOf(p.ClassInstallHeader); p.ClassInstallHeader.InstallFunction = installFunction; p.StateChange = stateChange; p.Scope = scope; p.HwProfile = hardwareProfile; var deviceInfo = this.deviceInfo; { //Set parameters if (!SetupDiSetClassInstallParams(Handle, ref deviceInfo, ref p, (uint)Marshal.SizeOf(p))) { throw new Win32ErrorException(); } KERNEL32.CheckLastError(); } { //Run change if (!SetupDiChangeState(Handle, ref deviceInfo)) { throw new Win32ErrorException(); } KERNEL32.CheckLastError(); } //if (!SetupDiCallClassInstaller(installFunction, m_Handle, ref deviceInfo)) }
public void dif(List <TXF.K_data.K> mk) { while (mk.Count > DIF.Count) { DIF.Add(new float()); DEM.Chart_EMA.Add(new float()); if (DIF.Count < EMA2.ema_count + DEM.ema_count + 2) { if (DEM.Chart_EMA.Count > 2) { DIF[DIF.Count - 3] = 0; DEM.Chart_EMA[DEM.Chart_EMA.Count - 3] = 0; } } } //int i; //for (i = 25; i < DIF.Count; i++) { // DIF[i] = EMA1.SMA_[i] - EMA2.SMA_[i]; //} if (EMA1.Chart_EMA.Count > 0 && EMA2.Chart_EMA.Count > 0) { DIF[DIF.Count - 1] = EMA1.Chart_EMA[EMA1.Chart_EMA.Count - 1] - EMA2.Chart_EMA[EMA2.Chart_EMA.Count - 1]; highest = Math.Max(highest, DIF[DIF.Count - 1]); lowest = Math.Min(lowest, DIF[DIF.Count - 1]); } //if (mk.Count == EMA2.ema_count + DEM.ema_count + 2) { // int n = 34; // while(n-- > 0) { // DIF.Remove(DIF[0]); // DEM.Chart_EMA.Remove(DEM.Chart_EMA[0]); // times = new float[times.Length - 1]; // int i; // for (i = 0; i < times.Length; i++) // times[i] = i + (300 - times.Length) + 1; // } //} }
public static extern bool SetupDiCallClassInstaller(DIF installFunction, Handle deviceInfoSet, [In] ref SP_DEVINFO_DATA deviceInfoData);
public static extern Boolean SetupDiCallClassInstaller(DIF InstallFunction, IntPtr DeviceInfoSet, IntPtr DeviceInfoData);
public static extern bool SetupDiCallClassInstaller( DIF InstallFunction, SafeDeviceInfoSetHandle DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData);
public Item(BinaryReader source) { int dataLength; { // Parse DIF DIF dif; do { dif = new DIF(source.ReadByte()); } while ((dif.DataType == DataTypes._Special_Functions) && (dif.Function == Functions.Minimum) && (!dif.StorageLSB) && (!dif.Extension)); DataType = dif.DataType; Function = dif.Function; StorageNumber = dif.StorageLSB ? 1UL : 0UL; dataLength = dif.Length; Tariff = 0; SubUnit = 0; int n = 0; bool Extension = dif.Extension; while (Extension) { // Parse DIFE if (n > 10) { throw new InvalidDataException(); } DIFE dife = new DIFE(source.ReadByte()); UInt64 snPart = (UInt64)dife.StorageNumber; snPart <<= (n * 4 + 1); StorageNumber |= snPart; UInt32 tPart = (UInt32)dife.Tariff; tPart <<= (n * 2); Tariff |= tPart; UInt16 suPart = (UInt16)dife.Device; suPart <<= n; SubUnit |= suPart; Extension = dife.Extension; n++; } } { // Parse VIF VIF vif = new VIF(source); List <UnitData> unitsList = new List <UnitData>(); if ((vif.VIFType != VIF.VIFTypes.LinearVIFExtensionFD) && (vif.VIFType != VIF.VIFTypes.LinearVIFExtensionFB)) { unitsList.Add(new UnitData(vif.Units, vif.Magnitude, vif.VIF_string)); } bool Extension = vif.Extension; int n = 0; while (Extension) { // Parse VIFE if (n > 10) { throw new InvalidDataException(); } switch (vif.VIFType) { case VIF.VIFTypes.LinearVIFExtensionFB: { VIFE_FB vife = new VIFE_FB(source.ReadByte()); Extension = vife.Extension; unitsList.Add(new UnitData(vife.Units, vife.Magnitude)); } break; case VIF.VIFTypes.LinearVIFExtensionFD: { VIFE_FD vife = new VIFE_FD(source.ReadByte()); Extension = vife.Extension; unitsList.Add(new UnitData(vife.Units, vife.Magnitude)); } break; default: { VIFE vife = new VIFE(source.ReadByte()); Extension = vife.Extension; unitsList.Add(new UnitData(vife.Units, vife.Magnitude)); } break; } n++; } Units = unitsList.ToArray(); } { // Parse Data byte[] buf = (dataLength > 0) ? source.ReadBytes(dataLength) : null; switch (DataType) { case DataTypes._No_data: Value = null; break; case DataTypes._8_Bit_Integer: System.Diagnostics.Debug.Assert(buf.Length == 1); Value = buf.Single(); break; case DataTypes._16_Bit_Integer: System.Diagnostics.Debug.Assert(buf.Length == 2); Value = BitConverter.ToInt16(buf, 0); break; case DataTypes._24_Bit_Integer: System.Diagnostics.Debug.Assert(buf.Length == 3); Value = BitConverter.ToInt32(new byte[] { 0 }.Concat(buf).ToArray(), 0); break; case DataTypes._32_Bit_Integer: System.Diagnostics.Debug.Assert(buf.Length == 4); Value = BitConverter.ToInt32(buf, 0); break; case DataTypes._32_Bit_Real: System.Diagnostics.Debug.Assert(buf.Length == 4); Value = BitConverter.ToSingle(buf, 0); break; case DataTypes._48_Bit_Integer: System.Diagnostics.Debug.Assert(buf.Length == 6); Value = BitConverter.ToInt64(new byte[] { 0, 0 }.Concat(buf).ToArray(), 0); break; case DataTypes._64_Bit_Integer: System.Diagnostics.Debug.Assert(buf.Length == 8); Value = BitConverter.ToInt64(buf, 0); break; case DataTypes._Selection_for_Readout: throw new NotImplementedException(); /// !!! case DataTypes._2_digit_BCD: System.Diagnostics.Debug.Assert(buf.Length == 1); Value = sbyte.Parse(buf.BCDToString()); break; case DataTypes._4_digit_BCD: System.Diagnostics.Debug.Assert(buf.Length == 2); Value = Int16.Parse(buf.BCDToString()); break; case DataTypes._6_digit_BCD: System.Diagnostics.Debug.Assert(buf.Length == 3); Value = Int32.Parse(buf.BCDToString()); break; case DataTypes._8_digit_BCD: System.Diagnostics.Debug.Assert(buf.Length == 4); Value = Int32.Parse(buf.BCDToString()); break; case DataTypes._variable_length: System.Diagnostics.Debug.Assert(buf == null); Value = VariableLengthData.ReadValue(source); break; case DataTypes._12_digit_BCD: System.Diagnostics.Debug.Assert(buf.Length == 6); Value = Int64.Parse(buf.BCDToString()); break; case DataTypes._Special_Functions: throw new NotImplementedException(); /// !!! break; } } }