Beispiel #1
0
        public void Loop()
        {
            //LogThis.LogWriter("Looping started");
                        LogThis.Report("Engine", "Looping started");
                        while (! RequestedToStop)
                            {
                                Thread.Sleep(500);
                                rfid = new Rfid(); // this also starts the event that in turn adds the RFID to the queue
                                // loops untill told to stop by boolean
                                // rfid event handler component thread

                                for (var i = 0; i < QueueOfRfids.Count; i++)
                                    {

                                        if (rfid.rfid.Equals(rfid.DiagnosticID))
                                            {
                                                Speaker sp = new Speaker(Language.Country.eng);
                                                sp.Speak("Engine loop is running nicely, last processed rfid is: " + lastUsedRfid);
                                            }
                                        else
                                            {
                                            // if its not a diagnostic scan tag, do this.
                                            lastUsedRfid = QueueOfRfids.Last();
                                            }
                                        dataFetcher = new FetchData(new ClientData());
                                        Config = new FlexConfig(true);
                                        CurrentUsersProfile = Config.GetProfile(dataFetcher.GetClientData().UserName);
                                        clientStatus = new DetermineStatus(dataFetcher.GetClientData());
                                    }

                                // Database information gathering based on the result off the rfid event (10 char long string)
                                // on completed database read interaction
                            }
                        // sjekk RFID event
        }
Beispiel #2
0
        private void DataRecievedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            // returns the ID read from tag, provides easteregg.

                        var serp = (SerialPort) sender;
                        //var dbm = new DatabaseManager();

                        //var DiagnosticID = "4510720867";
                        const string blueOysterId = "4519992145";

                        rfid = serp.ReadExisting().Trim();

                        //Console.WriteLine(rfid);
                        if (rfid == DiagnosticID)
                            {
                                // Play blue oyster soundtrack.
                                //Console.WriteLine("Dun duu du du duuu duu duuu");
                                Diagnostic = true;
                                if (Diagnostic)
                                    {
                                        //	PrintDiagnosticData(DiagnosticID);
                                        // TODO: Add diagnostic audiofeedback
                                        Speaker sp = new Speaker(Language.Country.eng);
                                        sp.Speak("Starting diagnostic run.");
                                    }
                            }
                        else if (rfid == blueOysterId)
                            {
                                var ap = new AudioPlayer("Blue Oyster Bar.wav");
                                ap.Play();
                            }
                        else
                            {
                                Engine.QueueOfRfids.Enqueue(rfid);
                            }
        }