예제 #1
0
        public void TestMethodVratitZaklNastaveni9()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                //var data = await m.ReadZaklNastaveni();
                //var task = m.ReadZaklNastaveni();

                //PrintByteArray(task.Result);

                byte minOk;
                byte minNg;
                byte adrLocal;
                byte verzeSw1;
                byte verzeSw2;
                byte verzeSw3;

                Assert.IsTrue(m.ReadZaklNastaveni(out minOk, out minNg, out adrLocal, out verzeSw1, out verzeSw2, out verzeSw3));

                Console.WriteLine($"minOK={minOk} minNG={minNg} verzeSw1={verzeSw1}");

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodVratitZaklNastaveni9 - OK");
        }
예제 #2
0
        public void TestMethodVratitStavCitacu96()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                //var data = await m.ReadZaklNastaveni();
                //var task = m.ReadZaklNastaveni();

                //PrintByteArray(task.Result);

                int ok;
                int ng;

                Console.WriteLine($"TestMethodVratitZaklNastaveni9 - OK");

                Assert.IsTrue(m.ReadStavCitacu(out ok, out ng));

                Console.WriteLine($"OK={ok} NG={ng}");

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodVratitStavCitacu96 - OK");
        }
예제 #3
0
        public void TestMethodZapsatCitace4()
        {
            Console.WriteLine($"TestMethodZapsatCitace4 - start");
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                try
                {
                    serialPort.Open();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    //throw;
                }

                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                var res = m.SetCitace(99, 33);

                Assert.IsTrue(res);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodZapsatCitace4 - OK");
        }
예제 #4
0
 public void TestMethodOpenPort()
 {
     using (SerialPortWraper serialPort = new SerialPortWraper(_portCfg))
     {
         //Thread.Sleep(1000);
         if (serialPort.IsOpen)
         {
             serialPort.Close();
         }
         serialPort.Open();
         Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");
         Console.WriteLine($"port {_portCfg.Port} otevřen");
         serialPort.Close();
         Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");
         Console.WriteLine($"port {_portCfg.Port} uzavřen");
     }
     Console.WriteLine($"TestMethodOpenPort - OK");
 }
예제 #5
0
파일: Program.cs 프로젝트: marsikv/slevyr
        static void TestReadPort()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();

                //serialPort.DataReceived += SerialPort_DataReceived;
                serialPort.ErrorReceived += SerialPort_ErrorReceived;


                Console.WriteLine($"Port is open: {serialPort.IsOpen}");

                if (!serialPort.IsOpen)
                {
                    Console.WriteLine($"Port not open - exit");
                    return;
                }

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                //m.Set6f();

                //m.SetHandshake(255, 1);

                //Assert.IsTrue(res);

                Thread.Sleep(500);

                int c = 0;
                int ok;
                int ng;

                while (c++ < 10)
                {
                    var res = m.ReadStavCitacu(out ok, out ng);

                    Console.WriteLine($"res = {res}  OK = {ok}  NG = {ng}");

                    Thread.Sleep(300);
                }


                //MessageBox.Show("Hello, world!");

                serialPort.Close();
            }
            Console.WriteLine($"TestMethodZapsatNacistCitace - OK");
            Console.ReadLine();
        }
예제 #6
0
        public static bool ClosePort()
        {
            Logger.Info("+");

            if (_runConfig.IsMockupMode)
            {
                return(true);
            }
            if (_serialPort.IsOpen)
            {
                _serialPort.DiscardInBuffer();
                _serialPort.DiscardOutBuffer();
                _serialPort.Close();
            }
            return(!_serialPort.IsOpen);
        }
예제 #7
0
        public void TestMethodNastavSmennost16Task()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                PlantMonitor m = new PlantMonitor(100);
                m.SerialPort = serialPort;

                var res = m.NastavSmennost16('A');

                Assert.IsTrue(res);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");
            }
            Console.WriteLine($"TestMethodNastavSmennost16Task - OK");
        }
예제 #8
0
        public void TestMethodReset7()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                Assert.IsTrue(m.Reset());

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodReset7 - OK");
        }
예제 #9
0
        public void TestMethod1()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                m.Set6f();

                m.SetHandshake(0, 1);

                //Assert.IsTrue(res);

                Thread.Sleep(500);

                int c = 0;
                int ok;
                int ng;

                while (c++ < 100)
                {
                    var res = m.ReadStavCitacu(out ok, out ng);

                    if (res)
                    {
                        m.UnitStatus.Ok = ok;
                        m.UnitStatus.Ng = ng;
                    }

                    Console.WriteLine($"OK = {ok}  NG = {ng}");

                    Thread.Sleep(300);
                }


                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");
            }
            Console.WriteLine($"TestMethodZapsatNacistCitace - OK");
        }
예제 #10
0
        public void TestMethodVratitZaklNastaveni9()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                PlantMonitor m = new PlantMonitor(100);
                m.SerialPort = serialPort;

                //var data = await m.VratitZaklNastaveni9();
                var task = m.VratitZaklNastaveni9();

                PrintByteArray(task.Result);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");
            }
            Console.WriteLine($"TestMethodVratitZaklNastaveni9 - OK");
        }
예제 #11
0
        //[TestMethod]
        public void TestMethodNastavJas()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                var res = m.SetJasLcd(10);

                Assert.IsTrue(res);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodVratitZaklNastaveni9 - OK");
        }
예제 #12
0
        public void TestMethodNastavCileSmen18()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");


                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                var res = m.SetCileSmen('A', 100, 50, 10);

                Assert.IsTrue(res);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodNastavCileSmen18 - OK");
        }
예제 #13
0
        public void TestMethodNastavCileSmen18()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");


                PlantMonitor m = new PlantMonitor(100);
                m.SerialPort = serialPort;

                var task = m.NastavCileSmen18('A', 100, 50, 10);

                task.Wait();

                //var data = await m.NastavCileSmen18('A', 100, 50, 10);

                PrintByteArray(task.Result);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");
            }
            Console.WriteLine($"TestMethodNastavCileSmen18 - OK");
        }
예제 #14
0
        public void TestMethodNastavCileSmen()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                short okVal = 123;
                short ngVal = 54;

                var res = m.SetDefektivita('A', 1000, 1001, 1002);

                Assert.IsTrue(res);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodZapsatNacistCitace - OK");
        }
예제 #15
0
        public void TestMethodZapsatNacistCitace()
        {
            using (var serialPort = new SerialPortWraper(_portCfg))
            {
                serialPort.Open();
                Assert.IsTrue(serialPort.IsOpen, $"port {_portCfg.Port} nelze otevřít");

                UnitMonitor m = new UnitMonitor(100);
                m.SerialPort = serialPort;

                short okVal = 123;
                short ngVal = 54;

                var res = m.SetCitace(okVal, ngVal);

                Assert.IsTrue(res);

                int ok;
                int ng;

                Thread.Sleep(500);

                Assert.IsTrue(m.ReadStavCitacu(out ok, out ng));

                Console.WriteLine($"OK={ok} NG={ng}");

                Assert.AreEqual(ok, okVal);
                Assert.AreEqual(ng, ngVal);

                serialPort.Close();
                Assert.IsFalse(serialPort.IsOpen, $"port {_portCfg.Port} nelze uzařít");

                Thread.Sleep(500);
            }
            Console.WriteLine($"TestMethodZapsatNacistCitace - OK");
        }