public MainWindow()
        {
            InitializeComponent();

            initConfig();

            sensorDatas = new ObservableCollection <SensorData>();
            for (int i = 0; i < config.Offsets.Length; i++)
            {
                sensorDatas.Add(new SensorData()
                {
                    Offset        = config.Offsets[i],
                    Scale         = config.Scales[i],
                    LogEnabled    = config.LogEnabled[i],
                    Name          = config.Names[i],
                    Lpf           = config.Lpf[i],
                    FilterEnabled = config.FilterEnabled[i],
                    Config        = config
                });
            }
            sensorDataList.DataContext = sensorDatas;
            pathText.DataContext       = config;
            filterGrid.DataContext     = config;

            portScanner             = new AdvancedPortScanner(115200, 1024, 3);
            portScanner.OnFindPort += PortScanner_OnFindPort;
            portScanner.Start();

            remoteTime       = new DateTime(0);
            secTick          = new Timer(500);
            secTick.Elapsed += SecTick_Elapsed;
            secTick.Start();

            isLogging = false;
        }
 private void PortScanner_OnFindPort(AdvancedPortScanner sender, PortScannerEventArgs e)
 {
     Debug.WriteLine("[main] find port {0}", e.Link.Port.PortName);
     link = e.Link;
     link.OnReceivePackage += Link_OnReceivePackage;
     link.OpenPort();
     portScanner.Stop();
 }