示例#1
0
文件: Form1.cs 项目: duwke/SharpTemp
        private void Form1_Load(object sender, EventArgs e)
        {
            System.ComponentModel.IContainer components = new System.ComponentModel.Container();
            _serialPort1 = new System.IO.Ports.SerialPort(components);
            _serialPort1.PortName = SharpTemp.Properties.Settings.Default.com_port;
            _serialPort1.BaudRate = 57600;

            _serialPort1.Open();
            if (!_serialPort1.IsOpen)
            {
                Console.WriteLine("Oops");
                return;
            }
            _httpServer = new MyHttpServer(_port);
            _httpThread = new Thread(new ThreadStart(_httpServer.listen));
            _httpThread.Start();
            _httpServer.NewAlarm += new MyHttpServer.AlarmChangeHandler(SetAlarm);

            // this turns on !
            _serialPort1.DtrEnable = true;

            // callback for text coming back from the arduino
            _serialPort1.DataReceived += OnReceived;

            // open output csv file
            _sr = new System.IO.StreamWriter(System.IO.File.OpenWrite(System.DateTime.Now.ToShortDateString() + System.DateTime.Now.ToShortTimeString() + ".csv"));

            Thread t = new Thread(new ThreadStart(StartLogger));
            t.Start();

            Chart1.Legends.Add("chtArea");
            Chart1.Series.Clear();
            Chart1.Series.Add("Ambient");

            Chart1.Series["Ambient"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            Chart1.Series["Ambient"].IsVisibleInLegend = true;
            Chart1.Series["Ambient"].ToolTip = "Data Point Value: #VALY{G}";

            Chart1.Series.Add("Cold");
            Chart1.Series["Cold"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            Chart1.Series.Add("Hot");
            Chart1.Series["Hot"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

            Chart1.ChartAreas[0].AxisX.Title = "Time";
            Chart1.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);
            Chart1.ChartAreas[0].AxisY.Title = "Temp";
            Chart1.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);

            textBox1.Text = SharpTemp.Properties.Settings.Default.T0Alarm.ToString();
            textBox2.Text = SharpTemp.Properties.Settings.Default.T1Alarm.ToString();
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            System.ComponentModel.IContainer components = new System.ComponentModel.Container();
            _serialPort1 = new System.IO.Ports.SerialPort(components);
            _serialPort1.PortName = "COM3";
            _serialPort1.BaudRate = 57600;

            _serialPort1.Open();
            if (!_serialPort1.IsOpen)
            {
                Console.WriteLine("Oops");
                return;
            }
            _httpServer = new MyHttpServer(8080);
            _httpThread = new Thread(new ThreadStart(_httpServer.listen));
            _httpThread.Start();

            // this turns on !
            _serialPort1.DtrEnable = true;

            // callback for text coming back from the arduino
            _serialPort1.DataReceived += OnReceived;

            Thread t = new Thread(new ThreadStart(StartLogger));
            t.Start();

            Chart1.Legends.Add("chtArea");
            Chart1.Series.Clear();
            Chart1.Series.Add("Ambient");

            Chart1.Series["Ambient"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            Chart1.Series["Ambient"].IsVisibleInLegend = true;
            Chart1.Series["Ambient"].ToolTip = "Data Point Y Value: #VALY{G}";

            Chart1.Series.Add("T0");
            Chart1.Series["T0"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            Chart1.Series.Add("T1");
            Chart1.Series["T1"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;

            Chart1.ChartAreas[0].AxisX.Title = "Time";
            Chart1.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);
            Chart1.ChartAreas[0].AxisY.Title = "Temp";
            Chart1.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Verdana", 10, System.Drawing.FontStyle.Bold);
        }