Esempio n. 1
0
 private SerialPortService()
 {
     //this.receivers = new Dictionary<String, Receiver>();
     this.receivers = new ObservableCollection<Receiver>();
     if (dispatcher == null)
     {
         dispatcher = new Dispatcher();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// The constructor for the Database module.
        /// </summary>
        /// <param name="dispatcher">The Dispatcher this object will receive messages from.</param>
        public Database(Dispatcher dispatcher)
            : base(dispatcher)
        {
            var jsonParser = new JsonParser() { CamelizeProperties = false };
            this.config = jsonParser.Parse(System.IO.File.ReadAllText(DATABASE_CONFIG_FILE));

            if (config.database.use == "true")
            {
                host = config.database.host;
                db = config.database.name;
                user = config.database.user;
                pass = config.database.pass;
            }
            connectionString = "Server=" + host + ";Database=" + db + ";Uid=" + user + ";Pwd=" + pass + ";";
            updateSensorCalibrations(config);
            insertions = new List<string>();
            try
            {
                logWriter = new System.IO.StreamWriter(config.log_file, false);
            }
            catch (Exception e)
            { }
        }
Esempio n. 3
0
        /// <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(SerialPort serialPort, String portName, Dispatcher dispatcher)
        {
            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 RealTimeEvents.NoteReceiver("Read: " + serialPort.ReadExisting(),
                        this, this.portName, this.VEMCO_SerialNumber, this.VEMCO_Model, this.encoder.encoderConfig));
                }
                run();
                dispatcher.enqueueEvent(new RealTimeEvents.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 RealTimeEvents.ExcepReceiver(re,re.fatal, 
                    this, this.portName, this.VEMCO_SerialNumber, this.VEMCO_Model, this.encoder.encoderConfig));
                serialPort.Close();
                throw re;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="dispatcher">A reference to the running system real time event dispatcher.</param>
 public ConsoleLogger(Dispatcher dispatcher)
     : base(dispatcher)
 {
 }
Esempio n. 5
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public Decoder(Dispatcher dispatcher)
     : base(dispatcher)
 {
 }