pry 2 years ago
parent
commit
638a8ebe2d
6 changed files with 72 additions and 30 deletions
  1. +54
    -26
      HBLConsole.Business/IotReport.cs
  2. +8
    -0
      HBLConsole.Communication/LebaiHelper.cs
  3. +2
    -2
      HBLConsole.MORKIC/Control_MORKIC.cs
  4. +2
    -0
      HBLConsole.MORKS/Control_MORKS.cs
  5. +4
    -0
      HBLConsole.MORKS/GVL_MORKS.cs
  6. +2
    -2
      HBLDevice.Coffee/CoffeeMachine.cs

+ 54
- 26
HBLConsole.Business/IotReport.cs View File

@@ -15,22 +15,22 @@ namespace HBLConsole.Business
{
public class IotReport
{
#region 单例模式
private volatile static IotReport _Instance;
public static IotReport GetInstance => _Instance ?? (_Instance = new IotReport());
private IotReport()
{
iOTDevSXModel = new IOTDevSXModel();
iOTDevSXModel.SBMC = InternetInfo.DeviceName;
iOTDevSXModel.SBMS = InternetInfo.DeviceMS;
iOTDevSXModel.SetKZSX(new DevSX { data = new List<DevSXBase> { new DevSXBase { SXMC = "", SXLX = "" } } });
IOTDev.GetInstance().Set(InternetInfo.ProductKey, InternetInfo.DeviceName, InternetInfo.DeviceSecret);
iSLinks = IOTDev.GetInstance().CreateLinks();
if (iSLinks) MessageLog.GetInstance.Show($"设备{InternetInfo.DeviceName}阿里云连接成功.");
else MessageLog.GetInstance.Show($"设备{InternetInfo.DeviceName}阿里云连接失败.不能上报业务信息");
string NameSpace = $"HBLConsole.{GeneralConfig.DeviceType}";//Load 加载的是dll的名称,GetType获取的是全命名空间下的类
Type type = Assembly.Load(NameSpace).GetType($"{NameSpace}.Control_{GeneralConfig.DeviceType}");
control = (IControl)type?.GetProperty("Instance").GetValue(null);
string NameSpace = $"HBLConsole.{GeneralConfig.DeviceType}";
control = (IControl)(Assembly.Load(NameSpace).GetType($"{NameSpace}.Control_{GeneralConfig.DeviceType}"))?.GetProperty("Instance").GetValue(null);
}
#endregion

#region 变量
/// <summary>
/// 是否连接成功
/// </summary>
@@ -38,25 +38,36 @@ namespace HBLConsole.Business
/// <summary>
/// 大屏上报Model
/// </summary>
public IOTDevSXModel iOTDevSXModel = new IOTDevSXModel();
public IOTDevSXModel iOTDevSXModel = new IOTDevSXModel() { SBMC = InternetInfo.DeviceName, SBMS = InternetInfo.DeviceMS };
/// <summary>
///
/// 当前控制的设备控件
/// </summary>
IControl control;
public IControl control;

#endregion

/// <summary>
/// 关闭IOT连接
/// </summary>
public void Close()
{
IOTDev.GetInstance().Disconnect();
}

/// <summary>
/// 获取属性状态
/// </summary>
public T GetTypeValue<T>(string str)
{
return (T)control.GetT().GetType().GetProperty(str).GetValue(control.GetT(), null);
}

/// <summary>
/// 设置上报数据
/// </summary>
public void SetData()
{
#region 上报
#region 上报数据整理
#region 基本数据
//设置基本属性与状态
iOTDevSXModel.SetJBSX(new DevSX
{
@@ -67,35 +78,50 @@ namespace HBLConsole.Business
new DevSXBase { SXMC="设备软件",SXLX="上位机",SXStatus=true }
}
});
#endregion

#region 扩展数据
bool IsAllowRun = GetTypeValue<bool>("AllowRun");
bool TemperatureReached = GetTypeValue<bool>("TemperatureReached");
bool MissingBowl = GetTypeValue<bool>("MissingBowl");
bool TurntableLowerLimit = GetTypeValue<bool>("TurntableLowerLimit");

bool MissingBowlSignal2 = GetTypeValue<bool>("MissingBowlSignal2");
bool IsNoodles = GetTypeValue<bool>("IsNoodles");//转台
bool AllowFallNoodle = GetTypeValue<bool>("AllowFallNoodle");//是否允许到面
bool[] CookNoodlesComplete = GetTypeValue<bool[]>("CookNoodlesComplete");//煮面完成上升信号
bool isCookNoodles= CookNoodlesComplete.ToList().Find(o=>o);
//设置扩展属性与状态,连接上机器人后才会处罚
if (GeneralConfig.Healthy)
if (IsAllowRun)
{
iOTDevSXModel.SetKZSX(new DevSX
{
data = new List<DevSXBase>
{
new DevSXBase { SXMC="设备硬件",SXLX="煮面炉",SXStatus= TemperatureReached ,
SXYCMS=TemperatureReached?"":DateTime.Now+" 异常,煮面炉温度不够,疑似正在加热或者未工作...."},
new DevSXBase { SXMC="设备硬件",SXLX="取碗结构",SXStatus=MissingBowl ,
SXYCMS=MissingBowl?"":DateTime.Now+" 异常,缺碗...."},
new DevSXBase { SXMC="设备硬件",SXLX="取面转台",SXStatus=TurntableLowerLimit ,
SXYCMS=TurntableLowerLimit?"":DateTime.Now+" 异常,转台缺面...."}
new DevSXBase { SXMC="设备硬件",SXLX="煮面炉",SXStatus= !TemperatureReached ,
SXYCMS=!TemperatureReached?"":DateTime.Now+" 异常,煮面炉温度不够,疑似正在加热或者未工作...."},
new DevSXBase { SXMC="设备硬件",SXLX="装小碗结构",SXStatus=MissingBowl ,
SXYCMS=MissingBowl?"":DateTime.Now+" 异常,缺小碗...."},
new DevSXBase { SXMC="设备硬件",SXLX="装大碗结构",SXStatus=MissingBowlSignal2 ,
SXYCMS=MissingBowlSignal2?"":DateTime.Now+" 异常,缺大碗...."},
new DevSXBase { SXMC="设备硬件",SXLX="取面转台",SXStatus=IsNoodles ,
SXYCMS=IsNoodles?"":DateTime.Now+" 异常,转台位置缺少物料...."},
new DevSXBase { SXMC="设备硬件",SXLX="配料机",SXStatus=!(!AllowFallNoodle && isCookNoodles) ,
SXYCMS=!((!AllowFallNoodle && isCookNoodles))?"":DateTime.Now+" 异常,配料机未配完料,疑似碗未到配料机下方或者配料机未工作...."}
}
});
}
else {
iOTDevSXModel.SetKZSX(new DevSX { data = new List<DevSXBase> { new DevSXBase { SXMC = "", SXLX = "" } } });
}
#endregion

//设置告警消息
#region 告警消息
List<DevSXBase> bases = Tools.JsonToObjectTools<DevSX>(iOTDevSXModel.JBSX)?.data?.ToList().FindAll(par => par.SXStatus == false);
if (bases != null) bases.AddRange(Tools.JsonToObjectTools<DevSX>(iOTDevSXModel.KZSX)?.data?.ToList().FindAll(par => par.SXStatus == false));
List<AlarmModel> alarms = new List<AlarmModel>();
bases?.ForEach(par => alarms.Add(new AlarmModel { DeviceMC = iOTDevSXModel.SBMC, DeviceSJ = DateTime.Now.ToString(), AlarmCD = "一般", DeviceZT = "未处理", DeviceMS = par.SXYCMS }));
iOTDevSXModel.SetGJXX(new AlarmMessage { data = alarms });
#endregion

bool InitComplete = GetTypeValue<bool>("InitComplete");
bool RobotTakeNoodle = GetTypeValue<bool>("RobotTakeNoodle");
@@ -104,16 +130,19 @@ namespace HBLConsole.Business
{
data = new List<ProcessModel>
{
new ProcessModel { ProcessName="开机",IsMark=!IsAllowRun },
new ProcessModel { ProcessName="初始化",IsMark=!InitComplete },
new ProcessModel { ProcessName="开机",IsMark=IsAllowRun,ProcessMS=IsAllowRun?"机器人开机成功":"" },
new ProcessModel { ProcessName="初始化",IsMark=InitComplete,ProcessMS=InitComplete?"机器人正在初始化成功":"" },
new ProcessModel { ProcessName="取面",IsMark=RobotTakeNoodle,ProcessMS=RobotTakeNoodle?"机器人正在取面过程中....":""},
new ProcessModel { ProcessName="出餐",IsMark=RobotOutMeal,ProcessMS=RobotOutMeal?"机器人正在出餐过程中....":"" }
new ProcessModel { ProcessName="出餐",IsMark=AllowFallNoodle,ProcessMS=AllowFallNoodle?"机器人正在出餐过程中....":"" }
}
});
#endregion

}

/// <summary>
/// 初始化上报流程
/// </summary>
public void Init()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
@@ -125,7 +154,6 @@ namespace HBLConsole.Business
}
Thread.Sleep(5000);
}), "设备IOT上报云端");

}
}
}

+ 8
- 0
HBLConsole.Communication/LebaiHelper.cs View File

@@ -40,10 +40,18 @@ namespace HBLConsole.Communication
}
}
MessageLog.GetInstance.Show("乐百机器人连接成功!");
GetSpeed();
//ActionOperate.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
}


public void GetSpeed()
{
//client.StartSys().GetAwaiter();
var aa = client.GetActualTcpSpeed().GetAwaiter();
}


/// <summary>
/// 获取信号量
/// </summary>


+ 2
- 2
HBLConsole.MORKIC/Control_MORKIC.cs View File

@@ -60,7 +60,7 @@ namespace HBLConsole.MORKIC
/// <summary>
/// 获取乐百机器人的数据
/// </summary>
SignalResult lebai;
SignalResult lebai=new SignalResult();

public void ConnectOk()
{
@@ -257,7 +257,7 @@ namespace HBLConsole.MORKIC
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
{
//lebai = LebaiHelper.GetInstance.GetValueAsync();
lebai = LebaiHelper.GetInstance.GetValueAsync();
Thread.Sleep(100);
}), "乐百机器人数据读取");
}


+ 2
- 0
HBLConsole.MORKS/Control_MORKS.cs View File

@@ -302,6 +302,7 @@ namespace HBLConsole.MORKS
mORKS.AllowTakeNoodle = true;
TurntableLoc.Clear();
MessageLog.GetInstance.Show("转台位置OK");
mORKS.IsNoodles = true;
}
else
{
@@ -324,6 +325,7 @@ namespace HBLConsole.MORKS
}
}
}
mORKS.IsNoodles = false;
MessageLog.GetInstance.Show("转台位置缺少物料");
}
}


+ 4
- 0
HBLConsole.MORKS/GVL_MORKS.cs View File

@@ -248,5 +248,9 @@ namespace HBLConsole.MORKS
[Circuit("取碗控制", "有取碗队列数量")]
public ConcurrentQueue<OrderLocInfo> TakeBowlTask { get; set; } = new ConcurrentQueue<OrderLocInfo>();

/// <summary>
/// 是否有面条
/// </summary>
public bool IsNoodles { get; set; } = true;
}
}

+ 2
- 2
HBLDevice.Coffee/CoffeeMachine.cs View File

@@ -14,7 +14,7 @@ namespace HBLDevice.Coffee
/// <summary>
/// 咖啡机
/// </summary>
public class CoffeeMachine
public class CoffeeMachine
{
//通讯代理
SerialPortClient commProxy = null;
@@ -224,6 +224,6 @@ namespace HBLDevice.Coffee
//}, "咖啡机解析线程");
}

}
}

Loading…
Cancel
Save