Exemple #1
0
        public Form1()
        {
            InitializeComponent();

            SyncFolder = Environment.GetEnvironmentVariable("USERPROFILE");
            SyncFolder += "\\Dropbox\\LowEx-Dropbox\\Bubble Data";
            if (Directory.Exists(SyncFolder) == false) SyncFolder = "";
            else folderBrowserDialog1.SelectedPath = SyncFolder;
            enSync = checkBoxSync.Checked;
            enUpload = checkBoxUpload.Checked;
            enStore = checkBoxStore.Checked;

            CurTempNodID = 0;
            CurPumpNodeID = 0;

            ComSet comset = new ComSet(ref this.ComPort1);
            comset.ShowDialog();
            if (ComPort1.IsOpen == true)
                ComPort1.DiscardInBuffer();
            ComPort1.ReadTimeout = 50;

            comboBoxT.Sorted = true;
            comboBoxP.Sorted = true;
            listBoxTBID.Sorted = true;

            string curdirectory = Directory.GetCurrentDirectory();
            string newdirectory;
            newdirectory = curdirectory + "\\Data";
            if (Directory.Exists(newdirectory) == false)
            {
                Directory.CreateDirectory(newdirectory);
            }
            datastoredirectory = curdirectory + "\\Data";
            newdirectory = curdirectory + "\\Upload";
            if (Directory.Exists(newdirectory) == false)
            {
                Directory.CreateDirectory(newdirectory);
            }
            newdirectory = curdirectory + "\\Upload\\Upload0";
            if (Directory.Exists(newdirectory) == false)
            {
                Directory.CreateDirectory(newdirectory);
            }
            newdirectory = curdirectory + "\\Upload\\Upload1";
            if (Directory.Exists(newdirectory) == false)
            {
                Directory.CreateDirectory(newdirectory);
            }
            uploadstoredirectory = curdirectory + "\\Upload\\Upload0";
            newdirectory = curdirectory + "\\Config";
            if (Directory.Exists(newdirectory))
            {
                if (File.Exists(newdirectory + "\\Temperature.config") == true)
                {
                    ReadConfig(newdirectory + "\\Temperature.config",ref Temperatureconfig, 1);
                }
                if (File.Exists(newdirectory + "\\Flowrate.config") == true)
                {
                    ReadConfig(newdirectory + "\\Flowrate.config", ref Flowrateconfig, 2);
                }
                if (File.Exists(newdirectory + "\\Telosb.config") == true)
                {
                    ReadConfig(newdirectory + "\\Telosb.config", ref Telosbconfig, 3);
                }
                if (File.Exists(newdirectory + "\\Boards.config") == true)
                {
                    ReadConfig(newdirectory + "\\Boards.config", ref Boardconfig, 4);
                }
            }

            textBoxFP1PPM_THRES.Text = "900";
            textBoxFP1PPM_HYST.Text = "300";
            textBoxFP1TEMP_THRES.Text = "30";
            textBoxFP1TEMP_HYST.Text = "2";
            textBoxFP2PPM_THRES.Text = "900";
            textBoxFP2PPM_HYST.Text = "300";
            textBoxFP2TEMP_THRES.Text = "30";
            textBoxFP2TEMP_HYST.Text = "2";
            textBoxFP3PPM_THRES.Text = "900";
            textBoxFP3PPM_HYST.Text = "300";
            textBoxFP3TEMP_THRES.Text = "30";
            textBoxFP3TEMP_HYST.Text = "2";
            textBoxFP4PPM_THRES.Text = "900";
            textBoxFP4PPM_HYST.Text = "300";
            textBoxFP4TEMP_THRES.Text = "30";
            textBoxFP4TEMP_HYST.Text = "2";

            threadCom1RecvEn = true;
            threadCom1Recv = new Thread(ThreadCom1Recv);
            threadCom1Recv.Start();

            threadCom2RecvEn = false;
            threadCom2Recv = new Thread(ThreadCom2Recv);

            threadComSendEn = true;
            threadComSend = new Thread(ThreadComSend);
            threadComSend.Start();

            textBoxSync.Text = SyncInterval.ToString();
            timerSync.Interval = SyncInterval * 60 * 1000;
            timerSync.Start();

            textBoxStrInterval.Text = StoreIterval.ToString();
            timerStore.Interval = StoreIterval * 1000;
            timerStore.Start();

            textBoxUpload.Text = UploadInterval.ToString();
            timerUpload.Interval = UploadInterval * 60 * 1000;
            timerUpload.Start();

            timerCheckStatus.Interval = 5 * 1000;
            timerCheckStatus.Start();
        }
Exemple #2
0
 private void buttonPort2_Click(object sender, EventArgs e)
 {
     threadCom2RecvEn = false;
     threadComSendEn = false;
     if(threadCom2Recv.IsAlive)
         threadCom2Recv.Join();
     if (threadComSend.IsAlive)
         threadComSend.Join();
     ComSet comset = new ComSet(ref this.ComPort2);
     comset.ShowDialog();
     if (ComPort2.IsOpen == true)
         ComPort2.DiscardInBuffer();
     ComPort2.ReadTimeout = 50;
     threadCom2RecvEn = true;
     threadCom2Recv = new Thread(ThreadCom2Recv);
     threadCom2Recv.Start();
     threadComSendEn = true;
     threadComSend = new Thread(ThreadComSend);
     threadComSend.Start();
 }