Esempio n. 1
0
 public void RelayTest()
 {
     try
     {
         KmtronicU1CrbRelay.Use("COM3", relay =>
         {
             relay.Switch(SwitchNumber.One, SwitchAction.On);
             Thread.Sleep(500);
             relay.Switch(SwitchNumber.One, SwitchAction.Off);
             Thread.Sleep(500);
         });
     }
     catch (System.IO.IOException e)
     {
         TestContext.WriteLine(e);
         Assert.Inconclusive("Com port not available");
     }
 }
Esempio n. 2
0
        private static void Background(CancellationToken ct)
        {
            Thread.CurrentThread.IsBackground = true;

            KmtronicU1CrbRelay.Use(_port, relay =>
            {
                while (!ct.IsCancellationRequested)
                {
                    if (Delays.OnTime > 0)
                    {
                        relay.Switch(SwitchNumber.One, SwitchAction.On);
                        ct.WaitHandle.WaitOne(Delays.OnTime);
                    }

                    if (Delays.OffTime > 0)
                    {
                        relay.Switch(SwitchNumber.One, SwitchAction.Off);
                        ct.WaitHandle.WaitOne(Delays.OffTime);
                    }
                }
            });
        }