Exemplo n.º 1
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            serialPort=new SerialPort();
             //   ledStripController=new LedStripController(serialPort);
            serialController=new SerialController(serialPort);
            db = new SQLiteRepository(serialController);
        }
Exemplo n.º 2
0
 public SQLiteRepository(SerialController serialController)
 {
     InitializeDB();
     ConnectToController(serialController);
 }
Exemplo n.º 3
0
        private void ConnectToController(SerialController serialController)
        {
            this.serialController = serialController;

            List<Message> messages = GetMessages();
            foreach (var message in messages)
                serialController.messagesLog.AddNewMessage(message);

            List<Node> nodes = GetNodes();
            foreach (var node in nodes)
                serialController.AddNode(node);

            serialController.messagesLog.OnClearMessages += OnClearMessages;
            serialController.OnClearNodesListEvent += OnClearNodesListEvent;

            if (storeLogMessages)
            {
                serialController.messagesLog.OnNewMessageLogged += OnNewMessage;
            }

            if (writeInterval == 0)
            {
                serialController.OnNewNodeEvent += AddOrUpdateNode;
                serialController.OnNodeUpdatedEvent += AddOrUpdateNode;
                serialController.OnNewSensorEvent += AddOrUpdateSensor;
                serialController.OnSensorUpdatedEvent += AddOrUpdateSensor;
            }
            else
            {
                serialController.OnNewNodeEvent += OnNodeUpdated;
                serialController.OnNodeUpdatedEvent += OnNodeUpdated;
                serialController.OnNewSensorEvent += OnSensorUpdated;
                serialController.OnSensorUpdatedEvent += OnSensorUpdated;

                updateDbTimer = new DispatcherTimer();
                updateDbTimer.Interval = TimeSpan.FromMilliseconds(writeInterval);
                updateDbTimer.Tick += UpdateDbTimer;
                updateDbTimer.Start();
            }
        }