public OPOSLineDisplayServer(string deviceName) { PosExplorer myPosExplorer = new PosExplorer(); DeviceCollection myDevices = myPosExplorer.GetDevices(DeviceType.LineDisplay); foreach (DeviceInfo devInfo in myDevices) { if (devInfo.ServiceObjectName == deviceName) { _lineDisplay = myPosExplorer.CreateInstance(devInfo) as LineDisplay; //open _lineDisplay.Open(); //claim the printer for use _lineDisplay.Claim(CLAIM_TIMEOUT_MS); //make sure it is enabled _lineDisplay.DeviceEnabled = true; } } if (_lineDisplay == null) { throw new Exception("No Customer Display Available!"); } }
public OPOSCashDrawerServer(string deviceName) { PosExplorer myPosExplorer = new PosExplorer(); DeviceCollection myDevices = myPosExplorer.GetDevices(DeviceType.CashDrawer); try { foreach (DeviceInfo devInfo in myDevices) { if (devInfo.ServiceObjectName == deviceName) { _cashDrawer = myPosExplorer.CreateInstance(devInfo) as CashDrawer; //open _cashDrawer.Open(); //claim the printer for use _cashDrawer.Claim(CLAIM_TIMEOUT_MS); //make sure it is enabled _cashDrawer.DeviceEnabled = true; } } if (_cashDrawer == null) { throw new Exception("No Cash Drawer Available!"); } } catch (Exception ex) { throw new Exception("No Cash Drawer Available!"); } }
void LoadBarcodes() { try { _posexplorer = new PosExplorer(); _barcodescannerList = _posexplorer.GetDevices(DeviceType.Scanner); IEnumerable <PosDeviceInfo> posdevinfo = PosDeviceInfo.CreatePosDeviceInfoCollection(_barcodescannerList); foreach (PosDeviceInfo item in posdevinfo) { if (this.InvokeRequired) { this.Invoke(new Action(() => lbBarcodeDevs.Items.Add(item))); } } } catch (PosControlException ex) { _logger.LogError(ex, "The application received an error ", "frmHardwaresetup", "ActivateScanner"); Helper.ShowMessage("The application received an error \n" + ex.Message, "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { _logger.LogError(ex, "The application received an error ", "frmHardwaresetup", "ActivateScanner"); Helper.ShowMessage("The application received an error \n" + ex.Message, "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async void testSaveToFile() { tokenSource = new CancellationTokenSource(); //Assert.DoesNotThrow(() => //{ //coll = await engine.BuildVolumesAsync(); devColl = await engine.BuildDevicesAsync(tokenSource.Token).ConfigureAwait(false);; //}); //string fileName = System.IO.Path.GetTempFileName(); string fileName = @"C:\Projects\Software\Tools\ReadRawDevice.Gui\ReadRawDevice.NUnit\bin\Debug\diskOutput.bin"; var device = devColl.Where(dev => { return((dev.DiskSize.HasValue) && (dev.FriendlyName.Equals("Alex EFI_TEST USB Device"))); }).First(); var progressIndicator = new Progress <double>(progress => { System.Diagnostics.Debug.WriteLine("Progress is: " + progress.ToString() + "%"); }); System.Diagnostics.Trace.WriteLine("Output file is: " + fileName); long bytesRead = await engine.ExtractDiskAsync(device, fileName, progressIndicator, tokenSource.Token); //tsk2.Wait(); System.Diagnostics.Debug.WriteLine("--- All done ---"); //engine.ExtractDiskAsync( }
public DeviceMethodCaller(DeviceCollection devices, Device device, MethodInfo method) { m_devices = devices; m_device = device; m_method = method; m_args = new object[1]; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Query() { // TODO: 2011-05-27 page_load 之前不能调用 IsValid // //if (IsValid) DateTime begin = UCConditionDTTwo1.Begin; DateTime end = UCConditionDTTwo1.End; //int[] deviceIDs = UCConditionDTTwo1.GetQueryDeviceIDs(); DeviceCollection dc = UCConditionDTTwo1.Stations.GetDeviceCollection(); int[] deviceIDs = dc.GetDeviceIDs(); if (deviceIDs.Length == 0) { // TODO: 2011-05-16 not select station msg // return; } DataTable tbl = DitchDataDBI.GetData(begin, end, deviceIDs); _h.Bind(); //DataTable tbl = GetDataTable(begin, end, deviceIDs[0]); //ColumnNameTextCollection nts = GetColumnNameTextCollection(); //GridViewHelper.SetGridViewColumn(this.GridView1, nts); //this.GridView1.DataSource = tbl; //this.DataBind(); this.UCZedChart1.GraphPaneConfig = this.GetGraphPaneConfig(); this.UCZedChart1.DataSource = tbl; }
private PosPrinter FindPrinter(string objectName) { PosExplorer myPosExplorer = new PosExplorer(); DeviceCollection myDevices = myPosExplorer.GetDevices(DeviceType.PosPrinter, DeviceCompatibilities.Opos); //find the printer by expected service object name foreach (DeviceInfo devInfo in myDevices) { if (devInfo.ServiceObjectName == objectName) { try { var p = myPosExplorer.CreateInstance(devInfo) as PosPrinter; //open p.Open(); //claim the printer for use p.Claim(CLAIM_TIMEOUT_MS); //make sure it is enabled p.DeviceEnabled = true; return(p); } catch (Exception) { // Eating exception for other printers may be connected } } } return(null); }
private static void InitializeBumpBar() { DeviceCollection bumpBarList = BumpBarDeviceCollection; if (bumpBarList.Count > 0) { try { DeviceInfo bumpBar = GetActiveDeviceInfo(bumpBarList, "BumpBarName", true); if (bumpBar != null) { activeBumpBar = (BumpBar)explorer.CreateInstance(bumpBar); activeBumpBar.Open(); activeBumpBar.Claim(1000); activeBumpBar.DeviceEnabled = true; } } catch (PosControlException) { // Log error and set the active to nil activeBumpBar = null; Logger.Error("InitializePosDevices", Strings.InitializationException); } } }
/// <summary> /// /// </summary> /// <param name="_soft"></param> /// <param name="node"></param> private void BuildStationCollection(CommuniSoft soft, XmlNode stationsNode) { if (soft == null) { throw new ArgumentNullException("soft"); } if (stationsNode == null) { throw new ArgumentNullException("stationsNode"); } foreach (XmlNode stationNode in stationsNode) { XmlNode stationNameNode = stationNode.SelectSingleNode(HardwareNodeNames.StationName); Debug.Assert(stationNameNode != null, "station name node == null"); string name = stationNameNode.InnerText; XmlNode communitypeNode = stationNode.SelectSingleNode(HardwareNodeNames.CommuniType); Debug.Assert(communitypeNode != null, "communitype node == null"); CommuniType communiType = BuildCommuniType(communitypeNode); DeviceCollection devices = null; XmlNode devicesNode = stationNode.SelectSingleNode(HardwareNodeNames.DeviceCollection); if (devicesNode != null) { devices = BuildDeviceCollection(devicesNode); } Station st = new Station(name, communiType); st.Devices = devices; soft.HardwareManager.Stations.Add(st); } }
public void RefreshDevicesList() { DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices"); lvDevices.Items.Clear(); foreach (Device device in deviceCollection.Devices) { ListViewItem item = new ListViewItem(); item.Text = device.Name; item.Name = device.Identifier; CompatibleDevice connectedDevice = supportedDevicesManager.GetConnectedDevice(device.Identifier); if (connectedDevice == null) { item.SubItems.Add(Resources.StrDeviceStatusOffline); } else { item.SubItems.Add(Resources.StrDeviceStatusOnline); } item.SubItems.Add("Unknown"); item.SubItems.Add("Never"); lvDevices.Items.Add(item); } lvDevices.Invalidate(); }
private void AddNewDeviceFromWizardDataStore(Wizard wizard) { CompatibleDevice device = (CompatibleDevice)wizard.DataStore[WizardDataStoreKeys.DEVICE]; String name = (String)wizard.DataStore[WizardDataStoreKeys.NAME]; bool openDevicePanel = (bool)wizard.DataStore[WizardDataStoreKeys.OPEN_PLAYLIST_PANEL]; DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices"); if (deviceCollection.GetDeviceWithIdentifier(device.Identifier) != null) { MessageBox.Show(this, "The device you are adding has already been added. You can only " + "add a device once.\n\nIf you want several playlists synchronized to the same " + "device, use the Playlists view to assign more playlists to your device.", "Device already added", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Device newDevice = new Device(); newDevice.Identifier = device.Identifier; newDevice.Name = name; deviceCollection.Devices.Add(newDevice); FlushDeviceConfigurationToFile(); RefreshDevicesList(); if (openDevicePanel) { mainForm.SwithcToMyDevicesPanel(); } }
public RawDevicesManager(InputProvider inputProvider) { virtualScreen = SystemInformation.VirtualScreen; this.inputProvider = inputProvider; mouseSpeed = SystemInformation.MouseSpeed * 0.15; devices = new DeviceCollection(); contacts = new ContactCollection(); IEnumerable<RawDevice> rawDevices = from device in RawDevice.GetRawDevices() where (device.RawType == RawType.Device && device.GetRawInfo().UsagePage == HID_USAGE_PAGE_DIGITIZER && device.GetRawInfo().Usage == HID_USAGE_DIGITIZER_PEN) || device.RawType == RawType.Mouse select device; foreach (RawDevice mouseDevice in rawDevices) devices.Add(new DeviceStatus(mouseDevice)); Thread inputThread = new Thread(InputWorker); inputThread.IsBackground = true; inputThread.SetApartmentState(ApartmentState.STA); inputThread.Name = "MultipleMice thread"; inputThread.Start(); this.inputProvider.IsRunning = true; }
//#region GetFirstSideValues ///// <summary> ///// ///// </summary> ///// <param name="xd100eDevice"></param> ///// <param name="if1"></param> ///// <param name="sf1"></param> ///// <returns></returns> //private bool GetFirstSideValues(Xd100e xd100eDevice, out double if1, out double sf1) //{ // bool hasSide1FluxProvider = false; // bool r = false; // if1 = 0d; // sf1 = 0d; // IStation st = xd100eDevice.Station; // foreach (IDevice d in st.Devices) // { // if (d is IFluxProvider) // { // IFluxProvider fp = d as IFluxProvider; // if (fp.FluxPlace == FluxPlace.FirstSide) // { // hasSide1FluxProvider = true; // if (fp.FluxDataDT != DateTime.MinValue) // { // if1 = fp.InstantFlux; // sf1 = fp.Sum; // r = true; // } // } // } // } // if (!r && !hasSide1FluxProvider) // { // r = true; // } // return r; //} //#endregion //GetFirstSideValues //#region GetFluxValues ///// <summary> ///// ///// </summary> ///// <param name="xd100e"></param> ///// <param name="ir"></param> ///// <param name="sr"></param> ///// <returns></returns> //private bool GetFluxValues(Xd100e xd100e, FluxPlace fluxPlace, out bool hasFluxProviderDevice, // out double ir, out double sr, out string recuritEx) //{ // hasFluxProviderDevice = false; // ir = 0d; // sr = 0d; // recuritEx = string.Empty; // IStation st = xd100e.Station; // List<IFluxProvider> fluxProviderList = GetFluxProviderList(st, fluxPlace); // if (fluxProviderList.Count == 0) // { // return true; // } // hasFluxProviderDevice = true; // if (!IsFluxDataValid(fluxProviderList)) // { // return false; // } // ir = CalcIR(fluxProviderList); // sr = CalcSR(fluxProviderList); // //recuritEx = GetRecuritEx(fluxProviderList); // return true; //} //#endregion //GetFluxValues #region GetRecuritEx /// <summary> /// /// </summary> /// <param name="fluxProviderList"></param> /// <remarks> /// recurit ex message: /// 1. DT /// 2. Device.Name /// 3. IR /// 4. SR /// </remarks> /// <returns></returns> //private string GetRecuritEx(List<IFluxProvider> fluxProviderList) private string GetRecuritEx(DeviceCollection devices) { //DeviceCollection devices = null; StringBuilder sb = new StringBuilder(); //foreach (IFluxProvider fp in fluxProviderList) foreach (IDevice device in devices) { IData last = device.DeviceDataManager.Last; string s = string.Format( "{0},{1},{2},{3}|", /* * fp.FluxDataDT, * ((IDevice)fp).Name, * fp.InstantFlux, * fp.Sum */ last.GetValue("DT"), device.Name, last.GetValue("InstantFlux"), last.GetValue("Sum") ); sb.Append(s); } // remove last '|' char // if (sb.Length > 0) { sb.Remove(sb.Length - 1, 1); } return(sb.ToString()); }
private static void InitializeScanners() { DeviceCollection scannerList = ScannerDeviceCollection; if (scannerList.Count > 0) { try { DeviceInfo scanner = GetActiveDeviceInfo(scannerList, "ScannerName", true); if (scanner != null) { activeScanner = (Scanner)explorer.CreateInstance(scanner); activeScanner.Open(); activeScanner.Claim(1000); activeScanner.DeviceEnabled = true; activeScanner.DecodeData = true; activeScanner.DataEventEnabled = true; } } catch (PosControlException) { // Log error and set the active to nil activeScanner = null; Logger.Error("InitializePosDevices", Strings.InitializationException); } } }
public void PlaylistsPanel_Load(object sender, EventArgs e) { flowPlaylistAssociations.Visible = false; DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices"); List <Playlist> playlists = mediaSoftwareService.GetPlaylists(); foreach (Playlist playlist in playlists) { PlaylistAssociationControl playlistAssociationControl = new PlaylistAssociationControl(); playlistAssociationControl.PlaylistName = playlist.Name; playlistAssociationControl.PlaylistNameToolTip = playlistAssociationControl.PlaylistName; playlistAssociationControl.PlaylistID = playlist.ID; UpdateAssociationCountForControl(playlistAssociationControl, deviceCollection); playlistAssociationControl.AddAssociationButton.Click += new EventHandler(AddAssociationButton_Click); playlistAssociationControl.EditAssociationsButton.Click += new EventHandler(EditAssociationsButton_Click); playlistAssociationControl.PlaylistNameLabel.Click += new EventHandler(EditAssociationsButton_Click); flowPlaylistAssociations.Controls.Add(playlistAssociationControl); } flowPlaylistAssociations.Visible = true; }
private void SetUpPrinter() { string strLogicalName = "PosPrinter"; try { PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; myDevices = posExplorer.GetDevices(DeviceType.PosPrinter); try { deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName); m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo); } catch (Exception) { } m_Printer.Open(); } catch (PosControlException) { Console.WriteLine("Failed to load printer: " + strLogicalName); } }
public static Boolean DeleteAMessageImpl(long messageId, int organizationId) { // Make sure customer owns the message, thus preventing customers from possibly // deleting other customers messages. OrganizationEntity organization = new OrganizationEntity(organizationId); foreach (LocationEntity location in organization.Locations) { DeviceCollection devices = new DeviceCollection(); devices.GetMulti(new PredicateExpression(DeviceFields.LocationId == location.LocationId)); foreach (DeviceEntity device in devices) { DeviceMessageCollection deviceMessages = new DeviceMessageCollection(); PredicateExpression filter = new PredicateExpression { DeviceMessageFields.DeviceId == device.DeviceId, DeviceMessageFields.MessageId == messageId }; deviceMessages.GetMulti(filter); if (deviceMessages.Count > 0) { DeviceMessageEntity deviceMessage = deviceMessages[0]; deviceMessage.DeliveryTime = DateTime.UtcNow; deviceMessage.Save(); return(true); } } } return(false); }
/// <summary> /// /// </summary> public void Do() { // devices // DeviceCollection devices = DeviceFactory.CreateDeviceCollection(); // foreach device // foreach (DeviceClass d in devices) { DateTime dtlast = d.GetLastDateTimeForm10MinuteDataTable(); DateTime begin = dtlast.Date + TimeSpan.FromDays(1d); DateTime end = DateTime.Now.Date; for (DateTime temp = begin; temp < end; temp += TimeSpan.FromDays(1d)) { DataTable source = d.GetDitchData(temp, temp + TimeSpan.FromDays(1d)); DataTable dest = Create10MinuteDataTable(source); if (dest != null && dest.Rows.Count > 0) { d.Write10MinuteDataTable(dest); } } } // device last zb data dt // }
private static void InitializeCashDrawer2() { DeviceCollection cashDrawerList = CashDrawerDeviceCollection; if (cashDrawerList.Count > 0) { try { DeviceInfo cashDrawer = GetActiveDeviceInfo(cashDrawerList, "CashDrawerName2", true); if (cashDrawer != null) { activeCashDrawer2 = (CashDrawer)explorer.CreateInstance(cashDrawer); activeCashDrawer2.Open(); activeCashDrawer2.Claim(1000); activeCashDrawer2.DeviceEnabled = true; } } catch (PosControlException) { // Log error and set the active to nil activeCashDrawer2 = null; Logger.Error("InitializePosDevices", Strings.InitializationException); } } }
private static PosPrinter InitializePosPrinter(string configSettingName) { PosPrinter result = null; DeviceCollection printerList = PosPrinterDeviceCollection; if (printerList.Count > 0) { try { #if DEBUG //DeviceInfo printer = GetActiveDeviceInfo(printerList, configSettingName, true); DeviceInfo printer = printerList[0]; #else DeviceInfo printer = GetActiveDeviceInfo(printerList, configSettingName); #endif if (printer != null) { result = (PosPrinter)explorer.CreateInstance(printer); result.Open(); result.Claim(1000); result.DeviceEnabled = true; } } catch (PosControlException) { // Log error and set the active to nil Logger.Error("InitializePosDevices", Strings.InitializationException); } } return(result); }
private double GetBT1FromCRL_G(Xd100e xd100eDevice) { double r = 0d; /* * foreach (IDevice device in xd100eDevice.Station.Devices) * { * if (device is IBT1Provider) * { * IBT1Provider bt1Pro = device as IBT1Provider; * if (bt1Pro.BT1DataDT != DateTime.MinValue) * { * r = bt1Pro.BT1; * } * } * } */ // 1. get heat kind device collection // 2. get device collection with place != unknown // 3. if device count > 1, select first device // 4. get device.bt1 DeviceCollection heatDevices = xd100eDevice.Station.Devices.GetDevices(KIND); RemoveUnknownPlaceDevice(heatDevices); bool hasData = heatDevices.HasData(HasDataOption.All); if (hasData) { r = Calc(heatDevices, "BT", CalcType.Avg); } return(r); }
private static void LoadStoredDevices(ModelRepository repo) { // If there are no current stored devices config, simply add a new DeviceCollection. if (!File.Exists(DEVICES_CONFIG_PATH)) { repo["devices"] = new DeviceCollection(); return; } Stream read; try { read = new FileStream(DEVICES_CONFIG_PATH, FileMode.Open); } catch (Exception ex) { throw new IOException("Unable to load stored devices configuration.", ex); } try { repo.Deserialize("devices", typeof(iTunesAgent.Domain.DeviceCollection), read); } finally { if (read != null) { read.Close(); } } }
public static bool LoadFromFile(string fileName, DeviceCollection devices) { if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } if (devices == null) { throw new ArgumentNullException(nameof(devices)); } // Read data only once string xml = File.ReadAllText(fileName); // Try JuisCheck2 file format try { JC2Data.LoadFromString(xml, devices); return(false); } catch (InvalidOperationException) { } // Try JuisCheck1 file format JC1Data.LoadFromString(xml, devices); return(true); }
public override bool Init() { if (!base.Init()) { return(false); } _Sources = new List <CSoundCardSource>(); DeviceCollection devices = DirectSoundCapture.GetDevices(); foreach (DeviceInformation dev in devices) { using (var ds = new DirectSoundCapture(dev.DriverGuid)) { var device = new CRecordDevice(_Devices.Count, dev.DriverGuid.ToString(), dev.Description, ds.Capabilities.Channels); _Devices.Add(device); } } _Initialized = true; return(true); }
public MainWindowViewModel() { ConnectedState = DeviceConncectState.NoDevice; MainDockPanelVM = new PerformanceViewModel(); _logDataReceived += ((PerformanceViewModel)MainDockPanelVM).OnLogDataReceived; _adbLogDataReceived += ((PerformanceViewModel)MainDockPanelVM).OnADBLogDataReceived; Devices = new DeviceCollection(); }
public void AddSameAddress() { DeviceTest d1 = new DeviceTest(DeviceTest2.DD,"dt"); DeviceTest2 d2 = new DeviceTest2("dt2"); DeviceCollection ds = new DeviceCollection(); ds.Add(d1); ds.Add(d2); }
public DeviceController( ILogger <DeviceController> logger, IStringLocalizer <DeviceController> localizer, DeviceCollection devices, IMapper mapper) : base(logger, localizer) { _devices = devices; _mapper = mapper; }
private void NewPlaylistAssociationForm_Load(object sender, EventArgs e) { DeviceCollection devices = model.Get <DeviceCollection>("devices"); foreach (Device device in devices.Devices) { cbDeviceSelector.Items.Add(device); } }
public DeviceController( ILogger <DeviceController> logger, DeviceCollection deviceService, IMapper mapper) { _logger = logger; _devices = deviceService; _mapper = mapper; }
public void EnumDevicesTest() { using var coll = new DeviceCollection(GUID_DEVCLASS_DISKDRIVE); //, null, null, DIGCF.DIGCF_ALLCLASSES); var devs = coll.ToArray(); Assert.That(devs, Is.Not.Empty); TestContext.WriteLine($"Found {devs.Length} devices."); TestContext.Write(string.Join("\r\n", devs.Select(c => c.Name).OrderBy(s => s))); }
/// <summary> /// /// </summary> /// <param name="stationName"></param> /// <param name="description"></param> public Station(string stationName, string description, DeviceCollection deviceCollection, CommuniType communiType) : this(stationName, communiType) { if (deviceCollection == null) throw new ArgumentNullException("deviceCollection"); m_DeviceCollection = deviceCollection; m_DeviceCollection.Station = this; m_CommuniType = communiType; }
/// <summary> /// Returns an enumerator that iterates through the device collection. /// </summary> /// /// <returns> /// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that /// can be used to iterate through the collection. /// </returns> /// public IEnumerator <AudioDeviceInfo> GetEnumerator() { DeviceCollection devices = (Category == AudioDeviceCategory.Capture) ? DirectSoundCapture.GetDevices() : DirectSound.GetDevices(); foreach (DeviceInformation info in devices) { yield return(new AudioDeviceInfo(info)); } }
/// <summary> /// /// </summary> /// <returns></returns> public static DeviceCollection CreateDeviceCollection() { DeviceCollection dc = new DeviceCollection(); DataTable tbl = DeviceDBI.GetDeviceDataView(); foreach (DataRow row in tbl.Rows) { DeviceClass c = CreateDevice(row); dc.Add(c); } return dc; }
void UpdateAssociatedPlaylists(int playlistID) { DeviceCollection deviceCollection = model.Get <DeviceCollection>("devices"); var devicesAssociatedWithPlaylist = from d in deviceCollection.Devices where (from p in d.Playlists where p.PlaylistID == playlistID select p).Count() > 0 select d; listAssociatedDevices.Items.Clear(); foreach (Device device in devicesAssociatedWithPlaylist) { listAssociatedDevices.Items.Add(device); } }
public void enumerateDevicesShouldNotThrow() { tokenSource = new CancellationTokenSource(); Assert.DoesNotThrow(() => { var tsk = engine.BuildDevicesAsync(tokenSource.Token); tsk.Wait(); devColl = tsk.Result; }); }
/// <summary> /// 构造函数。 /// </summary> public LogInViewModel() { //在这里控制Core中类的构造顺序 _deviceCollection=new DeviceCollection(); _deviceLogIn = new DeviceLogIn(_deviceCollection); _deviceConfigManager=new DeviceConfigManager(); //todo 用于测试,要删除。 Devices.Add(new DeviceInfo { Type = LogInType.DSP}); Devices.Add(new DeviceInfo { Type = LogInType.DSP, Status = LogInStatus.Status1 }); Devices.Add(new DeviceInfo { Type = LogInType.DSP,Status = LogInStatus.Status2}); }
public void DeleteByIdentifier_shouldDeleteDeviceWithMatchingIdentifier() { DeviceCollection collection = new DeviceCollection(); Device testDevice = new Device(); testDevice.Identifier = "usb:54321"; testDevice.Name = "Test device"; collection.Devices.Add(testDevice); collection.DeleteByIdentifier("usb:54321"); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:54321")); }
public void GetDeviceByIdentifier_shouldReturnDeviceWithMatchingIdentifier() { DeviceCollection collection = new DeviceCollection(); Device testDevice = new Device(); testDevice.Identifier = "usb:54321"; testDevice.Name = "Test device"; collection.Devices.Add(testDevice); Assert.AreEqual(testDevice, collection.GetDeviceWithIdentifier("usb:54321")); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:12345")); }
/// <summary> /// /// </summary> /// <param name="stationID"></param> /// <returns></returns> public static DeviceCollection CreateDeviceCollectionByStationID(int stationID) { DeviceCollection dc = new DeviceCollection(); //int[] devicdIDs = DeviceDBI.GetDeviceIDsByStationID(stationID); //string s = SqlHelper.MakeInQueryCondition(devicdIDs); DataTable tbl = DeviceDBI.GetDeviceDataTableByStationID(stationID); foreach (DataRow row in tbl.Rows) { DeviceClass d = CreateDevice(row); dc.Add(d); } return dc; }
public void GetDeviceByIdentifier_shouldReturnNullWhenNoDeviceWithProvidedIdentifier() { DeviceCollection collection = new DeviceCollection(); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:12345")); Device testDevice = new Device(); testDevice.Identifier = "usb:54321"; testDevice.Name = "Test device"; collection.Devices.Add(testDevice); Assert.IsNull(collection.GetDeviceWithIdentifier("usb:12345")); }
public MainWindow() { InitializeComponent(); BindingCommands(); BindingContextMenuItems(); DataContext = this; InputList = new ObservableCollection<DataModel>(); OutputList = new ObservableCollection<DataModel>(); DeviceCollection=new DeviceCollection(); _inputDelayTimer=new Stopwatch(); _outputDelayTimer = new Stopwatch(); Loaded += MainWindow_Loaded; //SampleDeviceCollection(); }
public void Add() { DeviceTest d = new DeviceTest(DeviceTest2.DD, "a"); DeviceCollection ds = new DeviceCollection(); Assert.AreEqual(0, ds.Count); ds.Add(d); Assert.AreEqual(1, ds.Count); Assert.AreSame(d.Devices, ds); d.Delete(); Assert.IsNull(d.Devices); Assert.AreEqual(0, ds.Count); }
public void allDevicesShouldHaveDiskSize() { tokenSource = new CancellationTokenSource(); Assert.DoesNotThrow(() => { var tsk = engine.BuildDevicesAsync(tokenSource.Token); tsk.Wait(); devColl = tsk.Result; }); devColl.AsParallel().ForAll(dev => { System.Diagnostics.Trace.WriteLine("Device " + dev.FriendlyName + " size is: " + (dev.DiskSize.HasValue == true ? dev.DiskSize.Value.ToString() : "<empty>")); }); var zz = devColl.Where(dev => !(dev.DiskSize.HasValue && dev.DiskSize.Value >= 0)); Assert.True(zz.Any() == false); }
public ScannerManager() { checkTimer = new System.Windows.Threading.DispatcherTimer(); checkTimer.Interval = new TimeSpan(0, 0, 2); checkTimer.Tick += checkTimer_Tick; explorer = new PosExplorer(); scannerList = explorer.GetDevices(DeviceType.Scanner); try { foreach (DeviceInfo di in scannerList) { if (di.ServiceObjectName == "USBHHScanner") { activeScanner = (Scanner)explorer.CreateInstance(di); break; } } } catch (PosException) { } }
/// <summary> /// /// </summary> /// <param name="fluxDevices"></param> /// <returns> /// hashtable /// key:place - value:list /// place - instantflux , sum /// </returns> private Hashtable GetFluxDatas(DeviceCollection fluxDevices) { Hashtable hs = new Hashtable(); foreach (IDevice d in fluxDevices) { PlaceDeviceBase pd = d as PlaceDeviceBase; List<double> list = GetHashValue(hs, pd.Place); IData last = pd.DeviceDataManager.Last; list[0] += Convert.ToDouble(last.GetValue("InstantFlux")); list[1] += Convert.ToDouble(last.GetValue("Sum")); } return hs; }
/// <summary> /// /// </summary> /// <param name="station"></param> /// <returns></returns> public override DeviceCollection BuildDeviceCollection(Station station) { DeviceCollection devices = new DeviceCollection(); string sql = string.Format( "select * from tblDevice where DeviceDeleted = 0 and StationID = {0}", station.ID ); DataTable deviceTable = DBI.ExecuteDataTable(sql); foreach (DataRow row in deviceTable.Rows) { Device device = BuildDevice(row); if (device != null) { devices.Add(device); } } return devices; }
private void RemoveUnknownPlaceDevice(DeviceCollection devices) { for (int i = devices.Count -1; i >= 0; i--) { IDevice device = devices[i]; if (device is PlaceDeviceBase) { PlaceDeviceBase placeDevice = device as PlaceDeviceBase; if (placeDevice.Place == FluxPlace.Unknown) { devices.Remove(device); } } } }
/// <summary> /// /// </summary> /// <param name="fluxProviderList"></param> /// <remarks> /// recurit ex message: /// 1. DT /// 2. Device.Name /// 3. IR /// 4. SR /// </remarks> /// <returns></returns> //private string GetRecuritEx(List<IFluxProvider> fluxProviderList) private string GetRecuritEx(DeviceCollection devices) { //DeviceCollection devices = null; StringBuilder sb = new StringBuilder(); //foreach (IFluxProvider fp in fluxProviderList) foreach ( IDevice device in devices ) { IData last = device.DeviceDataManager.Last; string s = string.Format( "{0},{1},{2},{3}|", /* fp.FluxDataDT, ((IDevice)fp).Name, fp.InstantFlux, fp.Sum */ last.GetValue("DT"), device.Name, last.GetValue("InstantFlux"), last.GetValue("Sum") ); sb.Append(s); } // remove last '|' char // if (sb.Length > 0) { sb.Remove(sb.Length - 1, 1); } return sb.ToString(); }
private DeviceCollection Filter(DeviceCollection devices, FluxPlace fluxPlace) { DeviceCollection r = new DeviceCollection(); foreach (IDevice device in devices) { PlaceDeviceBase pd = device as PlaceDeviceBase; if (pd.Place == fluxPlace) { r.Add(pd); } } return r; }
private double Calc(DeviceCollection devices, string propertyName, CalcType calcType) { Calculator c = new Calculator(calcType); foreach (IDevice device in devices) { IData last = device.DeviceDataManager.Last; Debug.Assert(last != null); object obj = ReflectionHelper.GetPropertyValue(last, propertyName); double val = Convert.ToDouble(obj); c.Add(val); } return c.Calc(); }
public void TestSerializeDeviceCollection() { DeviceCollection collection = new DeviceCollection(); Device msd = new Device(); msd.Name = "Test1"; msd.Identifier = "file:mydevice.id"; msd.AddPlaylistAssociation(1234, "pattern", "Playlist1"); msd.AddPlaylistAssociation(4567, "pattern", "Playlist2"); collection.Devices.Add(msd); Device wpd = new Device(); wpd.Name = "Test2"; wpd.Identifier = "usb:1234567890"; wpd.AddPlaylistAssociation(4321, "pattern2", "Playlist3"); wpd.AddPlaylistAssociation(7654, "pattern2", "Playlist4"); collection.Devices.Add(wpd); XmlSerializer serializer = new XmlSerializer(collection.GetType()); FileStream fs = null; try { fs = new FileStream("test.xml", FileMode.Create); serializer.Serialize(fs, collection); } finally { if (fs != null) fs.Close(); } FileStream read = null; try { read = new FileStream("test.xml", FileMode.Open); DeviceCollection deserializedCollection = (DeviceCollection)serializer.Deserialize(read); Assert.NotNull(deserializedCollection); Assert.AreEqual(2, deserializedCollection.Devices.Count); Device d1 = deserializedCollection.Devices[0]; Device d2 = deserializedCollection.Devices[1]; Assert.AreEqual("Test1", d1.Name); Assert.AreEqual("file:mydevice.id", d1.Identifier); Assert.AreEqual(2, d1.Playlists.Count); Assert.AreEqual(1234, d1.Playlists[0].PlaylistID); Assert.AreEqual("pattern", d1.Playlists[0].PatternID); Assert.AreEqual("Playlist1", d1.Playlists[0].DeviceFolder); Assert.AreEqual(4567, d1.Playlists[1].PlaylistID); Assert.AreEqual("pattern", d1.Playlists[1].PatternID); Assert.AreEqual("Playlist2", d1.Playlists[1].DeviceFolder); Assert.AreEqual("Test2", d2.Name); Assert.AreEqual("usb:1234567890", d2.Identifier); Assert.AreEqual(2, d2.Playlists.Count); Assert.AreEqual(4321, d2.Playlists[0].PlaylistID); Assert.AreEqual("pattern2", d2.Playlists[0].PatternID); Assert.AreEqual("Playlist3", d2.Playlists[0].DeviceFolder); Assert.AreEqual(7654, d2.Playlists[1].PlaylistID); Assert.AreEqual("pattern2", d2.Playlists[1].PatternID); Assert.AreEqual("Playlist4", d2.Playlists[1].DeviceFolder); } finally { if (read != null) { read.Close(); } } File.Delete("test.xml"); }
/// <summary> /// /// </summary> /// <param name="inOrOutTableName"></param> /// <param name="waterUserId"></param> /// <returns></returns> private static DeviceCollection CreateDeviceCollection(string inOrOutTableName, int waterUserId) { DeviceCollection ds = new DeviceCollection(); string s = string.Format( @"select * from tblDevice where deleted = 0 and deviceid in (select deviceid from {0} where waterUserID = {1})", inOrOutTableName, waterUserId); DataTable tbl = DBI.GetDBI().ExecuteDataTable(s); foreach (DataRow row in tbl.Rows) { DeviceClass d = CreateDevice(row); ds.Add(d); } return ds; }
/// <summary> /// /// </summary> /// <param name="devices"></param> /// <returns></returns> private DeviceCollection RemoveUnkonwnPlaceDevice(DeviceCollection devices) { DeviceCollection r = new DeviceCollection(); foreach (IDevice d in devices) { if (d is PlaceDeviceBase) { PlaceDeviceBase pd = d as PlaceDeviceBase; if (pd.Place != FluxPlace.Unknown) { r.Add(pd); } } } return r; }
public async void testSaveToFile() { tokenSource = new CancellationTokenSource(); //Assert.DoesNotThrow(() => //{ //coll = await engine.BuildVolumesAsync(); devColl = await engine.BuildDevicesAsync(tokenSource.Token).ConfigureAwait(false); ; //}); //string fileName = System.IO.Path.GetTempFileName(); string fileName = @"C:\Projects\Software\Tools\ReadRawDevice.Gui\ReadRawDevice.NUnit\bin\Debug\diskOutput.bin"; var device = devColl.Where(dev => { return (dev.DiskSize.HasValue) && (dev.FriendlyName.Equals("Alex EFI_TEST USB Device")); }).First(); var progressIndicator = new Progress<double>(progress => { System.Diagnostics.Debug.WriteLine("Progress is: " + progress.ToString() + "%"); }); System.Diagnostics.Trace.WriteLine("Output file is: " + fileName); long bytesRead = await engine.ExtractDiskAsync(device, fileName, progressIndicator, tokenSource.Token); //tsk2.Wait(); System.Diagnostics.Debug.WriteLine("--- All done ---"); //engine.ExtractDiskAsync( }
// Loop through all devices in the tree and make sure they exist in the DeviceCollection. // If not remove them from the tree. private void RemoveDevicesFromTree(DeviceCollection devices) { for (int i = DeviceTree.Nodes.Count - 1; i >= 0; i--) { TreeNode deviceTypeNode = DeviceTree.Nodes[i]; for (int j=deviceTypeNode.Nodes.Count-1; j>=0; j--) { TreeNode deviceNode = deviceTypeNode.Nodes[j]; DeviceInfo d = ((PosDeviceTag)deviceNode.Tag).DeviceInfo; bool IsInCollection = false; foreach (DeviceInfo device in devices) { if (DeviceInfosAreEqual(d, device)) { IsInCollection = true; break; } } if (!IsInCollection) { CloseDevice(deviceNode); deviceNode.Remove(); } } if (deviceTypeNode.Nodes.Count == 0) deviceTypeNode.Remove(); } }
/// <summary> /// /// </summary> /// <param name="deviceCollection"></param> public void RemoveTaskByDeviceCollection(DeviceCollection deviceCollection) { foreach (Device d in deviceCollection) { this.RemoveTaskByDevice(d); } }
// Loop through all devices in the collection and add them to the tree if they don't already exist private void AddDevicesToTree(DeviceCollection devices, bool showAddedDevice) { foreach( DeviceInfo device in devices ) { TreeNode deviceTypeNode = null; foreach (TreeNode t in DeviceTree.Nodes) { if (string.Compare(t.Text, device.Type, true) == 0) { deviceTypeNode = t; break; } } if (deviceTypeNode == null) { // Device type doesn't exist yet so create a node for it deviceTypeNode = new TreeNode(device.Type); deviceTypeNode.Tag = device.Type; DeviceTree.Nodes.Add(deviceTypeNode); } TreeNode deviceNode = null; foreach (TreeNode dt in deviceTypeNode.Nodes) { DeviceInfo d = ((PosDeviceTag) dt.Tag).DeviceInfo; if (DeviceInfosAreEqual(d, device)) { deviceNode = dt; break; } } if (deviceNode == null) { TreeNode DeviceNode = new TreeNode( GetDeviceDisplayName(device) ); DeviceNode.Tag = new PosDeviceTag(device); deviceTypeNode.Nodes.Add(DeviceNode); DeviceNode.EnsureVisible(); if (showAddedDevice) DeviceTree.SelectedNode = DeviceNode; } } }
/// <summary> /// 初始化设备集合 /// </summary> public DeviceLogIn(DeviceCollection deviceCollection) { _deviceCollection = deviceCollection; }
/// <summary> /// /// </summary> /// <param name="devicesNode"></param> /// <returns></returns> private DeviceCollection BuildDeviceCollection(XmlNode devicesNode) { if (devicesNode == null) throw new ArgumentNullException("devicesNode"); DeviceCollection devices = new DeviceCollection(); foreach (XmlNode node in devicesNode.ChildNodes) { if (node.Name == HardwareNodeNames.Device) { Device d = BuildDevice(node); devices.Add(d); } } return devices; }