private void timer2000_Tick(object sender, EventArgs e) { RelayManager.Open(0, 2); R2.BackColor = Color.Orange; timer2000.Stop(); timer500.Start(); Properties.Status.Default.race_state = 1; }
private void startButton_Click(object sender, EventArgs e) { SaveEverything(); Properties.Status.Default.race_state = 0; //Race State: //0 - before start //1 - starting //2 - green, Go! //3 - false start //4 - Finished counter = 0; RelayManager.Open(0, 1); R1.BackColor = Color.Blue; RelayManager.Close(0, 2); R2.BackColor = SystemColors.Control; RelayManager.Close(0, 3); R3.BackColor = SystemColors.Control; RelayManager.Close(0, 4); R4.BackColor = SystemColors.Control; RelayManager.Close(0, 5); R5.BackColor = SystemColors.Control; buttonCancelRace.Visible = false; timer2000.Interval = Properties.Settings.Default.preStageTime_ms; if (Properties.Settings.Default.start_mode) { timer500.Interval = 500; } else { timer500.Interval = 400; } groupBox2.Enabled = false; groupBox3.Enabled = false; stopwatch.Stop(); stopwatch.Reset(); timer2000.Start(); }
private void timer500_Tick(object sender, EventArgs e) { counter++; switch (counter) { case 1: if (Properties.Settings.Default.start_mode) { RelayManager.Close(0, 2); R2.BackColor = SystemColors.Control; } RelayManager.Open(0, 3); R3.BackColor = Color.Orange; break; case 2: if (Properties.Settings.Default.start_mode) { RelayManager.Close(0, 3); R3.BackColor = SystemColors.Control; } RelayManager.Open(0, 4); R4.BackColor = Color.Orange; break; case 3: RelayManager.Close(0, 2); RelayManager.Close(0, 3); RelayManager.Close(0, 4); RelayManager.Open(0, 5); R2.BackColor = SystemColors.Control; R3.BackColor = SystemColors.Control; R4.BackColor = SystemColors.Control; R5.BackColor = Color.ForestGreen; timer500.Stop(); buttonCancelRace.Visible = true; stopwatch.Restart(); Properties.Status.Default.race_state = 2; break; } }
static void Main(string[] args) { RelayManager.Init(); Console.WriteLine("Total devices : " + RelayManager.DevicesCount().ToString()); for (int i = 0; i < RelayManager.DevicesCount(); ++i) { RelayManager.OpenDevice(i); Console.WriteLine("Device number : {0}", RelayManager.CurrentDeviceIndex()); Console.WriteLine("Device serial : {0}", RelayManager.RelaySerial()); Console.WriteLine("Device channels : {0}", RelayManager.ChannelsCount()); Console.WriteLine("--------------------------------"); } Console.WriteLine("Enter 'q' for quit"); while (true) { string s = Console.ReadLine(); if (s == "1") { Console.WriteLine("Opening..."); RelayManager.Open(0, 1); Console.WriteLine("Channel 1 opened status : " + RelayManager.ChannelOpened(1)); } if (s == "2") { Console.WriteLine("Closing..."); RelayManager.Close(0, 1); Console.WriteLine("Channel 1 opened status : " + RelayManager.ChannelOpened(1)); } if (s == "3") { Console.WriteLine("Opening..."); RelayManager.Open(1, 1); Console.WriteLine("Channel 1 opened status : " + RelayManager.ChannelOpened(1)); } if (s == "4") { Console.WriteLine("Closing..."); RelayManager.Close(1, 1); Console.WriteLine("Channel 1 opened status : " + RelayManager.ChannelOpened(1)); } if (s == "5") { Console.WriteLine("Inverting channel 1 on relay 0..."); RelayManager.Invert(0, 1); Console.WriteLine("Channel 1 opened status : " + RelayManager.ChannelOpened(1)); } if (s == "6") { Console.WriteLine("Inverting channel 1 on relay 1 ..."); RelayManager.Invert(1, 1); Console.WriteLine("Channel 1 opened status : " + RelayManager.ChannelOpened(1)); } if (s == "q") { break; } } RelayManager.Close(); }
public void toggleRelay(int RelayNo) { //Set RelayNo to 0 if rollers are turning and deactivation checkbox is checked //DEBUG: //Properties.Status.Default.RollersTurning = true; if (Properties.Status.Default.RollersTurning & Properties.Settings.Default.R6dis_on_speed & RelayNo == 6) { RelayNo = 0; } if (Properties.Status.Default.RollersTurning & Properties.Settings.Default.R7dis_on_speed & RelayNo == 7) { RelayNo = 0; } if (Properties.Status.Default.RollersTurning & Properties.Settings.Default.R8dis_on_speed & RelayNo == 8) { RelayNo = 0; } switch (RelayNo) { case 0: break; case 1: if (R1.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 1); R1.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 1); R1.BackColor = SystemColors.Control; } break; case 2: if (R2.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 2); R2.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 2); R2.BackColor = SystemColors.Control; } break; case 3: if (R3.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 3); R3.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 3); R3.BackColor = SystemColors.Control; } break; case 4: if (R4.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 4); R4.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 4); R4.BackColor = SystemColors.Control; } break; case 5: if (R5.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 5); R5.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 5); R5.BackColor = SystemColors.Control; } break; case 6: if (R6.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 6); R6.BackColor = Color.ForestGreen; statusOverlay.button1.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 6); R6.BackColor = SystemColors.Control; statusOverlay.button1.BackColor = SystemColors.Control; } break; case 7: if (R7.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 7); R7.BackColor = Color.ForestGreen; statusOverlay.button2.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 7); R7.BackColor = SystemColors.Control; statusOverlay.button2.BackColor = SystemColors.Control; } break; case 8: if (R8.BackColor == SystemColors.Control) { //Enables that relay when button pressed. RelayManager.Open(0, 8); R8.BackColor = Color.ForestGreen; statusOverlay.button3.BackColor = Color.ForestGreen; } else { //Disables that relay when button pressed. RelayManager.Close(0, 8); R8.BackColor = SystemColors.Control; statusOverlay.button3.BackColor = SystemColors.Control; } break; } }