コード例 #1
0
ファイル: CcuTask.cs プロジェクト: yuanzj/ReserchDownload
 private void InitTask()
 {
     mUpgradeStartReqTask.InitTask();
     mUpgradeRequestTask.InitTask();
     mUpgradeProcessReqTask.InitTask();
     mUpgradeMD5ReqTask.InitTask();
     mUpgradeEndReqTask.InitTask();
     if (mCcuStream != null)
     {
         mCcuStream.Dispose();
         mCcuStream.Close();
         mCcuStream = null;
     }
     mCcuEvent.Reset();
     mCcuStream      = new FileStream(this.mfilePath, FileMode.Open, FileAccess.Read);
     CCU_FILE_LENGTH = (int)mCcuStream.Length;
     byte[] mVersion = new byte[4];
     mVersion[0] = 0x10; //16
     mVersion[1] = 0x31; //49
     mVersion[2] = 0x01; //01
     mVersion[3] = 0xFF;
     mUpgradeRequestParam.firmVersion = mVersion;
     mUpgradeRequestParam.fileLen     = (int)CCU_FILE_LENGTH;
     //单个包的大小
     mUpgradeRequestParam.singlePackageLen = CCU_PACKAGE_SIZE_KB;//单位KB
     mUpgradeRequestParam.singleFrameLen   = CCU_FRAME_SIZE;
     //是否强制升级
     mUpgradeRequestParam.ForceUpgrade = Const.DO_UPGRADE;
     //MD5参数
     mUpgradeMD5ReqParam.FirmVersion = mVersion;
     mUpgradeMD5ReqParam.FileLen     = CCU_FILE_LENGTH;
     mUpgradeMD5ReqParam.FirmUpgrade = Const.DO_UPGRADE;
     mUpgradeMD5ReqParam.MD5         = MD5.getMD5(new FileStream(this.mfilePath, FileMode.Open, FileAccess.Read));
 }
コード例 #2
0
 private void TaskStatusNotify(object sender, string msg, int value, Task_Level level)
 {
     if (level == Task_Level.TASK_INIT)
     {
         mTaskStatus = Task_Level.TASK_INIT;
         mPcuUpgradeStartTask.InitTask();
         mPcuUpgradeProcessTask.InitTask();
         mPcuUpgradeDoneTask.InitTask();
         mPcuUpgradeRunningTask.InitTask();
         mPcuUpgradeRequestTask.InitTask();
         mPcuEvent.Reset();
         if (mPcuStream != null)
         {
             mPcuStream.Dispose();
             if (mPcuStream != null)
             {
                 mPcuStream.Close();
             }
             else
             {
                 mPcuStream = null;
             }
         }
         mPcuStream      = new FileStream(this.mfilePath, FileMode.Open, FileAccess.Read);
         PCU_FILE_LENGTH = (int)mPcuStream.Length;
     }
     else if (level == Task_Level.TASK_PROGRESS)
     {
         if (pcuProgressBarHandler != null)
         {
             ProgressArgs mArgs = new ProgressArgs();
             mArgs.percentage = value;
             pcuProgressBarHandler(sender, mArgs);
         }
     }
     else if (level == Task_Level.TASK_DONE)
     {
         if (TaskDoneHandler != null)
         {
             TaskArgs mArgs = new TaskArgs();
             mArgs.level = mTaskStatus;
             TaskDoneHandler(sender, mArgs);
         }
     }
 }