示例#1
0
        static void Main(string[] args)
        {
            var lib = new Vici8145();

            lib.Openport("COM10");
            while (true)
            {
                DisplayData b       = lib.GetData(null, RespondingCommands.MainDisplayValue);
                var         hexdisp = $"{b.RawData[0]:X2} {b.RawData[1]:X2} {b.RawData[2]:X2} {b.RawData[3]:X2} {b.RawData[4]:X2} {b.RawData[5]:X2} {b.RawData[6]:X2} {b.RawData[7]:X2} {b.RawData[8]:X2} {b.RawData[9]:X2} {b.RawData[10]:X2} {b.RawData[11]:X2}";
                Console.WriteLine(hexdisp);
                b = lib.GetData(b, RespondingCommands.SecondDisplayValue);

                b = lib.GetData(b, RespondingCommands.AnalogeBarValue);


                Console.WriteLine(b.MainDisplayValue + " " + b.Unit + " " + b.Unit1 + " " + b.Select + " " + b.SecondDisplayValue + " " + b.Rel + " " + b.Hold + " " + b.MinMax);

                Console.ReadKey();
            }
            //Console.ReadKey();
        }
示例#2
0
        private void DoWork()
        {
            StreamWriter writer = null;

            string result = appSettings["Comport"];

            if (string.IsNullOrEmpty(result))
            {
                var frm = new Settings();
                frm.ShowDialog();
                result = appSettings["Comport"];
            }

            TimeSpan ts = new TimeSpan(0, 0, 0, LogInterval / 1000, LogInterval % 1000);


            toWriteTime = DateTime.Now;
            if (!string.IsNullOrEmpty(LogFilename))
            {
                writer = new StreamWriter(LogFilename);
            }

            var vcLib = new Vici8145();

            try
            {
                vcLib.Openport(result);
                DisplayData b = new DisplayData();
                while (true)
                {
                    b = vcLib.GetData(b, RespondingCommands.AnalogeBarValue);
                    if (!DisplData(b, writer, ts))
                    {
                        return;
                    }

                    b = vcLib.GetData(b, RespondingCommands.MainDisplayValue);
                    if (!DisplData(b, writer, ts))
                    {
                        return;
                    }

                    b = vcLib.GetData(b, RespondingCommands.AnalogeBarValue);

                    if (!DisplData(b, writer, ts))
                    {
                        return;
                    }

                    b = vcLib.GetData(b, RespondingCommands.SecondDisplayValue);
                    if (!DisplData(b, writer, ts))
                    {
                        return;
                    }

                    b = vcLib.GetData(b, RespondingCommands.AnalogeBarValue);
                    if (!DisplData(b, writer, ts))
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                writer?.Close();

                if (!ex.Message.Contains("abort"))
                {
                    ErrorMesg mesg = new ErrorMesg {
                        Mesg = ex.Message
                    };
                    mesg.ShowDialog();
                }
            }
        }