You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
6.0 KiB

using Monitor.LogService;
using Module.Socket.Tool;
using BatCharging.Model;
namespace BatCharging.Service
{
/// <summary>
/// 基础参数值
/// </summary>
public class CmnChargerParam
{
#region 随机数
/// <summary>
/// 循环时用的随机数值
/// </summary>
public static UInt16 _CYS_SEQ_NUM = 0;
/// <summary>
/// 鉴权随时数
/// </summary>
public static byte _RANDOM_NUM = 0;
/// <summary>
/// 计算循环用UInt16随机数值
/// </summary>
/// <returns></returns>
public static UInt16 GetUInt16SeqNum()
{
if (CmnChargerParam._CYS_SEQ_NUM < 65535)
{
CmnChargerParam._CYS_SEQ_NUM += 1;
}
else
{
CmnChargerParam._CYS_SEQ_NUM = 1;
}
return _CYS_SEQ_NUM;
}
/// <summary>
/// 计算Byte随机数值
/// </summary>
/// <returns></returns>
public static byte GetByteRandomNum()
{
if (CmnChargerParam._RANDOM_NUM < 255)
{
CmnChargerParam._RANDOM_NUM += 1;
}
else
{
CmnChargerParam._RANDOM_NUM = 1;
}
return CmnChargerParam._RANDOM_NUM;
}
#endregion 随时数
public static ChargerMgrTool _CHR00TCPCLIENT = new ChargerMgrTool();
/// <summary>
/// 设置消息发送到充电机的日志
/// </summary>
/// <param name="sendType">发送类型名称</param>
/// <param name="content">发送的字节数组</param>
public static void SetSendMsgToCharing01Log(string sendType, byte[] contents)
{
string strTemp = DateTime.Now.ToString("HH:mm:ss fff") + "\r\n";
for (int i = 0; i < contents.Length; i++)
{
strTemp += contents[i].ToString("X2").PadLeft(2, '0') + " ";
}
Log.LogInstance.WriteLog(sendType + "-" + strTemp, LogType.Run, "MessageLogCharing01");
}
/// <summary>
/// 设置消息发送到充电机的日志
/// </summary>
/// <param name="sendType">发送类型名称</param>
/// <param name="content">发送的字节数组</param>
public static void SetSendMsgToCharing02Log(string sendType, byte[] contents)
{
string strTemp = DateTime.Now.ToString("HH:mm:ss fff") + "\r\n";
for (int i = 0; i < contents.Length; i++)
{
strTemp += contents[i].ToString("X2").PadLeft(2, '0') + " ";
}
Log.LogInstance.WriteLog(sendType + "-" + strTemp, LogType.Run, "MessageLogCharing02");
}
/// <summary>
/// 设置消息发送到充电机的日志
/// </summary>
/// <param name="sendType">发送类型名称</param>
/// <param name="content">发送的字节数组</param>
public static void SetSendMsgToCharing03Log(string sendType, byte[] contents)
{
string strTemp = DateTime.Now.ToString("HH:mm:ss fff") + "\r\n";
for (int i = 0; i < contents.Length; i++)
{
strTemp += contents[i].ToString("X2").PadLeft(2, '0') + " ";
}
Log.LogInstance.WriteLog(sendType + "-" + strTemp, LogType.Run, "MessageLogCharing03");
}
/// <summary>
/// 设置消息发送到充电机的日志
/// </summary>
/// <param name="sendType">发送类型名称</param>
/// <param name="content">发送的字节数组</param>
public static void SetSendMsgToCharing04Log(string sendType, byte[] contents)
{
string strTemp = DateTime.Now.ToString("HH:mm:ss fff") + "\r\n";
for (int i = 0; i < contents.Length; i++)
{
strTemp += contents[i].ToString("X2").PadLeft(2, '0') + " ";
}
Log.LogInstance.WriteLog(sendType + "-" + strTemp, LogType.Run, "MessageLogCharing04");
}
/// <summary>
/// 设置消息发送到充电机的日志
/// </summary>
/// <param name="sendType">发送类型名称</param>
/// <param name="content">发送的字节数组</param>
public static void SetSendMsgToCharing05Log(string sendType, byte[] contents)
{
string strTemp = DateTime.Now.ToString("HH:mm:ss fff") + "\r\n";
for (int i = 0; i < contents.Length; i++)
{
strTemp += contents[i].ToString("X2").PadLeft(2, '0') + " ";
}
Log.LogInstance.WriteLog(sendType + "-" + strTemp, LogType.Run, "MessageLogCharing05");
}
/// <summary>
/// 设置消息发送到充电机的日志
/// </summary>
/// <param name="sendType">发送类型名称</param>
/// <param name="content">发送的字节数组</param>
public static void SetSendMsgToCharing06Log(string sendType, byte[] contents)
{
string strTemp = DateTime.Now.ToString("HH:mm:ss fff") + "\r\n";
for (int i = 0; i < contents.Length; i++)
{
strTemp += contents[i].ToString("X2").PadLeft(2, '0') + " ";
}
Log.LogInstance.WriteLog(sendType + "-" + strTemp, LogType.Run, "MessageLogCharing06");
}
/// <summary>
/// 设置消息发送到充电机的日志
/// </summary>
/// <param name="sendType">发送类型名称</param>
/// <param name="content">发送的字节数组</param>
public static void SetSendMsgToCharing07Log(string sendType, byte[] contents)
{
string strTemp = DateTime.Now.ToString("HH:mm:ss fff") + "\r\n";
for (int i = 0; i < contents.Length; i++)
{
strTemp += contents[i].ToString("X2").PadLeft(2, '0') + " ";
}
Log.LogInstance.WriteLog(sendType + "-" + strTemp, LogType.Run, "MessageLogCharing07");
}
}
}