static void testUnparsedMessages(Dispatcher dispatcher, Receiver receiver, dynamic config) { dispatcher.enqueueEvent(new UnparsedMessage("*450052.0#16[0099],2012-10-02 21:14:45,STS,DC=0,PC=0,LV=0.0,BV=3.2,BU=3.6,I=5.3,T=23.9,DU=0.0,RU=0.0,STORAGE,OK,#E3", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("*450052.0#16[0014],INVALID,#07", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("*450052.0#16[0009],OK,#9A", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("450052,000,2012-10-02 21:19:19,STS,DC=0,PC=0,LV=0.0,BV=3.2,BU=3.6,I=2.7,T=23.7,DU=0.0,RU=0.0,XYZ=-0.06:-0.22:0.94,#8C", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("450052,001,2012-10-02 21:20:01,A69-9001,30444,#B3", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("450052,032,2012-10-02 21:40:42,A69-1303,48823,#C5", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("450052,039,2012-10-02 21:42:17,A69-9001,30,444,#CA", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("*450052.0#16[0099],VR2C-69:450052,'VEMCO',MAP-113 [ 1105 1303 9001/9002 1420 1430 1601 1602 ],FW=0.0.25,HW=3,OK,#57", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("*450052.0#16[0125],2012-10-02 21:47:06,STS,DC=108,PC=1199,LV=0.0,BV=3.2,BU=3.6,I=5.3,T=23.1,DU=0.0,RU=0.1,XYZ=-0.06:-0.22:0.94,STOPPED,OK,#89", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("*450052.0#16[0053],232,SI=60,BL=U,BI=1,MA=U,FMT=SER SEQ UTC CS,OK,#8A", receiver, null, "450052", "VR2C-69", config)); dispatcher.enqueueEvent(new UnparsedMessage("this is some garbage", receiver, null, "450052", "VR2C-69", config)); }
/// <summary> /// Public constructor for the Receiver class. /// </summary> /// <param name="serialPort">The serial port object to which the receiver is connected</param> /// <param name="portName">The name of the port (i.e. COM1, COM2, etc.)</param> /// <param name="dispatcher">The event queue dispatcher where events generated by this class are sent</param> /// <remarks> /// After opening the port, the constructor calls the init() method which determines whether the hardware connect /// is, in fact, a VEMCO reciever and then proceeds to configure it. After returning, the constructor then instructs /// the receiver to start sending "Real Time" data. Finally the run() method is called and the objects stays in /// the run method until it shutdown() is called. With the exception of whether the class in run()ing or not, no state /// is maintained by the class. /// </remarks> public Receiver(string serialNumber, string model, Dispatcher dispatcher) { VEMCO_SerialNumber = serialNumber; VEMCO_Model = model; Dictionary<int, string> configFiles = new Dictionary<int, string>(); this.TTL = DEFAULT_TTL; this.serialPort = serialPort; this.portName = portName; this.dispatcher = dispatcher; //serialPort.Open(); encoder = null; //init(); if (encoder != null) { //this.textReader = new StreamReader(serialPort.BaseStream, serialPort.Encoding); //Object[] r = {"0"}; //write("RTMPROFILE", r); //write("START"); //Thread.Sleep(500); //while (serialPort.BytesToRead > 0) //{ // dispatcher.enqueueEvent(new NoteReceiver("Read: " + serialPort.ReadExisting(), // this, this.portName, this.VEMCO_SerialNumber, this.VEMCO_Model, this.encoder.encoderConfig)); //} //run(); dispatcher.enqueueEvent(new NewReceiver(this, this.portName, this.VEMCO_SerialNumber, this.VEMCO_Model, this.encoder.encoderConfig)); } else { ReceiverExceptions re = new ReceiverExceptions(this, "(FATAL) Failed to configure encoder during init().", true); //dispatcher.enqueueEvent(new ExcepReceiver(re,re.fatal, // this, "test port name", this.VEMCO_SerialNumber, this.VEMCO_Model, this.encoder.encoderConfig)); //serialPort.Close(); //throw re; } }