private static void write_IOC0640_step(RunResult result) { ushort outPort_index = result == RunResult.Missing ? Resources.Empty_port : result == RunResult.NG ? Resources.NG_port : Resources.OK_port; IOC0640.ioc_write_outbit(Resources.cardIndex, outPort_index, Resources.startSignal); Thread.Sleep(Resources.signalWidth); IOC0640.ioc_write_outbit(Resources.cardIndex, outPort_index, Resources.endSignal); }
/// <summary> /// Read trigger signal from IO card. This function only works within a while loop /// </summary> /// <param name="initialState"> /// Specify the initial state of of incoming signal, this param should not be modified from /// outside /// </param> /// <returns>true for triggered, false for not triggered</returns> private static bool read_IOC0640_step(ref int initialState) { int stateRead = IOC0640.ioc_read_inbit(Resources.cardIndex, Resources.inSignal_port); if (stateRead == initialState) { return(false); } initialState = stateRead; return(stateRead == Resources.startSignal); }
private void Form1_Load(object sender, EventArgs e) { // Initialize resources from the MainWindow Resources.mainWindow = this; // Load vpp file Utilities.load_vpp(Resources.VppPath); // Init the IO card and begin listening in a background thread try { int initSuccess = IOC0640.ioc_board_init(); textBox_message.AppendText(initSuccess > 0? "IO card init succeeded!\n\r":"IO card init failed!\n\r"); } catch (Exception exception) { textBox_message.AppendText("IO card init failed: " + exception.Message + "\n\r"); } Utilities.Listen_for_IOSignals_async(); }