public AndonManager(Queue<int> stationList, Queue<int> departmentList , MODE mode)
        {
            try
            {
                responseTimeout = int.Parse(ConfigurationSettings.AppSettings["ResponseTimeout"]);
                this.mode = mode;

                transactionTimer = new System.Timers.Timer(responseTimeout);
                transactionTimer.Elapsed += new ElapsedEventHandler(transactionTimer_Elapsed);
                transactionTimer.AutoReset = false;

                simulation = ConfigurationSettings.AppSettings["SIMULATION"];

                if (simulation != "Yes")
                {
                    spDriver = new SerialPortDriver(19200,8,StopBits.One,Parity.None,Handshake.None);

                    communicationPort = ConfigurationSettings.AppSettings["PORT"];
            
                    
	                rs485Driver = new RS485Driver();
                    xbeeDriver = new XbeeDriver(XbeeDriver.COMMUNICATION_MODE.API_ESC);
                    xbeeIdentifier = ConfigurationSettings.AppSettings["XBeeIdentifier"];


                    //communicationPort = findXbeePort(xbeeIdentifier);   //find the port of xbee

                    //if (communicationPort == String.Empty)
                    //{
                    //    throw new AndonManagerException(" Error : Xbee Device Not Found ");
                    //}



	
	                stations = stationList;
	                departments = departmentList;
	
	                transactionQ = new Queue<TransactionInfo>();
                    
                    
                }
                else{
                	
                	simulationTimer = new System.Timers.Timer(2 * 1000);
                	simulationTimer.Elapsed += new ElapsedEventHandler(simulationTimer_Elapsed);
                    simulationTimer.AutoReset = false;
                	
                }

                _andonTrace = new TraceSource("andonTrace");
                _andonTrace.Switch = new SourceSwitch("andonTraceSwitch");


                String xbeeTraceFile = ConfigurationSettings.AppSettings["AndonTraceFile"];

                if (xbeeTraceFile != String.Empty)
                {
                    _andonTraceListener = new TextWriterTraceListener(xbeeTraceFile);
                    _andonTrace.Listeners.Add(_andonTraceListener);
                    _andonTrace.Switch.Level = SourceLevels.Information;
                }
                else
                {
                    _andonTrace.Switch.Level = SourceLevels.Off;
                }



            }
            catch (Exception e)
            {
                throw new AndonManagerException("Andon Manager Initialization Error:"+e.Message);
            }
        }
Ejemplo n.º 2
0
        public AndonManager(Queue<int> stationList, Queue<int> departmentList , MODE mode)
        {
            try
            {
                responseTimeout = int.Parse(ConfigurationSettings.AppSettings["ResponseTimeout"]);
                this.mode = mode;

                transactionTimer = new System.Timers.Timer(responseTimeout);
                transactionTimer.Elapsed += new ElapsedEventHandler(transactionTimer_Elapsed);
                transactionTimer.AutoReset = false;

                simulation = ConfigurationSettings.AppSettings["SIMULATION"];

                if (simulation != "Yes")
                {
                    spDriver = new SerialPortDriver(57600,8,StopBits.One,Parity.None,Handshake.None);

                    communicationPort = ConfigurationSettings.AppSettings["PORT"];
            
                    
	                rs485Driver = new RS485Driver();
                    xbeeDriver = new XbeeDriver(XbeeDriver.COMMUNICATION_MODE.API_ESC);
                    xbeeIdentifier = ConfigurationSettings.AppSettings["XBeeIdentifier"];


                    //communicationPort = findXbeePort(xbeeIdentifier);   //find the port of xbee

                    //if (communicationPort == String.Empty)
                    //{
                    //    throw new AndonManagerException(" Error : Xbee Device Not Found ");
                    //}



	
	                stations = stationList;
	                departments = departmentList;
	
	                transactionQ = new Queue<TransactionInfo>();
                    
                    
                }
                else{
                	
                	simulationTimer = new System.Timers.Timer(2 * 1000);
                	simulationTimer.Elapsed += new ElapsedEventHandler(simulationTimer_Elapsed);
                    simulationTimer.AutoReset = false;
                	
                }

                whID = Convert.ToInt32(ConfigurationSettings.AppSettings["WH_ID"]);
            }
            catch (Exception e)
            {
                throw new AndonManagerException("Andon Manager Initialization Error:"+e.Message);
            }
        }