Exemplo n.º 1
0
 public SerialPortForm(SerialPortParameter _param)
 {
     InitializeComponent();
     mParam = _param;
 }
Exemplo n.º 2
0
        private void MainFrm_Load(object sender, EventArgs e)
        {
            //版本号
            this.Text    = String.Format("串口升级工具 V{0}", AssemblyFileVersion());
            mTaskParam   = new TaskParameters();
            mSerialParam = new SerialPortParameter();
            mPcuItem     = new ListViewItem();
            mPcuItem.UseItemStyleForSubItems = false;
            mCcuItem = new ListViewItem();
            mCcuItem.UseItemStyleForSubItems = false;
            //加载配置文件
            LoadSetting();
            mTaskManager = new TaskManager(mTaskParam);
            //设置参数
            ccuProgressBar.Value                = 0;
            ccuProgressBar.Maximum              = 100;
            pcuProgressBar.Value                = 0;
            pcuProgressBar.Maximum              = 100;
            mTaskManager.ccuProgressBarHandler += (object _sender, EventArgs _e) =>
            {
                ProgressArgs mArgs = _e as ProgressArgs;
                if (mArgs != null)
                {
                    UpdateCcuProgressBar(mArgs.percentage);
                }
            };
            mTaskManager.pcuProgressBarHandler += (object _sender, EventArgs _e) =>
            {
                ProgressArgs mArgs = _e as ProgressArgs;
                if (mArgs != null)
                {
                    UpdatePcuProgressBar(mArgs.percentage);
                }
            };
            mTaskManager.ccuListViewItemHandler += (object _sender, EventArgs _e) =>
            {
                TaskArgs mArgs = _e as TaskArgs;
                if (mArgs != null)
                {
                    UpdateCcuItems(mArgs.msg, mArgs.level);
                }
            };

            mTaskManager.pcuListViewItemHandler += (object _sender, EventArgs _e) =>
            {
                TaskArgs mArgs = _e as TaskArgs;
                if (mArgs != null)
                {
                    UpdatePcuItems(mArgs.msg, mArgs.level);
                }
            };

            CcuTimeCounts              = 0;
            CcuTestTimeTicker          = new System.Timers.Timer(1000);
            CcuTestTimeTicker.Enabled  = false;
            CcuTestTimeTicker.Elapsed += new ElapsedEventHandler((object source, ElapsedEventArgs ElapsedEventArgs) =>
            {
                CcuTimeCounts++;
                SetTimeTicker(Devices.CCU, CcuTimeCounts);
            });

            PcuTimeCounts              = 0;
            PcuTestTimeTicker          = new System.Timers.Timer(1000);
            PcuTestTimeTicker.Enabled  = false;
            PcuTestTimeTicker.Elapsed += new ElapsedEventHandler((object source, ElapsedEventArgs ElapsedEventArgs) =>
            {
                PcuTimeCounts++;
                SetTimeTicker(Devices.PCU, PcuTimeCounts);
            });

            string msg = String.Format("当前串口:{0} ",
                                       Const.COM_PORT);

            UpdateStatusBar(0, msg, "");

            this.toolStripBtn_Stop.Enabled = false;
        }