示例#1
0
        void timer_Tick(GT.Timer timer)
        {
            var data = new SensorData()
            {
                Ph     = 1 + rnd.Next(10),
                Relay1 = rnd.Next(2) > 0 ? true : false,
                Relay2 = rnd.Next(2) > 0 ? true : false,
                Tds1   = 1 + rnd.Next(100),
                Tds2   = 1 + rnd.Next(100),
                Temp1  = 25 + rnd.Next(7), //.ConvertAndReadTemperature(),
                Temp2  = 25 + rnd.Next(8), //.ConvertAndReadTemperature(),
                //Temp3 = Temp3.ConvertAndReadTemperature(),
                WaterDist = 1 + rnd.Next(10)
            };
            //insert to db
            var item = new DataGridItem(new object[] { DateTime.Now.ToString("HH:mm:ss"), data.Temp1.ToString("n2") + "C", data.Temp2.ToString("n2") + "C", data.WaterDist.ToString("n2") + "CM", data.Tds1.ToString("n2"), data.Tds2.ToString("n2") });

            //add data to grid
            GvData.AddItem(item);
            GvData.Invalidate();
            if (counter++ > 9)
            {
                counter = 0;
                GvData.Clear();
            }

            var jsonStr = Json.NETMF.JsonSerializer.SerializeObject(data);

            Debug.Print("kirim :" + jsonStr);
            xBeeAdapter.Port.WriteLine(jsonStr);
        }
示例#2
0
        /// <summary>
        /// Initialization of mailbox data grid with info.
        /// </summary>
        /// <param name="invalidate">Determines whether or not to refresh data grid.</param>
        private void PopulateMailbox(bool invalidate)
        {
            // DataGridItems must contain an object array whose length matches the number of columns.
            dGridMailbox.AddItem(new DataGridItem(new object[2] {
                "-----E-Mail-----", "-----Addresses-----"
            }));

            for (int i = 0; i < EmailAddressArray.Length; i++)
            {
                EmailAddressArray[i] = new EmailAddress("*****@*****.**", "OFF");
                dGridMailbox.AddItem(new DataGridItem(new object[2] {
                    EmailAddressArray[i].State, EmailAddressArray[i].Address
                }));
            }

            UserMailbox = new EmailMailbox("*****@*****.**", "password", "smtp.server.com", 0, "pop3.server.com", 0);

            dGridMailbox.AddItem(new DataGridItem(new object[2] {
                "-----Mailbox----", "-------Setup------"
            }));
            dGridMailbox.AddItem(new DataGridItem(new object[2] {
                "Username:"******"Password:"******"SMTP Server:", UserMailbox.SmtpServer
            }));
            dGridMailbox.AddItem(new DataGridItem(new object[2] {
                "SMTP Port:", UserMailbox.SmtpPort.ToString()
            }));
            dGridMailbox.AddItem(new DataGridItem(new object[2] {
                "POP3 Server:", UserMailbox.Pop3Server
            }));
            dGridMailbox.AddItem(new DataGridItem(new object[2] {
                "POP3 Port:", UserMailbox.Pop3Port.ToString()
            }));

            if (invalidate)
            {
                dGridMailbox.Invalidate();
            }
        }
        private void update_Schedule_DataGrid()
        {
            dataGrid_Schedule.Clear();

            if (dropDown_PumpSelection.Value != null)
            {
                Fertilize_Job[] jobs = Fertilize_Manager.GetFertilizePumpByIndex((int)dropDown_PumpSelection.Value).Get_All_Fertilize_Jobs();

                foreach (Fertilize_Job job in jobs)
                {
                    dataGrid_Schedule.AddItem(new DataGridItem(new object[] { job.StartTime.Hour.ToString("D2") + ":" + job.StartTime.Minute.ToString("D2"), job.Quantity_ml.ToString() + " ml", job }));
                }
            }

            update_DataTextboxes(dataGrid_Schedule.SelectedIndex);
            dataGrid_Schedule.Invalidate();
        }