using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataEntity.Sockets.Base
{
///
/// 基础请求消息实体类
///
public class HxRequestBase
{
///
/// 指令编号
///
public string message_id { get; set; }
///
/// 消息类型,详见0.8节
///
public int message_type { get; set; }
///
/// 指令名称
///
public string method { get; set; }
///
/// 设备唯一编号
///
public string equipment_id { get; set; }
///
/// 执行方法的工作流编号
///
public string workflow_id { get; set; }
///
/// 实验ID
///
public string experiment_id { get; set; }
///
/// 预估时间
///
public int estimate_time { get; set; }
///
/// 超时时间
///
public int timeout { get; set; }
///
/// 描述信息
///
public string description { get; set; }
///
/// 记录时间
///
public string timestamp { get; set; }
#region 给基础变量赋值
///
/// 给基础变量赋值
///
///
///
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 随机生成字符串
///
/// 随机生成字符串
///
///
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
}
}