Exemplo n.º 1
0
        private void SerialportWatcher_SerialPortsChangedEvent(bool aInserted, SerialportWatcher.PortInfo aChangedPort)
        {
            this.UIThread(() =>
            {
                var qport = SerialportWatcher.GetPorts(SerialportWatcher.PortKind.QDLoader);
                if (qport.Count > 0)
                {
                    this.CurrentPort = qport[0];
                    Log.i("QDLoader port is presented ({0})", this.CurrentPort.Name);
                }
                else
                {
                    var dport = SerialportWatcher.GetPorts(SerialportWatcher.PortKind.Serial);
                    if (dport.Count > 0)
                    {
                        if (this.CurrentPort.Kind != SerialportWatcher.PortKind.Serial)
                        {
                            this.CurrentPort = dport[0];
                        }
                        else if (aInserted == false && this.CurrentPort.Equals(aChangedPort)) // 제거 시 갱신
                        {
                            this.CurrentPort = dport[0];
                        }

                        Log.i("Debug port is presented ({0})", this.CurrentPort.Name);
                    }
                    else
                    {
                        if (this.CurrentPort.Kind != SerialportWatcher.PortKind.None)
                        {
                            this.CurrentPort = new SerialportWatcher.PortInfo();
                        }
                        Log.i("Port is none");
                    }
                }
                InvokePropertyChanged("PortListVisible");
            });
        }
Exemplo n.º 2
0
        Timer SendDebugtimer = new System.Timers.Timer(); // jwoh add User/Factory mode

        private void SerialportWatcher_SerialPortsChangedEvent(bool aInserted, SerialportWatcher.PortInfo aChangedPort)
        {
            this.UIThread(() =>
            {
                if (this.FbMode == FBMode.None)
                {
                    if (aInserted)
                    {
                        if (aChangedPort != null)
                        {
                            if (aChangedPort.Kind == SerialportWatcher.PortKind.Diagnostic ||
                                aChangedPort.Kind == SerialportWatcher.PortKind.QDLoader)
                            {
                                var titem         = new TargetItem(_id, this);
                                titem.CurrentPort = aChangedPort;
                                this.TargetItems.Add(titem);
                                Log.i("ADD Target Items1: ID:{0}, Port:{1}", _id, titem.CurrentPort.Caption);
                                UpdateJobList(titem);
                                _id++;
                                // jwoh add User/Factory mode [
                                if ((this.SelBoard == 1) && (this.DLEndpopup == false) && (this.IsIdle))
                                {
                                    SendDebugtimer.Interval = 800;
                                    SendDebugtimer.Elapsed += new ElapsedEventHandler(timer_SendDebugon);
                                    SendDebugtimer.Start();
                                } // jwoh add User/Factory mode ]
                            }
                        }
                        else
                        {
                            foreach (var port in SerialportWatcher.Ports)
                            {
                                if (port.Kind == SerialportWatcher.PortKind.Diagnostic ||
                                    port.Kind == SerialportWatcher.PortKind.QDLoader)
                                {
                                    var titem         = new TargetItem(_id, this);
                                    titem.CurrentPort = port;
                                    this.TargetItems.Add(titem);
                                    Log.i("ADD Target Items2: ID:{0}, Port:{1}", _id, titem.CurrentPort.Caption);
                                    _id++;
                                    // jwoh add User/Factory mode [
                                    if ((this.SelBoard == 1) && (this.DLEndpopup == false) && (this.IsIdle))
                                    {
                                        if (this.FdebugOn)
                                        {
                                            titem.FileProgress = 100;
                                        }
                                        SendDebugtimer.Interval = 800;
                                        SendDebugtimer.Elapsed += new ElapsedEventHandler(timer_SendDebugon);
                                        SendDebugtimer.Start();
                                    } // jwoh add User/Factory mode [
                                }
                            }
                            UpdateJobList();
                        }
                        this.DownloadCommand.RaiseCanExecuteChanged();
                        InvokePropertyChanged("CanEfsBackup");
                    }
                    else // removed
                    {
                        if (aChangedPort != null)
                        {
                            var item = this.TargetItems.FirstOrDefault(x => x.MatchPort(aChangedPort));
                            if (item != null && item.Id >= 0) // valid
                            {
                                this.TargetItems.Remove(item);
                                // jwoh add User/Factory mode [
                                if ((this.SelBoard == 1) && (this.ChangedDebugPort.Count > 0))
                                {
                                    item.Print(LogLevels.Error, "===== DebugOff Port List Remove {0} =====", item.CurrentPort.Name);
                                    this.ChangedDebugPort.RemoveAll(ditem => ditem == item.CurrentPort.Name);
                                    if (this.ChangedDebugPort.Count == 0)
                                    {
                                        this.FdebugOn = false;
                                    }
                                } // jwoh add User/Factory mode [
                                Log.i("REMOVE Target Items: ID:{0}, Port:{1}", item.Id, item.CurrentPort.Caption);
                                _id--; // jwoh
                                this.DownloadCommand.RaiseCanExecuteChanged();
                            }
                        }
                    }
                }
                else // busy state
                {
                    if (aChangedPort != null)
                    {
                        lock (TargetItem._so)
                        {
                            Log.i("{0} Port:{1}", aInserted ? "ADD1" : "REMOVE1", aChangedPort.Caption);
                        }
                        foreach (var ti in this.TargetItems)
                        {
                            ti.UpdatedTargetPort(aChangedPort, aInserted);
                        }
                    }
                }
            });
        }
Exemplo n.º 3
0
 public PortSelect(EmergencyModel aModel, SerialportWatcher.PortInfo aPort)
 {
     _model = aModel;
     Port   = aPort;
 }
Exemplo n.º 4
0
 public PortSelect(DumpModel aModel, SerialportWatcher.PortInfo aPort)
 {
     _model = aModel;
     Port   = aPort;
 }