public MainWindow() { InitializeComponent(); _defaultBrush = (SolidColorBrush) Resources["DefaultBrush"]; _OnBrush = Brushes.Green; _switch = new ChannelSwitch(); _switch.Connecting += _switch_Connecting; _switch.ConnectionEstablished += _switch_ConnectionEstablished; _switch.ConnectionLost += _switch_ConnectionLost; _switch.ChannelStateRequest += _switch_ChannelStateRequest; _switch.ChannelStateConfirmation += _switch_ChannelStateConfirmation; _switch.Error += _switch_Error; _switch.Exiting += _switch_Exiting; }
static void Main(string[] args) { var sw = new ChannelSwitch(); //sw.Setup(new ConnectionParams { BaudRate = 115200, PortName = "COM7" }); sw.Initialize(); System.Threading.Thread.Sleep(1000); while (!sw.Initialized) ; for (short i = 0; i < 40; i++) { sw.Switch(i, true); System.Threading.Thread.Sleep(100); } Console.ReadKey(); }