示例#1
0
        public Magazine_Driver(LabManager.LabManager parent, int nMagazine_ID)
        {
            _nMagazine_ID = nMagazine_ID;
             _parent = parent;

             myMagazineHelper = new MagazineHelper(_nMagazine_ID);

             string IniFilePath = myDef.LanguageFile;
             myIniHandler = IniStructure.ReadIni(IniFilePath);

              //  _parent.InsertLoggingEntry((int)Definition.ThorLogWindows.ROUTING, "starting magazine '" + myMagazineHelper.GetMagazineName() + "' ");
             string strStarting = String.Format(myIniHandler.GetValue("Magazine", "StartMagazineInit"), myMagazineHelper.GetMagazineName());

             WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strStarting, (int)Definition.Message.D_MESSAGE);

             UpdateMagazine();

             // Hook up the Elapsed event for the timer.
             MagazineDriverTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

             // Set the Interval to 1 seconds (1000 milliseconds).
             MagazineDriverTimer.Interval = 1000;
             MagazineDriverTimer.Enabled = true;

             if (myMagazineHelper.GetOutputPosition() == -1 || myMagazineHelper.GetMachine_ID() == -1)
             {
                 string strCorruptConf = String.Format(myIniHandler.GetValue("Magazine", "CorruptConfiguration"), myMagazineHelper.GetOutputPosition(), myMagazineHelper.GetMachine_ID());
                 WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strCorruptConf, (int)Definition.Message.D_ALARM);
             }

             // Keep the timer alive until the end of Main.
              //GC.KeepAlive(MagazineDriverTimer);
        }
示例#2
0
        public int SendCommand(int nCommandNumber, int nSample_ID, int nPos, int nMachine_ID)
        {
            int nRet = -1;
            myMagazineHelperCommand = new MagazineHelper(_nMagazine_ID);

            switch (nCommandNumber)
            {
                case 1:
                    {// insert
                         try
                        {
                            InsertSample(nSample_ID, myMagazineHelperCommand.GetForceFIFO(), nPos, nMachine_ID, false);
                            string strNoPos = String.Format(myIniHandler.GetValue("Magazine", "InsertSample"), myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID), nSample_ID, myMagazineHelperCommand.GetMagazineName());
                            WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strNoPos, (int)Definition.Message.D_DEBUG);
                        }
                        catch (Exception ex) { WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, ex.ToString(), (int)Definition.Message.D_ALARM); }
                        break;
                    }

                case 2:
                    { // delete
                        try{
                             DeleteSample(nSample_ID);
                        }
                        catch (Exception ex) { WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, ex.ToString(), (int)Definition.Message.D_ALARM); }

                            string strNoPos = String.Format(myIniHandler.GetValue("Magazine", "DeletedSample"), nSample_ID);
                            WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strNoPos, (int)Definition.Message.D_DEBUG);

                        break;
                    }

                case 3:
                    {
                        // force sortorder ON
                        try
                        {
                            ForceSortOrderForSample(nSample_ID, 1);
                        }
                        catch (Exception ex) { WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, ex.ToString(), (int)Definition.Message.D_ALARM); }

                        string strForceSortOrder = String.Format(myIniHandler.GetValue("Magazine", "ForceSortOrderSample"), nSample_ID, "ON");
                        WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strForceSortOrder, (int)Definition.Message.D_DEBUG);
                        break;
                    }
                case 4:
                    {
                        // force sortorder OFF
                        try
                        {
                            ForceSortOrderForSample(nSample_ID, 0);
                        }
                        catch (Exception ex) { WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, ex.ToString(), (int)Definition.Message.D_ALARM); }

                        string strForceSortOrder = String.Format(myIniHandler.GetValue("Magazine", "ForceSortOrderSample"), nSample_ID, "OFF");
                        WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strForceSortOrder, (int)Definition.Message.D_DEBUG);
                        break;
                    }
                case 5:
                    {// putsample back
                        try
                        {
                                // the "put back flag" is set so "MagazineDoneFlag" in table "sample_active" is set
                            InsertSample(nSample_ID, myMagazineHelperCommand.GetForceFIFO(), nPos, nMachine_ID, true);
                            string strNoPos = String.Format(myIniHandler.GetValue("Magazine", "SampleReturn"), myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID), nSample_ID, myMagazineHelperCommand.GetMagazineName());
                            WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strNoPos, (int)Definition.Message.D_DEBUG);
                        }
                        catch (Exception ex) { WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, ex.ToString(), (int)Definition.Message.D_ALARM); }
                        break;
                    }
                 case 6:
                    {// reactivate sample (run duplicate sample)
                        try
                        {
                            // the "MagazineDoneFlag" will be mset to 0 -  in table "sample_active"
                            // the sample ID will be set to "D#" + "OLDSAMPLEID" to indicate that this one is a second try to get sample results
                            ReactivateSample(nSample_ID);
                            string strNoPos = String.Format(myIniHandler.GetValue("Magazine", "SampleDuplicate"), myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID), nSample_ID, myMagazineHelperCommand.GetMagazineName());
                            WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strNoPos, (int)Definition.Message.D_DEBUG);
                        }
                        catch (Exception ex) { WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, ex.ToString(), (int)Definition.Message.D_ALARM); }
                        break;
                    }

                default:
                    string strUnknownCommand = String.Format(myIniHandler.GetValue("Magazine", "UnknownCommand"), nCommandNumber.ToString());
                    WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strUnknownCommand , (int)Definition.Message.D_ALARM);
                    break;
            }

            return nRet;
        }