VisionBox .NET Library  1.7.10.0 (2024-04-16)
IOScheduler_Example.cs

C# example for using the IOScheduler device

See VIB_NET::IOScheduler for a description of this example.

1 
2 using System;
3 using VIB_NET;
4 
5 namespace CSharp
6 {
7  class IOScheduler_Example
8  {
9  public static void IOScheduler()
10  {
11  Console.Clear();
12 
14  try
15  {
16  // Create device objects with the 'using' statement so they get closed automatically:
17  using (VIB_NET.Multiplexer multiplexer = new VIB_NET.Multiplexer())
18  using (VIB_NET.IOScheduler ioScheduler0 = new VIB_NET.IOScheduler())
19  using (VIB_NET.IOScheduler ioScheduler1 = new VIB_NET.IOScheduler())
20  using (VIB_NET.DigitalOutput digitalOutput = new VIB_NET.DigitalOutput())
21  using (VIB_NET.TriggerGenerator triggerGenerator = new VIB_NET.TriggerGenerator())
22  {
23  // Connection of the FPGA units:
24  //
25  // triggerGenerator(0) -> multiplexer(0) +--------------------------------------> digitalOutput(0)
26  // |
27  // +-> ioScheduler0(0) -> multiplexer(1) -> digitalOutput(1)
28  // |
29  // +-> ioScheduler0(1) -> multiplexer(2) -> digitalOutput(2)
30  // |
31  // +-> ioScheduler1(0) -> multiplexer(3) -> digitalOutput(3)
32 
33  //>Open all devices: Multiplexer, 2x IOScheduler, DigitalOutput, TriggerGenerator
34  multiplexer.Open();
35  triggerGenerator.Open();
36  ioScheduler0.Open(0);
37  ioScheduler1.Open(1);
38  digitalOutput.Open(0);
39 
40  //TriggerGenerator: create 100 Hz signal
41  triggerGenerator.ConfigureSet("GenA_tLow=5ms GenA_tHigh=5ms");
42  triggerGenerator.ConfigureSet("TrigOut0_Mux=GenA");
43 
44  //Multiplexer
45  multiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.OFF); //disconnect the 100Hz from the schedulers
46  multiplexer.ConnectOutput(1, VIB_NET.Multiplexer.eMUX_SOURCE.IOSCHEDULER_0_OUT0);
47  multiplexer.ConnectOutput(2, VIB_NET.Multiplexer.eMUX_SOURCE.IOSCHEDULER_0_OUT1);
48  multiplexer.ConnectOutput(3, VIB_NET.Multiplexer.eMUX_SOURCE.IOSCHEDULER_1_OUT0);
49 
50  //MuxOutpus as source for the DigOut
51  digitalOutput.SetSource(0, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT0, false); //noInvert
52  digitalOutput.SetSource(1, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT1, false); //noInvert
53  digitalOutput.SetSource(2, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT2, false); //noInvert
54  digitalOutput.SetSource(3, VIB_NET.DigitalOutput.eOUT_SOURCE.MUX_OUT3, false); //noInvert
55 
56  //Prepare the IO schedulers
57  ioScheduler0.Reset();
58  ioScheduler1.Reset();
59  ioScheduler1.SetOutputPulsTiming(8 * 1000, 2 * 1000); // delay us, on us
60 
61  //> start the units
62  ioScheduler0.Start();
63  ioScheduler1.Start();
64 
65  //add some values
66  const UInt32 StartDelay = 4;
67  const UInt32 StepMul = 2;
68  for (UInt32 i = 0; i < 5; i++)
69  {
70  //we want to toggle the output
71  if (1 == (i % 2))
72  {
73  ioScheduler0.PushValue(StartDelay + StepMul * i, 2);
74  }
75  else
76  {
77  ioScheduler0.PushValue(StartDelay + StepMul * i, 1);
78  }
79  //we want only edges so we set always 1
80  ioScheduler1.PushValue(StartDelay + StepMul * i, 1);
81  }
82  //> connect the 100Hz to the IOScheduler
83  multiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.TRIGGEN_OUT0);
84 
85  //> wait until all elements are outputted
86  UInt32 iFillLevel = 0;
87  do
88  {
89  iFillLevel = ioScheduler0.BufferFillLevel;
90  }
91  while (iFillLevel > 0);
92 
93  //disconnect the 100Hz from the schedulers
94  multiplexer.ConnectOutput(0, VIB_NET.Multiplexer.eMUX_SOURCE.OFF);
95 
96  } // Close all devices
97  }
98  catch (System.Exception e)
99  {
100  Console.WriteLine(e.Message);
101  }
103 
104  Console.WriteLine("\nPress enter to proceed...");
105  System.Console.ReadLine();
106  }
107  }
108 }
VIB_NET
All relevant classes and functions are residing in this namespace.
Definition: CameraLinkIn.cpp:6
VIB_NET::Multiplexer
This class controls the Multiplexer unit which connects signal sources and sinks with each other.
Definition: VIB_NET.h:1003
VIB_NET::TriggerGenerator
This module controls the FPGA Trigger Unit.
Definition: VIB_NET.h:658
VIB_NET::DigitalOutput
This class controls the optically isolated output signals.
Definition: VIB_NET.h:1099
VIB_NET::DigitalOutput::eOUT_SOURCE
eOUT_SOURCE
Sources for the Outputs used with SetSource()
Definition: VIB_NET.h:1112
VIB_NET::Multiplexer::eMUX_SOURCE
eMUX_SOURCE
Source signal definitions for the Multiplexer
Definition: VIB_NET.h:1008
VIB_NET::IOScheduler
This class controls the I/O Scheduler which allows to store and emit output signals in hard real-time...
Definition: VIB_NET.h:1291