//【重载】创建PCI1754更新输入类的实例 /// <summary> /// 【重载】创建PCI1754更新输入类的实例 /// </summary> /// <param name="TargetCard">目标PCI1754卡【窗体控件的形式】</param> /// <param name="DLLPassword">使用此DLL的密码</param> public PCI1754(ref Automation.BDaq.InstantDiCtrl TargetCard) { SuccessBuiltNew = false; PasswordIsCorrect = false; try { TargetPCI1754Card = TargetCard; if (TargetPCI1754Card.Initialized == true) { NeedFormControlFlag = true; SuccessBuiltNew = true; } else { MessageBox.Show("参数'TargetCard'传递的PCI1754控件初始化失败,没有选择设备或者是设备打开失败,请检查具体原因。", "错误"); SuccessBuiltNew = false; return; } } catch (Exception ex) { SuccessBuiltNew = false; MessageBox.Show("创建类的实例时出现错误!\r\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
/// <summary> /// Подрограмма считывания данных из порта /// </summary> /// <param name="port">Имя порта</param> /// <param name="bit"></param> /// <returns></returns> public byte ReadBit(int port, int bit) { byte value; if (!IsInit) { // Модуль не инициализирован throw new Exception <Pci1753ExceptionArgs>(new Pci1753ExceptionArgs(0), "The object of card Pci1753 is not initialized"); } if (0 > port || ChannelCountMax <= port) { // Номер канала задан неверно throw new Exception <Pci1753ExceptionArgs>(new Pci1753ExceptionArgs(0), $"The port {port} of card Pci1753 is not valid"); } var error_code = InstantDiCtrl.ReadBit(port, bit, out value); if (error_code != ErrorCode.Success) { // Возникла ошибка throw new Exception <Pci1753ExceptionArgs>(new Pci1753ExceptionArgs(0), $"Ошибка чтения бита данных из порта {port:D} интерфейсной платы PCI-1753 - {error_code}"); } return(value); }
public override void Init() { //初始化窗体 FilePath = Assembly.GetExecutingAssembly().Location; String path = Path.GetDirectoryName(FilePath); DeviceDescription = xlIni.INIGetStringValue(FilePath + ".ini", "PCI1762", "DeviceDescription", null); if (DeviceDescription == null) { DeviceDescription = "DemoDevice,BID#0"; xlIni.INIWriteValue(FilePath + ".ini", "PCI1762", "DeviceDescription", DeviceDescription); } isDiInitialized = true; isDoInitialized = true; m_do = new InstantDoCtrl(); m_di = new InstantDiCtrl(); try { m_do.SelectedDevice = new DeviceInformation(DeviceDescription); m_di.SelectedDevice = new DeviceInformation(DeviceDescription); m_do.Write(0, 0); m_do.Write(1, 0); } catch (Exception) { throw; } isDoInitialized = m_do.Initialized; isDiInitialized = m_di.Initialized; }
public MSController() { if (instantDiCtrl1 == null) { instantDiCtrl1 = new InstantDiCtrl(); } }
//释放相关资源 /// <summary> /// 释放相关资源 /// </summary> public void Dispose() { try { if (NeedFormControlFlag == true) { TargetPCI1754Card.Dispose(); TargetPCI1754Card = null; } if (UpdateInputSignal != null) { UpdateInputSignal.Abort(); UpdateInputSignal = null; } TargetDICard = null; TargetDevice.Close(); TargetDevice.Dispose(); } catch (Exception)// ex) { //ErrorMessage = ex.Message;; } }
public void Init() { m_do = new InstantDoCtrl(); m_di = new InstantDiCtrl(); m_do.SelectedDevice = new DeviceInformation(DeviceDescription); m_di.SelectedDevice = new DeviceInformation(DeviceDescription); }
public PCIRelayCard() { DoController = new InstantDoCtrl(); DiReader = new InstantDiCtrl(); string deviceDescription = "DemoDevice,BID#0"; DoController.SelectedDevice = new DeviceInformation(deviceDescription); DiReader.SelectedDevice = new DeviceInformation(deviceDescription);
public PCIRelayCard(int deviceNumber) { DoController = new InstantDoCtrl(); DoController.SelectedDevice = new DeviceInformation(deviceNumber); DiReader = new InstantDiCtrl(); DiReader.SelectedDevice = new DeviceInformation(deviceNumber); stateDoToWrite = ReadDoState(this.IORelayPort); ReadDiState(this.IDIPort); }
public MSController(int deviceNumber, VM_MSConfig msConfig) { if (instantDiCtrl1 == null) { instantDiCtrl1 = new InstantDiCtrl(); } instantDiCtrl1.SelectedDevice = new DeviceInformation(deviceNumber); Config = msConfig; STSEventLogManage.Instance.Start(); }
public Board1730(PCIE1730pars _pars, DOnPr _OnPr) : base(_pars, _OnPr) { ctrl_in = new InstantDiCtrl(); ctrl_out = new InstantDoCtrl(); ctrl_in.SelectedDevice = new DeviceInformation(_pars.Devnum); ctrl_out.SelectedDevice = new DeviceInformation(_pars.Devnum); buf_in = new byte[portCount_in]; buf_out = new byte[portCount_out]; }
public PCIRelayCard() { DoController = new InstantDoCtrl(); DiReader = new InstantDiCtrl(); string deviceDescription = "DemoDevice,BID#0"; DoController.SelectedDevice = new DeviceInformation(deviceDescription); DiReader.SelectedDevice = new DeviceInformation(deviceDescription); stateDoToWrite = ReadDoState(this.IORelayPort); ReadDiState(this.IDIPort); }
public void Initialize() { _deviceInformation = new DeviceInformation(DeviceId); _di = new InstantDiCtrl(); _di.SelectedDevice = _deviceInformation; InputPortCount = _di.Features.PortCount; InputPortState = new byte[InputPortCount]; _do = new InstantDoCtrl(); _do.SelectedDevice = _deviceInformation; OutputPortCount = _do.Features.PortCount; }
/// <summary> /// 尝试启动 /// </summary> public void Open() { if (!IsOpen()) { DiInstance = new InstantDiCtrl(); DiInstance.SelectedDevice = new DeviceInformation(DeviceDiscription); DoInstance = new InstantDoCtrl(); DoInstance.SelectedDevice = new DeviceInformation(DeviceDiscription); DeviceDiscriptionOfInstance = DeviceDiscription; } doBuffer = Read_do(); }
/// <summary> /// /// </summary> protected DaqPciClass() { // Step 1: // Create a 'InstantAiCtrl' for Instant AI function. InstantAiContrl = new InstantAiCtrl(); // Create a 'InstantAoCtrl' for Instant AO function. InstantAoContrl = new InstantAoCtrl(); // DioCtrlBase class used for digital input(DI),digital input // related interrupt,digital output operations(DO); _baseDioCtrl = new DioCtrlBase(); // Create a 'InstantDiCtrl' for DI function. InstantDiCtrl = new InstantDiCtrl(); // Create a 'InstantDoCtrl' for DO function. InstantDoCtrl = new InstantDoCtrl(); }
public LongmenDevice(IPort port, ISerialize serialize) : base(port, serialize) { _device = new DeviceInformation(((PortBase)port).Port); _instantDoCtrl = new InstantDoCtrl(); _instantDoCtrl.SelectedDevice = _device; _instantDiCtrl = new InstantDiCtrl(); _instantDiCtrl.SelectedDevice = _device; byte[] data = new byte[4]; _instantDoCtrl.Write(0, data.Length, data); _option = default(eLongMenOption); _instantDiCtrl.Read(0, data.Length, data); Status = (eLongMenState)BitConverter.ToUInt32(data, 0); }
//private event EventHandler<DiSnapEventArgs> interruptEvent; public BoardCardControl(string deviceDescription, string profilePath = "") { this.deviceDescription = deviceDescription; this.profilePath = profilePath; this.instantDiCtrl = new InstantDiCtrl(); this.instantDoCtrl = new InstantDoCtrl(); this.instantDiCtrl.SelectedDevice = new DeviceInformation(this.DeviceDescription); this.instantDoCtrl.SelectedDevice = new DeviceInformation(this.DeviceDescription); //this.instantDiCtrl.Interrupt += new EventHandler<DiSnapEventArgs>(this.instantDiCtrl_Interrupt); //Todo::待测 if (String.IsNullOrEmpty(this.ProfilePath) && this.instantDiCtrl.Device != null && this.instantDoCtrl.Device != null) { this.instantDiCtrl.LoadProfile(this.ProfilePath); this.instantDoCtrl.LoadProfile(this.profilePath); } }
public void Initialize() { try { _deviceInformation = new DeviceInformation(DeviceId); _di = new InstantDiCtrl { SelectedDevice = _deviceInformation }; InputPortCount = _di.Features.PortCount; InputPortState = new byte[InputPortCount]; _do = new InstantDoCtrl { SelectedDevice = _deviceInformation }; OutputPortCount = _do.Features.PortCount; } catch (Exception e) { Logger.Error(e); } }
/// <summary> /// 尝试释放资源 /// </summary> public void Close() { DeviceDiscriptionOfInstance = ""; if (DoInstance != null) { if (DoInstance.Initialized) { DoInstance.Dispose(); } DoInstance = null; } if (DiInstance != null) { if (DiInstance.Initialized) { DiInstance.Dispose(); } DiInstance = null; } }
//【重载】创建PCI1754更新输入类的实例 /// <summary> /// 【重载】创建PCI1754更新输入类的实例 /// </summary> /// <param name="TargetCard">目标PCI1754卡【窗体控件的形式】</param> /// <param name="DLLPassword">使用此DLL的密码</param> public PCI1754(ref Automation.BDaq.InstantDiCtrl TargetCard, string DLLPassword) { SuccessBuiltNew = false; PasswordIsCorrect = false; try { if (DLLPassword == "ThomasPeng" || (DLLPassword == "pengdongnan") || (DLLPassword == "彭东南")) { PasswordIsCorrect = true; TargetPCI1754Card = TargetCard; if (TargetPCI1754Card.Initialized == true) { NeedFormControlFlag = true; SuccessBuiltNew = true; } else { MessageBox.Show("参数'TargetCard'传递的PCI1754控件初始化失败,没有选择设备或者是设备打开失败,请检查具体原因。", "错误"); SuccessBuiltNew = false; return; } } else { PasswordIsCorrect = false; SuccessBuiltNew = false; MessageBox.Show("Right Prohibited.\return\n You don't have the given right to use this DLL library, please contact with ThomasPeng.\r\n你未得到授权的密码,无法使用此DLL进行软件开发!请与作者彭东南联系:[email protected]\r\n 版权所有: 彭东南", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } catch (Exception ex) { SuccessBuiltNew = false; MessageBox.Show("创建类的实例时出现错误!\r\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void UpdateStaticDI() { //----------------------------------------------------------------------------------- // Configure the following parameters before running the demo //----------------------------------------------------------------------------------- //The default device of project is demo device, users can choose other devices according to their needs. string deviceDescription = "PCI-1750,BID#0"; string profilePath = "../../profile/PCI-1750.xml"; int startPort = 0; int portCount = 2; short fullResponse = 0; StaticIO_firstTime = true; ErrorCode errorCode = ErrorCode.Success; // Step 1: Create a 'InstantDiCtrl' for DI function. InstantDiCtrl instantDiCtrl = new InstantDiCtrl(); try { // Step 2: Select a device by device number or device description and specify the access mode. // in this example we use ModeWrite mode so that we can fully control the device, including configuring, sampling, etc. instantDiCtrl.SelectedDevice = new DeviceInformation(deviceDescription); errorCode = instantDiCtrl.LoadProfile(profilePath);//Loads a profile to initialize the device. if (BioFailed(errorCode)) { throw new Exception(); } // read DI ports' status and show. //Console.WriteLine("Reading ports' status is in progress..., any key to quit!\n"); byte[] buffer = new byte[64]; //byte data = 0;//data is used to the API ReadBit. //int bit = 0;//bit is used to the API ReadBit. // Step 3: Read DI ports' status and show. errorCode = instantDiCtrl.Read(startPort, portCount, buffer); //errorCode = instantDiCtrl.ReadBit(startPort, bit, out data); if (BioFailed(errorCode)) { throw new Exception(); } //Show ports' status for (int i = 0; i < portCount; ++i) { if (_showVerboseMessage) { Console.WriteLine(" DI port {0} status : 0x{1:x}\n", startPort + i, buffer[i]); } /************************************************************************/ //Console.WriteLine(" DI port {0} status : 0x{1:x}\n", startPort + i, data); //NOTE: //argument1:which port you want to control? For example, startPort is 0. //argument2:which bit you want to control? You can write 0--7, any number you want. //argument3:data is used to save the result. /************************************************************************/ } fullResponse = (short)(buffer[0] | buffer[1] << 8); extractAndsetNum(fullResponse); //Thread.Sleep(100); } catch (Exception e) { // Something is wrong string errStr = BioFailed(errorCode) ? " Some error occurred. And the last error code is " + errorCode.ToString() : e.Message; Console.WriteLine(errStr); } finally { // Step 4: Close device and release any allocated resource. instantDiCtrl.Dispose(); //Console.ReadKey(false); } }
public IOControl() { Console.WriteLine("New IOcontrol object created"); instantDiCtrl1 = new InstantDiCtrl(); instantDoCtrl1 = new InstantDoCtrl(); try { //Kreiranje objekata za upravljanje I/O uređajem instantDoCtrl1.SelectedDevice = new DeviceInformation(1); instantDiCtrl1.SelectedDevice = new DeviceInformation(1); //Učitavanja profila I/O Modula IOprofile = "D:/N046_17 DOKUMENTACIJA I PROGRAM/Res/ioProfile.xml"; //Provjera učitavanja profila ErrorCode errProfile = ErrorCode.Success; errProfile = instantDiCtrl1.LoadProfile(IOprofile); if (errProfile != ErrorCode.Success) { HandleError(errProfile); } else { Globals.pCol.writeLog(0, "I/O card profile loaded", ""); } } catch (Exception ex) { Globals.pCol.writeLog(2, "I/O card not ready", ""); MessageBox.Show("Device not ready: " + ex.ToString()); return; } //Provjera inicijalizacije Digitalnih outputa if (!instantDoCtrl1.Initialized) { Globals.pCol.writeLog(2, "No device selected or device open failed!", ""); MessageBox.Show("No device selected or device open failed!", "StaticDO"); return; } //Provjera inicijalizacije Digitalnih inputa if (!instantDiCtrl1.Initialized) { Globals.pCol.writeLog(2, "No device selected or device open failed!", ""); MessageBox.Show("No device selected or device open failed!", "StaticDI"); return; } /* * Kreiranje i pokretanje update timera * 50 ms * stopTimerInterval - parametar kojim se definira vrijeme vrtnje motora nakon što se ugasi separator 1. */ timerChStats = new System.Windows.Forms.Timer(); updateTick = 50; timerChStats.Interval = updateTick; timerChStats.Start(); timerChStats.Tick += new EventHandler(updateStatus); rotationDirection = "0"; stopTimerInterval = Int32.Parse(Globals.stopTimerInt); /* * refreshDeviceTimer = new Timer(); * refreshDeviceTimer.Interval = 400; * refreshDeviceTimer.Tick += new EventHandler(refreshIODevice); * refreshDeviceTimer.Start(); */ Belt_counter = 0; Belt_counterOld = 0; tickCount = 0; TotalStop_ACTIVE = false; //resetOutputs(); }