Пример #1
0
        public GSM_SMS()
        {
            //spDriver = new SerialPortDriver();
            spDriver = new SerialPortDriver(9600, 8, StopBits.One, Parity.None, Handshake.None);



            responseTimeout = int.Parse(ConfigurationSettings.AppSettings["ResponseTimeout"]);

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

            transactionEvent = new AutoResetEvent(false);

            _gsmSMSTrace = new TraceSource("GSM_SMSTrace");
            _gsmSMSTrace.Switch = new SourceSwitch("GSM_SMSTraceSwitch");


            String gsmSMSTraceFile = ConfigurationSettings.AppSettings["GSM_SMSTraceFile"];

            if (gsmSMSTraceFile != String.Empty && gsmSMSTraceFile!= null)
            {
                _gsmSMSTraceListener = new TextWriterTraceListener(gsmSMSTraceFile);
                _gsmSMSTrace.Listeners.Add(_gsmSMSTraceListener);
                _gsmSMSTrace.Switch.Level = SourceLevels.Information;
            }
            else
            {
                _gsmSMSTrace.Switch.Level = SourceLevels.Off;
            }
        }
Пример #2
0
        public GSM_SMS()
        {
            //spDriver = new SerialPortDriver();
            spDriver = new SerialPortDriver(9600, 8, StopBits.One, Parity.None, Handshake.None);



            responseTimeout = int.Parse(ConfigurationSettings.AppSettings["ResponseTimeout"]);

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

            transactionEvent = new AutoResetEvent(false);

            _gsmSMSTrace        = new TraceSource("GSM_SMSTrace");
            _gsmSMSTrace.Switch = new SourceSwitch("GSM_SMSTraceSwitch");


            String gsmSMSTraceFile = ConfigurationSettings.AppSettings["GSM_SMSTraceFile"];

            if (gsmSMSTraceFile != String.Empty && gsmSMSTraceFile != null)
            {
                _gsmSMSTraceListener = new TextWriterTraceListener(gsmSMSTraceFile);
                _gsmSMSTrace.Listeners.Add(_gsmSMSTraceListener);
                _gsmSMSTrace.Switch.Level = SourceLevels.Information;
            }
            else
            {
                _gsmSMSTrace.Switch.Level = SourceLevels.Off;
            }
        }
        public void start()
        {
            try
            {
            	if( simulation == "Yes")
            	{
            		simulationTimer.Start();
            		return;
            		
            	}
                spDriver.open(communicationPort);
                int i = 3;
                do
                {
                    if (spDriver.IsOpen == false)
                    {
                        spDriver.Close();
                        Thread.Sleep(500);
                    }
                } while (--i > 0);

                if (spDriver.IsOpen == false)
                throw new Exception("unable to open serial port");

                

                rxPacket = new List<byte>();
                partialPacket = new List<byte>();
                rxDataQ = new Queue<byte>();


                transactionTimer.Start();

            }
            catch (Exception e)
            {
                spDriver = null;
                throw new AndonManagerException("Unable to start Andon Manager:" + e.Message);
            }
        }
        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);
            }
        }
Пример #5
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);
            }
        }