58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using RCUHost.Protocols;
|
|||
|
|
using System.IO;
|
|||
|
|
using Common;
|
|||
|
|
using Domain;
|
|||
|
|
using Dao;
|
|||
|
|
using RestSharp;
|
|||
|
|
|
|||
|
|
namespace RCUHost.Implement
|
|||
|
|
{
|
|||
|
|
public class TFTPSettingReceiver : GenericReceiverBase, IT_FTPSettingReceiver
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
private static log4net.ILog logger = log4net.LogManager.GetLogger(typeof(TFTPReceiver));
|
|||
|
|
|
|||
|
|
//public ITFTP_SetRepository TFTPLogRepository { get; set; }
|
|||
|
|
//public IHostRepository HostRepository { get; set; }
|
|||
|
|
public override CommandType CommandType
|
|||
|
|
{
|
|||
|
|
get { return CommandType.TFTPLog_Setting; }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
public override void Process(ReceiverContext context)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public byte[] CreateDataPacket_Setting(byte[] data)
|
|||
|
|
{
|
|||
|
|
SystemHeader systemHeader = CreateSystemHeader();
|
|||
|
|
|
|||
|
|
//加2是 最后是CRC
|
|||
|
|
int size = StructConverter.SizeOf(systemHeader) + data.Length + 2;
|
|||
|
|
systemHeader.FrameLength = (ushort)size;
|
|||
|
|
|
|||
|
|
using (MemoryStream stream = new MemoryStream(size))
|
|||
|
|
{
|
|||
|
|
using (BinaryWriter writer = new BinaryWriter(stream))
|
|||
|
|
{
|
|||
|
|
writer.Write(StructConverter.StructToBytes(systemHeader));
|
|||
|
|
writer.Write(data);
|
|||
|
|
writer.Write(new byte[] { 0, 0 });
|
|||
|
|
return stream.ToArray();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Send_Setting_Data(byte[] data, string hostnumber, string mac)
|
|||
|
|
{
|
|||
|
|
byte[] result= CreateDataPacket_Setting(data);
|
|||
|
|
Send(result, hostnumber, mac);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|