using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace DataEntity.Sockets.Base
|
{
|
/// <summary>
|
/// 基础请求消息实体类
|
/// </summary>
|
public class HxRequestBase
|
{
|
/// <summary>
|
/// 指令编号
|
/// </summary>
|
public string message_id { get; set; }
|
/// <summary>
|
/// 消息类型,详见0.8节
|
/// </summary>
|
public int message_type { get; set; }
|
/// <summary>
|
/// 指令名称
|
/// </summary>
|
public string method { get; set; }
|
/// <summary>
|
/// 设备唯一编号
|
/// </summary>
|
public string equipment_id { get; set; }
|
/// <summary>
|
/// 执行方法的工作流编号
|
/// </summary>
|
public string workflow_id { get; set; }
|
/// <summary>
|
/// 实验ID
|
/// </summary>
|
public string experiment_id { get; set; }
|
/// <summary>
|
/// 预估时间
|
/// </summary>
|
public int estimate_time { get; set; }
|
/// <summary>
|
/// 超时时间
|
/// </summary>
|
public int timeout { get; set; }
|
/// <summary>
|
/// 描述信息
|
/// </summary>
|
public string description { get; set; }
|
|
/// <summary>
|
/// 记录时间
|
/// </summary>
|
public string timestamp { get; set; }
|
|
#region 给基础变量赋值
|
/// <summary>
|
/// 给基础变量赋值
|
/// </summary>
|
/// <param name="equipmentId"></param>
|
/// <param name="method"></param>
|
public void SetBaseVal(string equipmentId, string method)
|
{
|
this.equipment_id = equipmentId;
|
this.method = method;
|
string instrunctionId = InstrunctionId();
|
this.description = $"description_{this.method}";
|
this.message_id = instrunctionId;
|
this.message_type = 2;
|
this.estimate_time = 3;
|
this.timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
string strworkflow_id = "workflow_id_" + instrunctionId;
|
this.workflow_id = strworkflow_id;
|
this.experiment_id = "experiment_id_" + instrunctionId;
|
this.timeout = 3;
|
}
|
#endregion
|
|
#region 随机生成字符串
|
/// <summary>
|
/// 随机生成字符串
|
/// </summary>
|
/// <returns></returns>
|
public static string InstrunctionId()
|
{
|
Random random = new Random();
|
int randKey = random.Next(1000, 9999);
|
string guidStr = Guid.NewGuid().ToString();
|
return DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + guidStr;
|
}
|
#endregion
|
}
|
}
|