예제 #1
0
        static void Main(string[] args)
        {
            ITransportLayerWorker worker = new TransportLayerWorker("COM3", 19200);
            worker.InitDevice();
            var dev = new SolaryDevice(1, worker);

            var btn = new Buttons(false, false);
            while (!btn.StartButton)
                btn = dev.GetPressedButtons();

            if(btn.StartButton)
                dev.Start(SolaryAction.Sunbath, 60);

            //            var helper = new PackageHelper();
            //            var cmd = new List<byte>(new byte[] {0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x3c});
            //            var pkg = helper.PackToPackage(cmd);
            //
            //            var port = new SerialPort("COM3", 19200, Parity.None, 8, StopBits.One);
            //            port.DataReceived += (sender, eventArgs) => Console.WriteLine("Answer received");
            //            try
            //            {
            //                port.Open();
            //                port.Write(pkg.ToArray(), 0, pkg.ToArray().Length);
            //            }
            //            catch (Exception e)
            //            {
            //                Console.WriteLine(e);
            //            }

            Console.WriteLine("Press any key");
            Console.ReadKey();
        }
예제 #2
0
        public Solarium()
        {
            ITransportLayerWorker worker = new TransportLayerWorker("COM5", 9600);
            worker.InitDevice();

            _solary = new SolaryDevice(DevNumber, worker);
            _timerStub = new Timer(1000);
            _timerStub.Elapsed += OnTimerElapsed;
        }