using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ModBus.Net
{
public abstract class ProtocalUnit : IProtocalFormatting
{
///
/// 格式化,将输入结构转换为字节数组
///
///
///
public abstract byte[] Format(InputStruct message);
///
/// 格式化,将对象数组转换为字节数组
///
///
///
public virtual byte[] Format(params object[] message)
{
return TranslateContent(message);
}
///
/// 结构化,将字节数组转换为输出结构。
///
///
///
///
public abstract OutputStruct Unformat(byte[] messageBytes, ref int pos);
///
/// 转换静态方法,把对象数组转换为字节数组。
///
///
///
public static byte[] TranslateContent(params object[] contents)
{
bool b = false;
//先查找传入的结构中有没有数组,有的话将其打开
var newContentsList = new List