예제 #1
0
 /// <summary>
 /// Generated for faults that occur without a prior exception being generated.
 /// </summary>
 /// <param name="fatal">Set to true if the fault requires the serial port to be closed.</param>
 /// <param name="text">Reason for failure (human readable)</param>
 /// <param name="receiver">The Receiver object associated with the VEMCO hardware.</param>
 public ReceiverExceptions(Receiver receiver, string text, Boolean fatal)
 {
     this.fatal = fatal;
     this.text = text;
     this.receiver = receiver;
     this.originatingException = null;
 }
 /// <summary>
 /// Constructor when an Exception has been or will be thrown.
 /// </summary>
 /// <param name="re">The corresponding Exception</param>
 /// <param name="fatal">Set to true if the fault requires the serial port to be closed.</param>
 /// <param name="receiver">The Receiver object associated with the VEMCO hardware.</param>
 /// <param name="portName">The name of the serial port it is connected to (i.e. COM1)</param>
 /// <param name="serialNumber">The serial number of the receiver.</param>
 /// <param name="model">The model of the receiver.</param>
 /// <param name="config">The json object for the configration file.</param>
 public ExcepReceiver(Exception re, Boolean fatal, Receiver receiver, string portName, string serialNumber, string model, FridayThe13th.JsonObject config)
     : base("Receiver Exception: " + receiver + "entered exception condition. Fatal? " + fatal + 
      " Exception text: " + re.ToString(), receiver, portName, serialNumber, model, config)
 {
     this["exception"] = re;
     this["fatal"] = fatal;
     this["note"] = re.ToString();
 }
예제 #3
0
        static void Main(string[] args)
        {
            var jsonParser = new JsonParser() { CamelizeProperties = false };
            dynamic config = jsonParser.Parse(System.IO.File.ReadAllText("config.txt"));
            Dispatcher dispatcher = new Dispatcher();
            Database database = new Database(dispatcher, config);
            Decoder decoder = new Decoder(dispatcher);
            Receiver receiver = new Receiver("450052", "VR2C-69", dispatcher);
            Encoder encoder = new Encoder("*450052.0#16,", config);
            ConsoleLogger consoleLogger = new ConsoleLogger(dispatcher);
            dispatcher.addModule(database);
            dispatcher.addModule(decoder);
            dispatcher.addModule(consoleLogger);
            dispatcher.run();

            testUnparsedMessages(dispatcher, receiver, config);
            //testEncoder(encoder);
            //testDecoder(decoder);
            //testDatabase(database);
        }
예제 #4
0
 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>
 /// Default constructor.
 /// </summary>
 /// <param name="receiver">The Receiver object associated with the VEMCO hardware.</param>
 /// <param name="portName">The name of the serial port it is connected to (i.e. COM1)</param>
 /// <param name="serialNumber">The serial number of the receiver.</param>
 /// <param name="model">The model of the receiver.</param>
 /// <param name="config">The json object for the configration file.</param>
 public NewReceiver(Receiver receiver, string portName, string serialNumber, string model, FridayThe13th.JsonObject config)
     : base("Receiver mounted on " + receiver.portName, receiver, portName, serialNumber, model,config)
 {
 }
 /// <summary>
 /// Constructor when no Exception has been or will be thrown.
 /// </summary>
 /// <param name="fatal">Set to true if the fault requires the serial port to be closed.</param>
 /// <param name="text">Reason for failure (human readable)</param>
 /// <param name="receiver">The Receiver object associated with the VEMCO hardware.</param>
 /// <param name="portName">The name of the serial port it is connected to (i.e. COM1)</param>
 /// <param name="serialNumber">The serial number of the receiver.</param>
 /// <param name="model">The model of the receiver.</param>
 /// <param name="config">The json object for the configration file.</param>
 public ExcepReceiver(Boolean fatal, string text, Receiver receiver, string portName, string serialNumber, string model, FridayThe13th.JsonObject config)
     : base("Receiver Error: " + receiver.portName + " entered exceptional condition. Fatal: " + fatal, receiver, portName, serialNumber, model, config)
 {
     this["fatal"] = fatal;
     this["note"] = text;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="receiver">The Receiver object associated with the VEMCO hardware.</param>
 /// <param name="portName">The name of the serial port it is connected to (i.e. COM1)</param>
 /// <param name="serialNumber">The serial number of the receiver.</param>
 /// <param name="model">The model of the receiver.</param>
 /// <param name="config">The json object for the configration file.</param>
 /// <param name="unparsedMessage">The String of the unparsed message.</param>
 public UnparsedMessage( String unparsedMessage, Receiver receiver, string portName, string serialNumber, string model, FridayThe13th.JsonObject config)
     : base(unparsedMessage + " from receiver on " /*+ receiver.portName*/, receiver, portName, serialNumber, model, config)
 {
     this["unparsedmessage"] = unparsedMessage;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="message">This should be some human readable text about why the event is being generated.</param>
 /// <param name="receiver">The Receiver object associated with the VEMCO hardware.</param>
 /// <param name="portName">The name of the serial port it is connected to (i.e. COM1)</param>
 /// <param name="serialNumber">The serial number of the receiver.</param>
 /// <param name="model">The model of the receiver.</param>
 /// <param name="config">The json object for the configration file.</param>
 public ReceiverEvent(string message, Receiver receiver, string portName, string serialNumber, string model, FridayThe13th.JsonObject config)
     : base(message, null)
 {
     this["receiver"] = receiver;
     this["portname"] = portName;
     this["serialnumber"] = serialNumber;
     this["model"] = model;
     this["configuration"] = config;
 }
 /// <param name="text">Human readable string of noteworthy information.</param>
 /// <param name="receiver">The Receiver object associated with the VEMCO hardware.</param>
 /// <param name="portName">The name of the serial port it is connected to (i.e. COM1)</param>
 /// <param name="serialNumber">The serial number of the receiver.</param>
 /// <param name="model">The model of the receiver.</param>
 /// <param name="config">The json object for the configration file.</param>
 public NoteReceiver(string text, Receiver receiver, string portName, string serialNumber, string model, FridayThe13th.JsonObject config)
     : base("NOTE[" + "PORT: " + receiver.portName + " SERIAL NUMBER: " + serialNumber + "MODEL: " + model + "] " + text, receiver, portName, serialNumber, model, config)
 {
     this["note"] = text;
 }