示例#1
0
        private void ReadRFID_Load(object sender, EventArgs e)
        {
            string[] ports = SerialPort.GetPortNames();

            Eclock eclock     = new Eclock();
            string serialPort = eclock.GetPort();

            foreach (var item in ports)
            {
                if (serialPort.Contains(item))
                {
                    comPortNumber = item;
                }
            }
            if (!String.IsNullOrEmpty(comPortNumber))
            {
                comPort = new SerialPort(comPortNumber, 9600, Parity.None, 8, StopBits.One);

                //var value = ReadID();
                //RFIDTags = value;

                if (backgroundWorker1.IsBusy != true)
                {
                    // Start the asynchronous operation.
                    backgroundWorker1.RunWorkerAsync();
                }
            }
            else
            {
                MessageBox.Show("Club Reader not detected.", "Error");
                this.Close();
            }
        }
示例#2
0
 private String ReadID()
 {
     try
     {
         Eclock eclock = new Eclock();
         //if (!comPort.IsOpen) comPort.Open();
         if (!String.IsNullOrEmpty(comPortNumber))
         {
             //String entryCollection = "12345678|14220397|12345678|12345678|12345678|12345678|12345678|12345678|15212437";
             //String[] entryList = entryCollection.Split('|');
             bool transmit = false;
             while (!transmit)
             {
                 //eclock.SendData("$Race$" + item + "#", commPort);
                 String inComingData = eclock.ReceiveData(comPort);
                 if (inComingData != "")
                 {
                     return(PrintData(inComingData));
                 }
                 else
                 {
                     //this.Close();
                     transmit = true;
                     backgroundWorker1.CancelAsync();
                 }
             }
         }
         return("");
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#3
0
        private void SyncEclock_Load(object sender, EventArgs e)
        {
            Eclock eclock     = new Eclock();
            string serialPort = eclock.GetPort();

            string[] ports    = SerialPort.GetPortNames();
            string   commPort = "";

            foreach (var item in ports)
            {
                if (serialPort.Contains(item))
                {
                    commPort = item;
                }
            }

            if (!String.IsNullOrEmpty(commPort))
            {
                eclock.InitializeEclock(commPort);
            }
            this.label1.Text = "E-CLOCK SYNC " + ActionType;

            if (DataStartIndex > 0)
            {
                this.txtCount.Text    = DataStartIndex.ToString();
                this.txtto.Text       = DataEndtIndex.ToString();
                this.lblCount.Visible = true;
                this.label2.Visible   = true;
                this.txtCount.Visible = true;
                this.txtto.Visible    = true;
            }
        }
示例#4
0
        private void UnLockEclock()
        {
            try
            {
                Eclock   eclock     = new Eclock();
                string   serialPort = eclock.GetPort();
                string[] ports      = SerialPort.GetPortNames();
                string   commPort   = "";

                foreach (var item in ports)
                {
                    if (serialPort.Contains(item))
                    {
                        commPort = item;
                    }
                }

                eclock.SendData("$UnLo$", commPort);
                this.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        private void SyncEntry()
        {
            try
            {
                Eclock   eclock     = new Eclock();
                string   serialPort = eclock.GetPort();
                string[] ports      = SerialPort.GetPortNames();
                string   commPort   = "";
                foreach (var item in ports)
                {
                    if (serialPort.Contains(item))
                    {
                        commPort = item;
                    }
                }

                //eclock.SyncTime(commPort);
                DataTable dt = new DataTable();
                dt = DataList;


                eclock.SendData("$Stat$", commPort);
                System.Threading.Thread.Sleep(1000);

                progressBar1.Maximum = dt.Rows.Count;
                System.Threading.Thread.Sleep(1000);

                int counter = 1;
                if (!String.IsNullOrEmpty(commPort))
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        String bandedData = "$Enty$" +
                                            ClubName + "|" +
                                            item["BandNumber"].ToString() + "|" +
                                            item["TagID"].ToString() + "|" +
                                            item["Category"].ToString() + "|" +
                                            item["Color"].ToString() + "|" +
                                            item["Sex"].ToString().Substring(0, 1) + "|#";

                        eclock.SendData(bandedData, commPort);
                        progressBar1.Value = counter;
                        System.Threading.Thread.Sleep(1000);
                        counter++;
                    }
                }

                eclock.SendData("$Done$|#", commPort);
                MessageBox.Show("Data sync", "Eclock Sync");
                this.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#6
0
        static void Main(string[] args)
        {
            Eclock eclock     = new Eclock();
            string serialPort = eclock.GetPort();

            string[] ports    = SerialPort.GetPortNames();
            string   commPort = "";

            Console.WriteLine("Start Uploading Eclock Program.");
            foreach (var item in ports)
            {
                if (serialPort.Contains(item))
                {
                    commPort = item;
                }
            }

            string userName        = Environment.UserName;
            string path            = AppDomain.CurrentDomain.BaseDirectory;
            string programFileName = path + "Eclock.ino.mega.hex";

            if (File.Exists(programFileName) && commPort != "")
            {
                Console.WriteLine("Program Uploading...");
                var uploader = new ArduinoSketchUploader(
                    new ArduinoSketchUploaderOptions()
                {
                    FileName     = programFileName,
                    PortName     = commPort,
                    ArduinoModel = ArduinoModel.Mega2560
                });

                uploader.UploadSketch();
                Console.WriteLine("Program Uploading Completed...");
            }
            else
            {
                if (commPort == "")
                {
                    Console.WriteLine("Check E-Clock connection.");
                }
                else
                {
                    Console.WriteLine("Program File Missing.");
                }
            }
        }
示例#7
0
        private void SyncTime()
        {
            Eclock eclock     = new Eclock();
            string serialPort = eclock.GetPort();

            string[] ports    = SerialPort.GetPortNames();
            string   commPort = "";

            foreach (var item in ports)
            {
                if (serialPort.Contains(item))
                {
                    commPort = item;
                }
            }

            if (!String.IsNullOrEmpty(commPort))
            {
                eclock.SyncTime(commPort);
            }
        }
示例#8
0
        private static void GetResult(string action)
        {
            try
            {
                Eclock   eclock        = new Eclock();
                string   serialPort    = eclock.GetPort();
                string[] ports         = SerialPort.GetPortNames();
                string   comPortNumber = "";
                string   rtype         = "";

                if (action == "TRAINING")
                {
                    rtype = "T";
                }

                foreach (var item in ports)
                {
                    if (serialPort.Contains(item))
                    {
                        comPortNumber = item;
                    }
                }

                SerialPort comPort = new SerialPort(comPortNumber, 9600, Parity.None, 8, StopBits.One);
                if (!String.IsNullOrEmpty(comPortNumber))
                {
                    DataPath = DataPath.Trim();
                    string entryDirectory = DataPath + "entry\\" + DateRelease;
                    string filepath       = entryDirectory + "\\" + MemberID + ".txt";

                    if (File.Exists(filepath))
                    {
                        string[] entryCollection = ReadText.ReadTextFile(filepath);

                        string resultDirectory = DataPath + "result\\" + DateRelease;
                        string memberDirectory = resultDirectory + "\\" + MemberID;
                        string filepathList    = resultDirectory + "\\" + MemberID + ".txt";

                        if (File.Exists(filepathList))
                        {
                            File.Delete(filepathList);
                        }

                        eclock.SendData("$Stat$", comPort);
                        System.Threading.Thread.Sleep(1000);

                        foreach (var item in entryCollection)
                        {
                            bool transmit = false;
                            while (!transmit)
                            {
                                //eclock.SendData(, comPort);
                                String inComingData = eclock.ReceiveDataResult("$Race$" + rtype + item + "#", comPort);
                                if (inComingData != "")
                                {
                                    PrintData(inComingData, item);
                                    //eclock.SendData("Done" + item + "#", commPort);
                                    transmit = true;
                                }
                            }
                        }

                        eclock.SendData("$Done$|#", comPort);
                    }
                }
                //Console.ReadLine();
                Console.WriteLine("Result Sync Completed....");
                System.Threading.Thread.Sleep(2000);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (ActionType == "BANDED")
                {
                    DataStartIndex = Convert.ToInt32(this.txtCount.Text);
                    DataEndtIndex  = Convert.ToInt32(this.txtto.Text);
                    SyncBanded();
                }
                else if (ActionType == "ENTRY")
                {
                    DataStartIndex = Convert.ToInt32(this.txtCount.Text);
                    DataEndtIndex  = Convert.ToInt32(this.txtto.Text);
                    SyncEntry();
                }
                else if (ActionType == "UNLOCK")
                {
                    UnLockEclock();
                }
                else if (ActionType == "ENTRYDB")
                {
                    SyncEntryInDatabase();
                }
                else if (ActionType == "RESULTDB")
                {
                    SyncResultInDatabase();
                }
                else if (ActionType == "RESULTRACE")
                {
                    SyncResult(ActionType);
                }
                else if (ActionType == "RESULTTRAINING")
                {
                    SyncResult(ActionType);
                }
                else if (ActionType == "UPLOADPROGRAM")
                {
                    string path    = AppDomain.CurrentDomain.BaseDirectory + "ProgramLoader";
                    var    process = Process.Start(path + "\\ConsoleApp1.exe");
                    process.WaitForExit();
                    var exitCode = process.ExitCode;
                    this.Close();
                }
                else if (ActionType == "RESET")
                {
                    Eclock   eclock     = new Eclock();
                    string   serialPort = eclock.GetPort();
                    string[] ports      = SerialPort.GetPortNames();
                    string   commPort   = "";
                    foreach (var item in ports)
                    {
                        if (serialPort.Contains(item))
                        {
                            commPort = item;
                        }
                    }

                    if (commPort != "")
                    {
                        eclock.SyncTime(commPort);
                    }
                    this.Close();
                }
                else if (ActionType == "CLOCK")
                {
                    Eclock   eclock     = new Eclock();
                    string   serialPort = eclock.GetPort();
                    string[] ports      = SerialPort.GetPortNames();
                    string   commPort   = "";
                    foreach (var item in ports)
                    {
                        if (serialPort.Contains(item))
                        {
                            commPort = item;
                        }
                    }

                    if (commPort != "")
                    {
                        eclock.SyncTime(commPort);
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                Common.Logs(ex.Message);
            }
        }
示例#10
0
        private void SyncBanded()
        {
            Eclock eclock     = new Eclock();
            string serialPort = eclock.GetPort();

            string[] ports    = SerialPort.GetPortNames();
            string   commPort = "";

            foreach (var item in ports)
            {
                if (serialPort.Contains(item))
                {
                    commPort = item;
                }
            }

            if (!String.IsNullOrEmpty(commPort))
            {
                //eclock.SyncTime(commPort);
                DataTable dt = new DataTable();
                dt = DataList;

                eclock.SendData("$Stat$", commPort);
                progressBar1.Maximum = dt.Rows.Count;
                System.Threading.Thread.Sleep(2500);

                int counter = 1;
                foreach (DataRow item in dt.Rows)
                {
                    if (counter >= DataStartIndex && counter <= DataEndtIndex)
                    {
                        string path = ReadText.ReadFilePath("datapath");
                        string pigeonMobileListPath = path + "\\PigeonMobileList\\" + item["TagID"].ToString() + ".txt";
                        string mobileNumber         = "";
                        if (File.Exists(pigeonMobileListPath))
                        {
                            string[] pigeonMobileCollection = ReadText.ReadTextFile(pigeonMobileListPath);
                            string[] values = pigeonMobileCollection[0].ToString().Split('|');
                            mobileNumber = values[1].ToString().Trim();
                        }

                        String bandedData = "$BaNd$" +
                                            ClubName + "|" +
                                            item["BandNumber"].ToString() + "|" +
                                            item["TagID"].ToString() + "|" +
                                            item["Category"].ToString() + "|" +
                                            item["Color"].ToString() + "|" +
                                            item["Sex"].ToString().Substring(0, 1) + (mobileNumber != "" ? "|" + mobileNumber + "|#" : "|#");

                        eclock.SendData(bandedData, commPort);
                        this.txtCount.Text = counter.ToString();
                        System.Threading.Thread.Sleep(2500);
                    }

                    progressBar1.Value = counter;
                    counter++;
                }

                eclock.SendData("$Done$|#", commPort);
                MessageBox.Show("Data sync", "Eclock Sync");
                this.Close();
            }
        }