public DataRecorder(RealTimeDB DataBase)
        {
            InitializeComponent();
            SW.Reset();
            DB = DataBase;

            this.MaximumSize = new Size(this.Width, this.Height);

            AutoResetEvent autoEvent = new AutoResetEvent(false);
            TimerCallback  tcb       = Update;

            updateTimer = new System.Threading.Timer(tcb, autoEvent, 1000, 1000);
        }
        static void Main(string[] args)
        {
            Dictionary <string, string> tableFormat = new Dictionary <string, string>();

            tableFormat.Add("x", "varchar(5)");
            tableFormat.Add("y", "varchar(5)");
            tableFormat.Add("z", "varchar(260)");

            RealTimeDB db = new RealTimeDB(
                server: "localhost", DB_TYPE: "mysql", DB_NAME: "TestMonitoringSystem", TABLE_NAME: "TestTableMax11",
                user_id: "root", user_pw: "123qwe", tableFormat: tableFormat
                );
            RealTimeDB db1 = new RealTimeDB(
                server: "localhost", DB_TYPE: "mysql", DB_NAME: "TestMonitoringSystem", TABLE_NAME: "TestTableMax12",
                user_id: "root", user_pw: "123qwe", tableFormat: tableFormat
                );
            RealTimeDB db2 = new RealTimeDB(
                server: "localhost", DB_TYPE: "mysql", DB_NAME: "TestMonitoringSystem", TABLE_NAME: "TestTableMax13",
                user_id: "root", user_pw: "123qwe", tableFormat: tableFormat
                );

            db.connect_database();
            db.connect_database_timer();

            db1.connect_database();
            db1.connect_database_timer();

            db2.connect_database();
            db2.connect_database_timer();

            while (true)
            {
                // For Debugging
                Random randomNumber = new Random();

                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("x", randomNumber.Next(0, 150).ToString());
                dic.Add("y", randomNumber.Next(0, 150).ToString());
                dic.Add("z", String.Join("", Enumerable.Repeat <int>(0, 256).ToArray <int>()));

                // Insert your codes
                db.queue.Enqueue(dic);
                db1.queue.Enqueue(dic);
                db2.queue.Enqueue(dic);
                Thread.Sleep(100);
            }

            db.disconnect_database_timer();
            db.disconnect_database();
        }
Beispiel #3
0
        public DataPlotter(RealTimeDB Database)
        {
            InitializeComponent();
            XAxisLength = 10;

            //Add new Plot
            Plot = new PlotView();

            //Add the plot form
            Plot.Location = new Point(0, 20);
            Plot.Width    = this.Width;
            Plot.Height   = this.Height;
            DataPlot      = new PlotModel()
            {
                Title = "Advanced Serial Plotter",
                //PlotType = PlotType.Cartesian,
                Background        = OxyColors.White,
                LegendOrientation = LegendOrientation.Horizontal,
                LegendPlacement   = LegendPlacement.Outside,
                LegendPosition    = LegendPosition.RightTop,
                LegendBackground  = OxyColor.FromAColor(200, OxyColors.White),
                LegendBorder      = OxyColors.Black,
                IsLegendVisible   = true,
            };

            Plot.Model = DataPlot;
            this.Controls.Add(this.Plot);
            Plot.Parent = Splitter.Panel1;
            Plot.Update();

            //Attatch to the database
            DB = Database;
            updateSignalNames();

            //Event Handlers
            this.Resize      += new EventHandler(FrmResize);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(FrmClosing);

            // Create a Timer to update the Plot Data.
            AutoResetEvent autoEvent = new AutoResetEvent(false);
            TimerCallback  tcb       = Update;

            updateTimer = new System.Threading.Timer(tcb, autoEvent, 100, 200);

            TB_XAxisTime.Text = XAxisScale.ToString();
            FrmResize(this, new System.EventArgs());
        }