using HslCommunication.BasicFramework;
using HybirdFrameworkCore.Autofac.Attribute;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Service.Charger.Msg.Host.Req
{
///
/// 3.7 远程升级-站级监控升级请求下发
///
public class UpgradeRequest : ASDU
{
///
/// 记录类型
///
[Property(0, 8)]
public byte RecordType { get; set; }
///
/// 执行控制 0x01:立即执行 0x02:空闲执行
///
[Property(8, 8)]
public byte ExecutionControl { get; set; }
///
/// 下载超时时间
///
[Property(16, 16)]
public byte DownloadTimeout { get; set; }
///
/// 版本号 ASCII 码
///
[Property(32, 24)]
public string VersionNumber { get; set; }
///
/// 文件名称 HEX
///
[Property(56, 160)]
public byte[] FileNameByte
{
get
{
return Enumerable.Range(0, FileName.Length / 2)
.Select(i => Convert.ToByte(FileName.Substring(i * 2, 2), 16))
.ToArray();
}
set { }
}
///
/// 文件名称 HEX
///
public string FileName { get; set; }
///
/// 文件大小 HEX
///
[Property(216, 32)]
public uint FileSize { get; set; }
///
/// MD5校验值 HEX
///
[Property(248, 128)]
public byte[] MD5VerificationByte
{
get
{
return Enumerable.Range(0, MD5Verification.Length / 2)
.Select(i => Convert.ToByte(MD5Verification.Substring(i * 2, 2), 16))
.ToArray();
}
set { }
}
public string MD5Verification { get; set; }
///
/// URL(文件路径)ASCII码
///
[Property(376, 1600)]
public string URL { get; set; }
///
///
///
/// 执行控制 0x01:立即执行 0x02:空闲执行
/// 下载超时时间
/// 版本号
/// 文件名称
/// 文件大小
/// MD5校验值
/// URL(文件路径)
public UpgradeRequest(byte executionControl, byte downloadTimeout, string versionNumber,
string fileName, uint fileSize, string mD5Verification, string url)
{
PackLen = 0;
CtlArea = 0;
SrcAddr = 0;
FrameTypeNo = 45;
MsgBodyCount = 1;
TransReason = 3;
PublicAddr = 0;
MsgBodyAddr = new byte[] { 0, 0, 0 };
RecordType = 33;
ExecutionControl = executionControl;
DownloadTimeout = downloadTimeout;
VersionNumber = versionNumber;
FileName = fileName;
FileSize = fileSize;
MD5Verification = mD5Verification;
URL = url;
}
}
}