/// <summary> /// /// </summary> /// <param name="sn">Serial number of Xemo controller. Labeled on on of side panel of Xemo Controller SU 360</param> /// <param name="comPort">Port number referred to Xemo device. By default is 0 that means auto matching.</param> /// <param name="baudRate">BaudRate for chosen com port. Not used in case interface initialization via USB.</param> /// <param name="sets">Initial settings of current settings</param><seealso cref="SampleChangerSettings"/> public SampleChanger(int sn, ushort comPort = 0, int baudRate = 19200, SampleChangerSettings sets = null) { try { if (!XemoDet.ContainsKey(sn)) { Report.Notify(new Message(Codes.ERR_XM_INI_DEV_NF) { DetailedText = $"Device with such serial number '{sn}' not found" }); throw new ArgumentNullException($"Device with such serial number '{sn}' not found"); } if (sets == null) { Settings = new SampleChangerSettings(); } SerialNumber = sn; ComPort = GetComPortByDeviceId(SerialNumber); _baudRate = baudRate; PairedDetector = XemoDet[sn]; if (ComPort == 0) { XemoDLL.ML_DeIniCom(); } else { XemoDLL.ML_DeIniComPort((short)ComPort); } Connect(); ErrorHandlerDel = ErrorHandler; // you must save a "copy" of the delegate so that if the C functions calls this method at any time, this copy is still "alive" and hasn't been GC ML_ErrorCallBackDelegate(ErrorHandlerDel); InitializeAxes(); } catch (Exception ex) { Report.Notify(new Message(Codes.ERR_XM_INI_UNREG) { DetailedText = ex.Message }); throw; } }
public void Disconnect() { BreakSystemProgram(); XemoDLL.ML_DeIniCom(); }