Exemple #1
0
        private Task GetDuiShiTask(ITaskManage iTaskManage)
        {
            Task task = new Task();

            task.MeterMac  = this.MAC;
            task.TaskDate  = DateTime.Now;
            task.TaskID    = Guid.NewGuid().ToString(); //用于和指令进行进行关联
            task.TaskState = TaskState.Waitting;
            task.TaskType  = TaskType.TaskType_校时;      //点火任务(DH),换表登记(HB)、开阀(KF)、关阀(GF)、充值(CZ)、调整价格(TJ)

            Command cmd = new Command();
            //1.校时
            byte          ser       = this.meter.LastTopUpSer; // Convert.ToByte(new Random().Next(0, 255));
            DataItem_A015 item_A015 = new DataItem_A015(ser);  //

            cmd.TaskID         = task.TaskID;
            cmd.Identification = ((UInt16)item_A015.IdentityCode).ToString("X2");
            cmd.ControlCode    = (byte)ControlCode.WriteData;//写操作
            cmd.DataLength     = Convert.ToByte(item_A015.Length);
            cmd.DataCommand    = MyDataConvert.BytesToHexStr(item_A015.GetBytes());
            cmd.Order          = 1;
            task.CommandList.Add(cmd);
            iTaskManage.SetDuiShiTask(task, cmd);
            return(task);
        }
Exemple #2
0
        /// <summary>
        /// 主站请求写数据对象
        /// </summary>
        /// <param name="buffer"></param>
        /// <returns></returns>
        private DataItem getWriteDataAskItem(byte[] buffer)
        {
            IdentityCode identityCode = MyDataConvert.get数据表示符(buffer);
            DataItem     item         = null;

            switch (identityCode)
            {
            case IdentityCode.写价格表:
                item = new DataItem_A010(buffer);
                break;

            case IdentityCode.写结算日:
                item = new DataItem_A011(buffer);
                break;

            case IdentityCode.写购入金额:
                item = new DataItem_A013(buffer);
                break;

            case IdentityCode.写新密钥:
                item = new DataItem_A014(buffer);
                break;

            case IdentityCode.写标准时间:
                item = new DataItem_A015(buffer);
                break;

            case IdentityCode.写阀门控制:
                item = new DataItem_A017(buffer);
                break;

            case IdentityCode.出厂启用:
                item = new DataItem_A019(buffer);
                break;

            case IdentityCode.写地址:
                item = new DataItem_A018(buffer);
                break;

            case IdentityCode.写表底数:
                item = new DataItem_A016(buffer);
                break;

            default:
                break;
            }

            return(item);
        }