public DeviceDriver take() { global::System.IntPtr cPtr = yarpPINVOKE.PolyDriver_take(swigCPtr); DeviceDriver ret = (cPtr == global::System.IntPtr.Zero) ? null : new DeviceDriver(cPtr, false); return(ret); }
void Start() { // Buffer allocation _audioData = new NativeArray <float>(4096, Allocator.Persistent); // Clear the UI contents. _deviceList.ClearOptions(); _channelList.ClearOptions(); _statusText.text = ""; // Null device option _deviceList.options.Add(new Dropdown.OptionData() { text = "--" }); // Device list initialization _deviceList.options.AddRange( Enumerable.Range(0, DeviceDriver.DeviceCount). Select(i => DeviceDriver.GetDeviceName(i)). Select(name => new Dropdown.OptionData() { text = name })); _deviceList.RefreshShownValue(); }
private void SendProjCmd(MonitorConfig mc, ProjectorCommand pc) { try { //send the command if (mc.m_displayconnectionenabled == false) { DebugLogger.Instance().LogWarning("Display connection not enabled"); return; } //Find the driver DeviceDriver driver = UVDLPApp.Instance().m_deviceinterface.FindProjDriverByComName(mc.m_displayconnection.comname); if (driver == null) { DebugLogger.Instance().LogError("Driver not found"); return; } if (driver.Connected == true) { //send the command. driver.Write(pc.GetBytes(), pc.GetBytes().Length); } else { DebugLogger.Instance().LogError("Driver not connected"); return; } } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } }
public override DeviceDriver getImplementation() { global::System.IntPtr cPtr = yarpPINVOKE.PolyDriver_getImplementation(swigCPtr); DeviceDriver ret = (cPtr == global::System.IntPtr.Zero) ? null : new DeviceDriver(cPtr, false); return(ret); }
public virtual DeviceDriver create() { global::System.IntPtr cPtr = yarpPINVOKE.DriverCreator_create(swigCPtr); DeviceDriver ret = (cPtr == global::System.IntPtr.Zero) ? null : new DeviceDriver(cPtr, false); return(ret); }
public void DriverDeviceStatusEvent(DeviceDriver device, eDeviceStatus status) { switch (status) { case eDeviceStatus.eError: if (StatusEvent != null) { StatusEvent(ePIStatus.eError, "I/O Error"); } break; case eDeviceStatus.eConnect: if (StatusEvent != null) { StatusEvent(ePIStatus.eConnected, "Connected"); } break; case eDeviceStatus.eDisconnect: if (StatusEvent != null) { StatusEvent(ePIStatus.eDisconnected, "Disconnected"); } break; } }
/* * Adds a new projector driver serial port */ public void AddDriver(DeviceDriver d) { m_lstprojectors.Add(d); //add some events here.. d.DataReceived += new DeviceDriver.DataReceivedEvent(DriverDataReceivedEvent); d.DeviceStatus += new DeviceDriver.DeviceStatusEvent(DriverDeviceStatusEvent); }
private void InstrumentProcedure(InstrumentationRegion region) { foreach (var ls in this.AC.CurrentLocksets) { if (this.ShouldSkipLockset(ls)) { continue; } region.Procedure().Modifies.Add(new IdentifierExpr(ls.Id.tok, ls.Id)); } List <Variable> vars = SharedStateAnalyser.GetMemoryRegions(DeviceDriver.GetEntryPoint(this.EP.Name)); foreach (var ls in this.AC.MemoryLocksets) { if (!vars.Any(val => val.Name.Equals(ls.TargetName))) { continue; } if (this.ShouldSkipLockset(ls)) { continue; } region.Procedure().Modifies.Add(new IdentifierExpr(ls.Id.tok, ls.Id)); } }
// Add new camera to the collection and run it public bool Add(CameraPlay camwin, DeviceInfo deviceInfo, CameraInfo camera) { // create video source IVideoSource videoSource = DeviceBusiness.Instance.CreateVideoSource(deviceInfo.ProviderName); if (videoSource == null) { return(false); } DeviceDriver device = new DeviceDriver(videoSource); if (!RunningDeviceList.ContainsKey(deviceInfo.DeviceId)) { deviceInfo.ServiceID = -1; device.Init(ref deviceInfo); RunningDeviceList.Add(deviceInfo.DeviceId, deviceInfo); RunningDriverList.Add(camera.CameraId, device); } else { deviceInfo = RunningDeviceList[deviceInfo.DeviceId]; device.Init(ref deviceInfo); RunningDriverList.Add(camera.CameraId, device); } device.Start(ref camera); camwin.Camera = device; return(true); }
public DeviceDriver open(string device) { global::System.IntPtr cPtr = yarpPINVOKE.Drivers_open__SWIG_0(swigCPtr, device); DeviceDriver ret = (cPtr == global::System.IntPtr.Zero) ? null : new DeviceDriver(cPtr, false); return(ret); }
public DeviceInterface() { m_timeoutms = DEF_TIMEOUT; m_timeouttimer = new Timer(); m_timeouttimer.Elapsed += new ElapsedEventHandler(m_timeouttimer_Elapsed); m_timeouttimer.Interval = m_timeoutms; m_driver = null; }
public DeviceInterface() { m_projector = null; m_driver = null; m_ready = true; m_databufA = null; // new byte[BUFF_SIZE]; m_databufB = null; // new byte[BUFF_SIZE]; }
static void Main(string[] args) { IServer server = new ServerManager().CreateServer(new ServerConfig() { ServerName = "服务1", ComReadTimeout = 1000, ComWriteTimeout = 1000, NetReceiveTimeout = 1000, NetSendTimeout = 1000, ControlMode = ControlMode.Parallel, SocketMode = SocketMode.Tcp, ReceiveDataFliter = false, ClearSocketSession = false, CheckPackageLength = false, CheckSameSocketSession = false, DeliveryMode = DeliveryMode.DeviceIP, ParallelInterval = 1000 }); server.SocketConnected += server_SocketConnected; server.SocketClosed += server_SocketClosed; server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.Start(); string devCode = "0"; DeviceDriver dev1 = new DeviceDriver(); dev1.DeviceParameter.DeviceName = "设备驱动" + devCode.ToString(); dev1.DeviceParameter.DeviceAddr = int.Parse(devCode); dev1.DeviceParameter.DeviceCode = devCode.ToString(); dev1.DeviceParameter.DeviceID = devCode.ToString(); dev1.DeviceDynamic.DeviceID = devCode.ToString(); dev1.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev1.DeviceParameter.NET.RemotePort = 9600; dev1.CommunicateType = CommunicateType.NET; dev1.Initialize(devCode.ToString()); server.AddDevice(dev1); //devCode = "1"; //DeviceDriver dev2 = new DeviceDriver(); //dev2.DeviceParameter.DeviceName = "设备驱动" + devCode.ToString(); //dev2.DeviceParameter.DeviceAddr = int.Parse(devCode); //dev2.DeviceParameter.DeviceCode = devCode.ToString(); //dev2.DeviceParameter.DeviceID = devCode.ToString(); //dev2.DeviceDynamic.DeviceID = devCode.ToString(); //dev2.DeviceParameter.NET.RemoteIP = "192.168.1.102"; //dev2.DeviceParameter.NET.RemotePort = 9600; //dev2.CommunicateType = CommunicateType.NET; //dev2.Initialize(devCode.ToString()); //server.AddDevice(dev2); while ("exit" == Console.ReadLine()) { server.Stop(); } }
public DeviceInterface() { m_lstprojectors = new List <DeviceDriver>(); m_driver = null; m_ready = true; m_databufA = null; // new byte[BUFF_SIZE]; m_databufB = null; // new byte[BUFF_SIZE]; m_alwaysready = false; // assume it's a generic driver that requires gcode response to be ready }
/// <summary> /// this function starts the serial port detection, waits for the results to return, and /// reports back the detect serial port name /// </summary> /// <returns></returns> public string DeterminePort(int baud) { Initialize(); string comport = "invalid"; bool done = false; SerialAutodetectConfig config = new SerialAutodetectConfig(); config.m_baud = baud; //open and test all serial ports at once foreach (String s in DeviceDriver.GetPortNames()) { if (s.Equals("COM113")) { // create a new tester ConnectionTester tester = new ConnectionTester(s); // specify the name of the port we're trying to detect //set the baud tester.m_baud = config.m_baud; //set up to listen to events tester.ConnectionTesterStatusEvent += new ConnectionTester.ConnectionTesterStatus(ConnectionTesterStatusDel); //start it off tester.Start(); } } m_starttime = Environment.TickCount; while (!done) { try { //check for timeout if (Environment.TickCount >= (m_starttime + TIMEOUTTIME)) { done = true; } Thread.Sleep(0); // yield lock (m_lock) { // check the m_lstresults foreach (ConnectionTester con in m_lstresults) { if (con.m_result == ConnectionTester.eConnTestStatus.eDeviceResponded) { comport = con.m_portname; done = true; Initialize(); break; } } } } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } } return(comport); }
// Set camera to the specified position of the multiplexer public CameraPlay SetCamera(int row, int col, DeviceDriver camera) { if ((row >= 0) && (col >= 0) && (row < MaxRows) && (col < MaxCols)) { camWindows[row, col].Camera = camera; return(camWindows[row, col]); } return(null); }
public virtual DeviceDriver open(Searchable config) { global::System.IntPtr cPtr = yarpPINVOKE.Drivers_open__SWIG_1(swigCPtr, Searchable.getCPtr(config)); DeviceDriver ret = (cPtr == global::System.IntPtr.Zero) ? null : new DeviceDriver(cPtr, false); if (yarpPINVOKE.SWIGPendingException.Pending) { throw yarpPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
// this is called when we receive data from the device driver // one or more full lines can be received here void DriverDataReceivedEvent(DeviceDriver device, byte[] data, int length) { lock (lockobj) { try { // m_ready = true; // not sure I should do this here, I think it may be the cause of the flow control issue // raise the data event if (DataEvent != null) { DataEvent(device, data, length); } /* * //raise a data event notifying that we're ready for the next command * if (StatusEvent != null) * { * StatusEvent(ePIStatus.eReady, "Ready"); * } */ // copy the data into the A buffer int termpos = -1; // copy the data into the 'A' buffer // need to copy into the end of the A buffer if (m_databufA == null) { m_databufA = CopyData(0, data, 0, length); } else { m_databufA = AddBuffers(m_databufA, data); } termpos = Term_Pos(m_databufA, m_databufA.Length); while (termpos != -1) { m_databufB = CopyData(0, m_databufA, 0, termpos + 1); string result = System.Text.Encoding.ASCII.GetString(m_databufB); m_ready = true; if (LineDataEvent != null) { LineDataEvent(device, result); // raise an event for each complete line we receive } m_databufB = CopyData(0, m_databufA, termpos + 1, (m_databufA.Length - (termpos + 1))); m_databufA = CopyData(0, m_databufB, 0, m_databufB.Length); termpos = Term_Pos(m_databufA, m_databufA.Length); // check again } } catch (Exception) { // DebugLogger.Instance().LogError(ex.Message); // this is erroring on the null driver for some reason } } }
public PairWatchdogInformationAnalysis(AnalysisContext ac, EntryPoint ep) { Contract.Requires(ac != null && ep != null); this.AC = ac; this.EP = ep; this.PairEntryPoints = DeviceDriver.GetPairs(ep); this.PairAccesses = new HashSet <Expr>(); this.Region = this.AC.InstrumentationRegions.Find(val => val.Implementation().Name.Equals(ep.Name)); }
void DataReceived(DeviceDriver driver, byte[] data, int len) { if (InvokeRequired) { BeginInvoke(new MethodInvoker(delegate() { DataReceived(driver, data, len); })); } else { String s = ASCIIEncoding.ASCII.GetString(data); txtReceived.Text += s + "\r\n"; } }
// this is called when we receive data from the device driver // one or more full lines can be received here void DriverDataReceivedEvent(DeviceDriver device, byte[] data, int length) { lock (lockobj) { try { // m_ready = true; // not sure I should do this here, I think it may be the cause of the flow control issue // raise the data event if (DataEvent != null) { DataEvent(device, data, length); } if (m_alwaysready) { // don't go any further to parse responses and generate line data events // alwaysready is true for EliteImageWorks driver return; } // copy the data into the A buffer int termpos = -1; // copy the data into the 'A' buffer // need to copy into the end of the A buffer if (m_databufA == null) { m_databufA = CopyData(0, data, 0, length); } else { m_databufA = AddBuffers(m_databufA, data); } termpos = Term_Pos(m_databufA, m_databufA.Length); while (termpos != -1) { m_databufB = CopyData(0, m_databufA, 0, termpos + 1); string result = System.Text.Encoding.ASCII.GetString(m_databufB); m_ready = true; if (LineDataEvent != null) { LineDataEvent(device, result); // raise an event for each complete line we receive } m_databufB = CopyData(0, m_databufA, termpos + 1, (m_databufA.Length - (termpos + 1))); m_databufA = CopyData(0, m_databufB, 0, m_databufB.Length); termpos = Term_Pos(m_databufA, m_databufA.Length); // check again } } catch (Exception) { // DebugLogger.Instance().LogError(ex.Message); // this is erroring on the null driver for some reason } } }
/* * public override void ApplyStyle(ControlStyle ct) * { * base.ApplyStyle(ct); * if (ct.ForeColor != ControlStyle.NullColor) * { * label1.ForeColor = ct.ForeColor; * label2.ForeColor = ct.ForeColor; * lblTitle.ForeColor = ct.ForeColor; * } * if (ct.BackColor != ControlStyle.NullColor) * { * BackColor = ct.BackColor; * } * if (ct.FrameColor != ControlStyle.NullColor) * { * flowLayoutPanel1.BackColor = ct.FrameColor; * flowLayoutPanel5.BackColor = ct.FrameColor; * lblTitle.BackColor = ct.FrameColor; * } * * } */ void LineDataReceived(DeviceDriver driver, string line) { if (InvokeRequired) { BeginInvoke(new MethodInvoker(delegate() { LineDataReceived(driver, line); })); } else { line = line.Trim(); //sb.Insert(0, line); txtReceived.Text += line + "\r\n"; //txtReceived.Refresh(); } }
public async Task OnDiscoverDevices() { WpfUtilities.RunOnUiThread(() => { AvailableDevices.Clear(); }, Application.Current.Dispatcher); CommunicationHandlerFactory.DiscoverDevices(); await Task.Delay(500); foreach (var device in CommunicationHandlerFactory.AvailableDevices) { var handler = CommunicationHandlerFactory.AvailableHandlers.First(h => h.IsDriverForDevice(device)); var driver = new DeviceDriver(device, handler.SupportsSetupDialog, new DelegateCommand((p) => OnRunDeviceHandlerSetup(handler, p))); WpfUtilities.RunOnUiThread(() => { AvailableDevices.Add(driver); }, Application.Current.Dispatcher); } }
private void CreateImplementation(Implementation impl1, Implementation impl2) { Block call = new Block(Token.NoToken, "$logger", new List <Cmd>(), new GotoCmd(Token.NoToken, new List <string> { "$checker" })); if (this.EP1.Name.Equals(this.EP2.Name)) { this.CC1 = this.CreateCallCmd(impl1, impl2); call.Cmds.Add(this.CC1); } else { this.CC1 = this.CreateCallCmd(impl1, impl2); call.Cmds.Add(this.CC1); this.CC2 = this.CreateCallCmd(impl2, impl1, true); call.Cmds.Add(this.CC2); } this.RegionBlocks.Add(call); this.InternalImplementation = new Implementation(Token.NoToken, this.RegionName, new List <TypeVariable>(), this.CreateNewInParams(impl1, impl2), new List <Variable>(), new List <Variable>(), this.RegionBlocks); Block check = new Block(Token.NoToken, "$checker", new List <Cmd>(), new ReturnCmd(Token.NoToken)); foreach (var mr in SharedStateAnalyser.GetPairMemoryRegions( DeviceDriver.GetEntryPoint(impl1.Name), DeviceDriver.GetEntryPoint(impl2.Name))) { AssertCmd assert = this.CreateRaceCheckingAssertion(impl1, impl2, mr); if (assert == null) { continue; } check.Cmds.Add(this.CreateCaptureStateAssume(mr)); check.Cmds.Add(assert); } this.RegionBlocks.Add(check); this.InternalImplementation.Attributes = new QKeyValue(Token.NoToken, "checker", new List <object>(), null); }
/// <summary> /// This function removes all previous device drivers for the projector /// serial ports, it will then re-create the drivers, configure them, and /// add them to the device interface for later use. /// </summary> private void RegenProjectorSerialPorts() { // this will remove all projector device drivers. UVDLPApp.Instance().m_deviceinterface.RemoveAllProjDrivers(); foreach (MonitorConfig mc in UVDLPApp.Instance().m_printerinfo.m_lstMonitorconfigs) { //check to see if we're recreatiung the port if (mc.m_displayconnectionenabled == true) { DeviceDriver dev = DriverFactory.Create(eDriverType.eGENERIC); dev.Configure(mc.m_displayconnection); UVDLPApp.Instance().m_deviceinterface.AddDriver(dev); } } }
// this is called when we receive data from the device driver void DriverDataReceivedEvent(DeviceDriver device, byte[] data, int length) { // stop the watchdog timer m_timeouttimer.Enabled = false; // raise the data event if (DataEvent != null) { DataEvent(device, data, length); } //raise a data event notifying that we're ready for the next command if (StatusEvent != null) { StatusEvent(ePIStatus.eReady, "Ready"); } }
void DataReceived(DeviceDriver driver, byte[] data, int len) { /* * if (InvokeRequired) * { * BeginInvoke(new MethodInvoker(delegate() { DataReceived(driver, data, len); })); * } * else * { * String s = ASCIIEncoding.ASCII.GetString(data); * String rec = txtReceived.Text; * txtReceived.Text = s + "\r\n" + rec; * } * */ }
public DeviceDriver FindDisplaySerialPortDriverByName(string name) { //find the serial port for display 2 foreach (MonitorConfig mc in UVDLPApp.Instance().m_printerinfo.m_lstMonitorconfigs) { if (mc.Monitorid.Contains(name)) // we found our monitor { if (mc.m_displayconnectionenabled) { DeviceDriver driver = UVDLPApp.Instance().m_deviceinterface.FindProjDriverByComName(mc.m_displayconnection.comname); return(driver); } break; } // find the display by name, we should have a function for this already somewhere } return(null); }
public void OnDeviceSelected(int index) { // Stop and destroy the current stream. if (_stream != null) { _stream.Dispose(); _stream = null; } // Reset the UI elements. _channelList.ClearOptions(); _channelList.RefreshShownValue(); _statusText.text = ""; // Break if the null device option was selected. if (_deviceList.value == 0) { return; } // Open a new stream. try { _stream = DeviceDriver.OpenInputStream(_deviceList.value - 1); } catch (System.InvalidOperationException e) { _statusText.text = $"Error: {e.Message}"; return; } // Construct the channel list. _channelList.options = Enumerable.Range(0, _stream.ChannelCount). Select(i => $"Channel {i + 1}"). Select(text => new Dropdown.OptionData() { text = text }). ToList(); _channelList.RefreshShownValue(); }
public void LineReceived(DeviceDriver device, string line) { // parse for temperature data //convert to string string ln = line.Trim().ToUpper(); //ok T:201 B:117 String[] parts = line.Split(' '); // split on spaces bool temp = false; if (parts.Length > 1) // if this is more than just an 'ok' { foreach (string part in parts) { try { //part = part.ToUpper(); if (part.StartsWith("T:")) { string[] tmp = part.Split(':'); EXT0_Temp = double.Parse(tmp[1]); temp = true; } if (part.StartsWith("B:")) { string[] tmp = part.Split(':'); HBP_Temp = double.Parse(tmp[1]); temp = true; } if (temp) { //update the gui UpdateForm(); } } catch (Exception ex) { DebugLogger.Instance().LogError(ex.Message); } } } }
public bool give(DeviceDriver dd, bool own) { bool ret = yarpPINVOKE.PolyDriver_give(swigCPtr, DeviceDriver.getCPtr(dd), own); return ret; }
internal static HandleRef getCPtr(DeviceDriver obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
public virtual bool calibrate(DeviceDriver dd) { bool ret = yarpPINVOKE.ICalibrator_calibrate(swigCPtr, DeviceDriver.getCPtr(dd)); return ret; }
public virtual bool park(DeviceDriver dd) { bool ret = yarpPINVOKE.ICalibrator_park__SWIG_1(swigCPtr, DeviceDriver.getCPtr(dd)); return ret; }