@@ -145,7 +145,7 @@ namespace BPASmartClient.Business | |||
}; | |||
#region API 订单状态修改 | |||
if (orderStatusChange.CookingStatus != ORDER_STATUS.WAIT) | |||
if (orderStatusChange.SuborderId.Length > 0 && orderStatusChange.CookingStatus != ORDER_STATUS.WAIT) | |||
{ | |||
try | |||
{ | |||
@@ -7,12 +7,18 @@ | |||
<UseWindowsForms>true</UseWindowsForms> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Compile Remove="Fonts\Debug\**" /> | |||
<EmbeddedResource Remove="Fonts\Debug\**" /> | |||
<None Remove="Fonts\Debug\**" /> | |||
<Page Remove="Fonts\Debug\**" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Remove="Properties\App.xaml.cs" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Remove="Fonts\Debug\iconfont.ttf" /> | |||
<None Remove="Fonts\iconfont.ttf" /> | |||
<None Remove="Image\bg.png" /> | |||
<None Remove="Image\btn_close.png" /> | |||
@@ -27,7 +33,9 @@ | |||
<None Remove="Image\hbl.ico" /> | |||
<None Remove="Image\HBL.png" /> | |||
<None Remove="Image\iconfont.ttf" /> | |||
<None Remove="Image\leftback.png" /> | |||
<None Remove="Image\leftImage.png" /> | |||
<None Remove="Image\leftImage1.png" /> | |||
<None Remove="Image\leftImageSub.png" /> | |||
<None Remove="Image\logo\hbl.ico" /> | |||
<None Remove="Image\logo\hbl1.ico" /> | |||
@@ -173,11 +181,12 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Resource Include="Fonts\Debug\iconfont.ttf" /> | |||
<Resource Include="Image\btn_close.png" /> | |||
<Resource Include="Image\ComboBoxPopSelect.png" /> | |||
<Resource Include="Image\ComboBoxSelect.png" /> | |||
<Resource Include="Image\Exp.png" /> | |||
<Resource Include="Image\leftback.png" /> | |||
<Resource Include="Image\leftImage.png" /> | |||
<Resource Include="Image\上箭头.png" /> | |||
<Resource Include="Image\临时模板.png" /> | |||
<Resource Include="Image\产品制作.png" /> | |||
@@ -223,7 +232,7 @@ | |||
<Resource Include="Image\Cb_HalfChecked.png" /> | |||
<Resource Include="Image\hbl.ico" /> | |||
<Resource Include="Image\iconfont.ttf" /> | |||
<Resource Include="Image\leftImage.png" /> | |||
<Resource Include="Image\leftImage1.png" /> | |||
<Resource Include="Image\leftImageSub.png" /> | |||
<Resource Include="Image\logo\hbl.ico" /> | |||
<Resource Include="Image\logo\hbl1.ico" /> | |||
@@ -242,5 +242,9 @@ namespace BPASmartClient.DRCoffee | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
} | |||
} |
@@ -13,6 +13,8 @@ using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.EventBus; | |||
namespace BPASmartClient.Device | |||
{ | |||
@@ -110,6 +112,11 @@ namespace BPASmartClient.Device | |||
#endregion | |||
/// <summary> | |||
/// 写控制 | |||
/// </summary> | |||
/// <param name="address"></param> | |||
/// <param name="value"></param> | |||
public void WriteControl(string address, object value) | |||
{ | |||
if (peripherals != null) | |||
@@ -202,6 +209,7 @@ namespace BPASmartClient.Device | |||
Thread.Sleep(100); | |||
}), $"GetAllStatus:{DeviceId}"); | |||
DoMain(); | |||
SimOrder(); | |||
GetGvlStatus(); | |||
InitResetTask(); | |||
InitTask(); | |||
@@ -336,7 +344,7 @@ namespace BPASmartClient.Device | |||
{ | |||
MainTask(); | |||
Thread.Sleep(10); | |||
}) ,$"MainTask:{DeviceId}",true); | |||
}), $"MainTask:{DeviceId}", true); | |||
#endregion | |||
#region 设备状态监控 | |||
@@ -508,6 +516,11 @@ namespace BPASmartClient.Device | |||
/// </summary> | |||
public abstract void ResetProgram(); | |||
/// <summary> | |||
/// 模拟订单 | |||
/// </summary> | |||
public abstract void SimOrder(); | |||
public object GetError() | |||
{ | |||
return new { data = Error }; | |||
@@ -536,5 +549,6 @@ namespace BPASmartClient.Device | |||
IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi; | |||
return property.First().GetValue(info, null); | |||
} | |||
} | |||
} |
@@ -43,11 +43,6 @@ namespace BPASmartClient.Helper | |||
{ | |||
action?.Invoke(); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
/// <summary> | |||
@@ -60,56 +55,105 @@ namespace BPASmartClient.Helper | |||
{ | |||
action?.Invoke(par); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(par); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
public static void Invokes(this Action<object[]> action, object[] par, Action callback) | |||
{ | |||
action?.Invoke(par); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(par); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
/// <summary> | |||
/// 字节数组转换成32位整数 | |||
/// </summary> | |||
/// <param name="bytes"></param> | |||
/// <returns></returns> | |||
public static int BytesToInt(this byte[] bytes) | |||
{ | |||
if (bytes.Length > 4) return -1; | |||
int ReturnVlaue = 0; | |||
for (int i = 0; i < bytes.Length; i++) | |||
{ | |||
ReturnVlaue += (int)(bytes[i] << (i * 8)); | |||
} | |||
return ReturnVlaue; | |||
} | |||
/// <summary> | |||
/// 字节数组转换成 ushort 数组 | |||
/// </summary> | |||
/// <param name="bytes">要转换的字节数组</param> | |||
/// <param name="reverse">字节高度顺序控制</param> | |||
/// <returns></returns> | |||
public static ushort[] BytesToUshorts(this byte[] bytes, bool reverse = false) | |||
{ | |||
int len = bytes.Length; | |||
byte[] srcPlus = new byte[len + 1]; | |||
bytes.CopyTo(srcPlus, 0); | |||
int count = len >> 1; | |||
if (len % 2 != 0) | |||
{ | |||
count += 1; | |||
} | |||
ushort[] dest = new ushort[count]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] << 8 | srcPlus[2 * i + 1] & 0xff); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] & 0xff | srcPlus[2 * i + 1] << 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
/// <summary> | |||
/// ushort 数组转换成字节数组 | |||
/// </summary> | |||
/// <param name="src">需要转换的 ushort数组</param> | |||
/// <param name="reverse">高低字节的设置</param> | |||
/// <returns></returns> | |||
public static byte[] UshortsToBytes(this ushort[] src, bool reverse = false) | |||
{ | |||
int count = src.Length; | |||
byte[] dest = new byte[count << 1]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 8); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 0); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 0); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
///// <summary> | |||
///// 保存数据 | |||
///// </summary> | |||
//public static void Save<T>(this T ot) | |||
//{ | |||
// string outjson = JsonConvert.SerializeObject(ot); | |||
// var str = ot.GetType().GenericTypeArguments; | |||
// if (str != null && str.Length > 0) | |||
// { | |||
// File.WriteAllText(LocaPath.GetInstance.Getpath(str[0].Name), outjson); | |||
// } | |||
//} | |||
///// <summary> | |||
///// 获取保存的数据 | |||
///// </summary> | |||
//public static void Read(this object ot) | |||
//{ | |||
// var str = ot.GetType().GenericTypeArguments; | |||
// if (str != null && str.Length > 0) | |||
// { | |||
// string pa = LocaPath.GetInstance.Getpath(str[0].Name); | |||
// if (File.Exists(pa)) | |||
// { | |||
// string JsonString = File.ReadAllText(pa); | |||
// var result = JsonConvert.DeserializeObject<object>(JsonString); | |||
// if (result != null) { Json<object>.Data = result; } | |||
// } | |||
// } | |||
//} | |||
} | |||
} |
@@ -99,7 +99,9 @@ namespace BPASmartClient.IoT | |||
{ | |||
if (DeviceDataV != null && DeviceDataV.GetIsConnected() && DeviceDataV.deviceTable != null) | |||
{ | |||
DeviceDataV.IOT_Publish(BroadcastPubTopic, Tools.JsonConvertTools("刷新店铺列表")); | |||
string api = DataVApiAddress + "/api/Device/FlushedDevice"; | |||
HttpRequestHelper.HttpGetRequest(api, 1000); | |||
//DeviceDataV.IOT_Publish(BroadcastPubTopic, Tools.JsonConvertTools("刷新店铺列表")); | |||
} | |||
} | |||
catch (Exception ex) | |||
@@ -0,0 +1,14 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.JakaRobot\BPASmartClient.JakaRobot.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,83 @@ | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.JakaRobot; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Peripheral; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.JAKA | |||
{ | |||
public class JakaMachine : BasePeripheral | |||
{ | |||
JaKaHelper jaKaHelper = new JaKaHelper(); | |||
public override void Init() | |||
{ | |||
jaKaHelper.Connect(communicationPar.IPAddress); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
IsConnected = jaKaHelper.IsConnected; | |||
if (!IsConnected) IsWork = false; | |||
while (IsConnected) | |||
{ | |||
IsWork = true; | |||
if (status != null) | |||
{ | |||
SetStatus("GetProgramStatus", (int)jaKaHelper.GetProgramStatus()); | |||
SetStatus("Get_RobotAO1", jaKaHelper.Get_RobotAO1()); | |||
} | |||
Thread.Sleep(500); | |||
} | |||
Thread.Sleep(1000); | |||
}), $"设备[{DeviceId}]节卡机器人读取线程", true); | |||
EventBus.EventBus.GetInstance().Subscribe<WriteJaka>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteJaka; | |||
switch (par?.TagName) | |||
{ | |||
case "Power_On": | |||
jaKaHelper.Power_On(); | |||
break; | |||
case "Enable_robot": | |||
jaKaHelper.Enable_robot(); | |||
break; | |||
case "Set_RobotAO1": | |||
if (par?.Value is int intvalue) jaKaHelper.Set_RobotAO1(intvalue); | |||
break; | |||
case "JaKaProgramName": | |||
if (par?.Value is string stringvalue) jaKaHelper.JaKaProgramName(stringvalue); | |||
break; | |||
default: | |||
break; | |||
} | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
protected override void InitStatus() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Message\BPASmartClient.Message.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,371 @@ | |||
using BPASmartClient.Message; | |||
using System.Text; | |||
namespace BPASmartClient.JakaRobot | |||
{ | |||
public class JaKaHelper | |||
{ | |||
#region 果汁机设备 | |||
/*public const string SENCE_取咖啡杯 = "10000"; | |||
public const string SENCE_取果汁杯 = "10001"; | |||
public const string SENCE_取茶水杯 = "10002"; | |||
public const string SENCE_取水杯 = "10003"; | |||
public const string SENCE_取咖啡杯检测 = "11000"; | |||
public const string SENCE_取果汁杯检测 = "11001"; | |||
public const string SENCE_取茶水杯检测 = "11002"; | |||
public const string SENCE_取水杯检测 = "11003"; | |||
public const string SENCE_接咖啡 = "12000"; | |||
public const string SENCE_接果汁1 = "12001"; | |||
public const string SENCE_接果汁2 = "12002"; | |||
public const string SENCE_接果汁3 = "12003"; | |||
public const string SENCE_接果汁4 = "12004"; | |||
public const string SENCE_接茶 = "12005"; | |||
public const string SENCE_接水 = "12006"; | |||
public const string SENCE_放咖啡杯 = "13000"; | |||
public const string SENCE_放果汁杯1 = "13001"; | |||
public const string SENCE_放果汁杯2 = "13002"; | |||
public const string SENCE_放果汁杯3 = "13003"; | |||
public const string SENCE_放果汁杯4 = "13004"; | |||
public const string SENCE_放茶水杯 = "13005"; | |||
public const string SENCE_放水杯 = "13006";*/ | |||
//public const string SENCE_取杯 = "10000"; | |||
//public const string SENCE_放杯位检测 = "10100"; | |||
//public const string SENCE_取杯检测 = "11000"; | |||
//public const string SENCE_接咖啡 = "12000"; | |||
//public const string SENCE_接果汁1 = "12001"; | |||
//public const string SENCE_接果汁2 = "12002"; | |||
//public const string SENCE_接果汁3 = "12003"; | |||
//public const string SENCE_接果汁4 = "12004"; | |||
//public const string SENCE_接茶 = "12005"; | |||
//public const string SENCE_接水 = "12006"; | |||
//public const string SENCE_接茶_接水 = "12007"; | |||
//public const string SENCE_放咖啡杯 = "13000";//接饮料位---放饮料过渡位 | |||
//public const string SENCE_放果汁杯1 = "13001"; | |||
//public const string SENCE_放果汁杯2 = "13002"; | |||
//public const string SENCE_放果汁杯3 = "13003"; | |||
//public const string SENCE_放果汁杯4 = "13004"; | |||
//public const string SENCE_放茶水杯 = "13005"; | |||
//public const string SENCE_放杯 = "14000";//放杯过渡位到-放杯 | |||
//public const string SENCE_放杯检测 = "15000"; | |||
//public const string SENCE_初始位 = "20000"; | |||
#endregion | |||
private int rshd = -1; | |||
private bool login = false; | |||
/// <summary> | |||
/// 机器人的状态 | |||
/// </summary> | |||
private JKTYPE.RobotStatus robot_Status; | |||
private JKTYPE.ProgramState program_status; | |||
//private volatile static JaKaHelper _Instance; | |||
//public static JaKaHelper GetInstance => _Instance ?? (_Instance = new JaKaHelper()); | |||
//private JaKaHelper() { } | |||
public bool IsIdle { get; set; } = false; | |||
public bool IsConnected { get { return login; } } | |||
public void Connect(string ip) | |||
{ | |||
bool ErrorFlag = false; | |||
while (rshd == -1 || login == false) | |||
{ | |||
try | |||
{ | |||
jakaAPI.create_handler(ip.ToCharArray(), ref rshd); | |||
login = true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (!ErrorFlag) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
ErrorFlag = true; | |||
login = false; | |||
} | |||
Thread.Sleep(3000); | |||
} | |||
} | |||
if (login) | |||
{ | |||
try | |||
{ | |||
Power_On();//打开机器人电源 | |||
Thread.Sleep(1000); | |||
Enable_robot();//机器人上使能 | |||
MessageLog.GetInstance.Show("机器人已上电使能"); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx("机器人未完成上电和使能"); | |||
} | |||
} | |||
} | |||
public void Power_On() | |||
{ | |||
if (login) | |||
{ | |||
try | |||
{ | |||
jakaAPI.power_on(ref rshd); | |||
} | |||
catch (System.AccessViolationException ave) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ave.ToString()); | |||
} | |||
//catch (Exception ex) | |||
//{ | |||
// MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
//} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
public void Power_Off() | |||
{ | |||
if (login) | |||
{ | |||
try | |||
{ | |||
jakaAPI.power_off(ref rshd); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
public void Enable_robot() | |||
{ | |||
if (!(rshd == -1)) | |||
{ | |||
try | |||
{ | |||
jakaAPI.enable_robot(ref rshd); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
public void disEnable_robot() | |||
{ | |||
if (!(rshd == -1)) | |||
{ | |||
try | |||
{ | |||
jakaAPI.disable_robot(ref rshd); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
/// <summary> | |||
/// 设置机器人的DO值 | |||
/// </summary> | |||
/// <param name="DOIndex"></param> | |||
/// <param name="value"></param> | |||
/// <returns></returns> | |||
public bool Set_RobotDO(int DOIndex, bool value) | |||
{ | |||
try | |||
{ | |||
jakaAPI.set_digital_output(ref rshd, JKTYPE.IOType.IO_CABINET, DOIndex, value); | |||
return value; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
/// 设置机器人的AO值 | |||
/// </summary> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public int Set_RobotAO1(int Value) | |||
{ | |||
try | |||
{ | |||
return jakaAPI.set_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, 0, Value); | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 设置机器人的AO值 | |||
/// </summary> | |||
/// <param name="Index">索引值</param> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public int Set_RobotAO(int Index, int Value) | |||
{ | |||
try | |||
{ | |||
return jakaAPI.set_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, Index, Value); | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 获取机器人的AO值 | |||
/// </summary> | |||
/// <param name="Index">索引值</param> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public float Get_RobotAO(int Index, int value) | |||
{ | |||
try | |||
{ | |||
float bResult = 0; | |||
jakaAPI.get_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, Index, ref bResult); | |||
return bResult; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 获取机器人的AO值 | |||
/// </summary> | |||
/// <param name="Index">索引值</param> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public float Get_RobotAO1() | |||
{ | |||
try | |||
{ | |||
float bResult = 0; | |||
jakaAPI.get_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, 0, ref bResult); | |||
return bResult; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 获取机器人的DI输入 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <returns></returns> | |||
public bool Get_RobotDI(int index) | |||
{ | |||
bool bResult = false; | |||
jakaAPI.get_digital_input(ref rshd, JKTYPE.IOType.IO_CABINET, index, ref bResult); | |||
return bResult; | |||
} | |||
/// <summary> | |||
/// 获取机器人的状态 | |||
/// </summary> | |||
public void GetRobotStatus() | |||
{ | |||
jakaAPI.get_robot_status(ref rshd, ref robot_Status); | |||
} | |||
public JKTYPE.ProgramState GetProgramStatus() | |||
{ | |||
jakaAPI.get_program_state(ref rshd, ref program_status); | |||
return program_status; | |||
} | |||
StringBuilder jakafile; | |||
JKTYPE.ProgramState status; | |||
char[] file; | |||
public void JaKaProgramName(String Programname) | |||
{ | |||
try | |||
{ | |||
//加载 | |||
file = Programname.ToCharArray(); | |||
MessageLog.GetInstance.Show($"调用文件名:{Programname}"); | |||
status = new JKTYPE.ProgramState(); | |||
jakaAPI.get_program_state(ref rshd, ref status); | |||
if (status != JKTYPE.ProgramState.PROGRAM_IDLE) | |||
{ | |||
MessageLog.GetInstance.Show($"程序运行中,无法加载程序!!!"); | |||
} | |||
else | |||
{ | |||
if (jakaAPI.program_load(ref rshd, file) == 0) | |||
{ | |||
MessageLog.GetInstance.Show($"加载程序完成"); | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show($"加载程序失败!!!"); | |||
} | |||
} | |||
if (status == JKTYPE.ProgramState.PROGRAM_RUNNING) | |||
{ | |||
MessageLog.GetInstance.Show($"程序处于已处于启动状态!!!"); | |||
} | |||
else if (status == JKTYPE.ProgramState.PROGRAM_IDLE) | |||
{ | |||
jakafile = new StringBuilder(); | |||
jakaAPI.get_loaded_program(ref rshd, jakafile); | |||
if (jakafile.Length == 0) | |||
{ | |||
MessageLog.GetInstance.Show($"未加载程序,无法运行!!!"); | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show($"当前加载程序为:" + jakafile); | |||
jakaAPI.program_run(ref rshd); | |||
MessageLog.GetInstance.Show($"程序启动"); | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show($"程序处于暂停状态,无法重新启动程序!!!"); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,364 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
//using System.Numerics; | |||
using System.Text; | |||
using System.Runtime.InteropServices; | |||
namespace BPASmartClient.JakaRobot | |||
{ | |||
public class JKTYPE | |||
{ | |||
/** | |||
* @brief 笛卡尔空间位置数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct CartesianTran | |||
{ | |||
public double x; ///< x轴坐标,单位mm | |||
public double y; ///< y轴坐标,单位mm | |||
public double z; ///< z轴坐标,单位mm | |||
}; | |||
/** | |||
* @brief 欧拉角姿态数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct Rpy | |||
{ | |||
public double rx; ///< 绕固定轴X旋转角度,单位:rad | |||
public double ry; ///< 绕固定轴Y旋转角度,单位:rad | |||
public double rz; ///< 绕固定轴Z旋转角度,单位:rad | |||
}; | |||
/** | |||
* @brief 四元数姿态数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct Quaternion | |||
{ | |||
public double s; | |||
public double x; | |||
public double y; | |||
public double z; | |||
}; | |||
/** | |||
*@brief 笛卡尔空间位姿类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct CartesianPose | |||
{ | |||
public CartesianTran tran; ///< 笛卡尔空间位置 | |||
public Rpy rpy; ///< 笛卡尔空间姿态 | |||
}; | |||
/** | |||
* @brief 旋转矩阵数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RotMatrix | |||
{ | |||
public CartesianTran x; ///< x轴列分量 | |||
public CartesianTran y; ///< y轴列分量 | |||
public CartesianTran z; ///< z轴列分量 | |||
}; | |||
/** | |||
* @brief 程序运行状态枚举类型 | |||
*/ | |||
public enum ProgramState | |||
{ | |||
PROGRAM_IDLE, ///< 机器人停止运行 | |||
PROGRAM_RUNNING, ///< 机器人正在运行 | |||
PROGRAM_PAUSED ///< 机器人暂停 | |||
}; | |||
/** | |||
* @brief 坐标系选择枚举类型 | |||
*/ | |||
public enum CoordType | |||
{ | |||
COORD_BASE, ///< 基坐标系 | |||
COORD_JOINT, ///< 关节空间 | |||
COORD_TOOL ///< 工具坐标系 | |||
}; | |||
/** | |||
* @brief jog运动模式枚举 | |||
*/ | |||
public enum MoveMode | |||
{ | |||
ABS = 0, ///< 绝对运动 | |||
INCR ///< 增量运动 | |||
}; | |||
/** | |||
* @brief 系统监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct SystemMonitorData | |||
{ | |||
public int scbMajorVersion; ///<scb主版本号 | |||
public int scbMinorVersion; ///<scb次版本号 | |||
public int cabTemperature; ///<控制柜温度 | |||
public double robotAveragePower; ///<控制柜总线平均功率 | |||
public double robotAverageCurrent; ///<控制柜总线平均电流 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] instCurrent; ///<机器人6个轴的瞬时电流 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] instVoltage; ///<机器人6个轴的瞬时电压 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] instTemperature; ///<机器人6个轴的瞬时温度 | |||
}; | |||
/** | |||
* @brief 负载数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct PayLoad | |||
{ | |||
public double mass; ///<负载质量,单位:kg | |||
public CartesianTran centroid; ///<负载质心, 单位:mm | |||
}; | |||
/** | |||
* @brief 关节位置数据类型 | |||
*/ | |||
public struct JointValue | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] jVal; ///< 6关节位置值,单位:rad | |||
}; | |||
/** | |||
* @brief IO类型枚举 | |||
*/ | |||
public enum IOType | |||
{ | |||
IO_CABINET, ///< 控制柜面板IO | |||
IO_TOOL, ///< 工具IO | |||
IO_EXTEND ///< 扩展IO | |||
}; | |||
/** | |||
* @brief 机器人状态数据 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotState | |||
{ | |||
public int estoped; ///< 是否急停 | |||
public int poweredOn; ///< 是否打开电源 | |||
public int servoEnabled; ///< 是否使能 | |||
}; | |||
/** | |||
* @brief 机器人力矩数据 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct TorqueValue | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] jTorque; ///< 是否使能 | |||
} | |||
/** | |||
* @brief 机器人关节监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct JointMonitorData | |||
{ | |||
double instCurrent; ///< 瞬时电流 | |||
double instVoltage; ///< 瞬时电压 | |||
double instTemperature; ///< 瞬时温度 | |||
} | |||
/** | |||
* @brief 机器人监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotMonitorData | |||
{ | |||
double scbMajorVersion; ///< scb主版本号 | |||
double scbMinorVersion; ///< scb小版本号 | |||
double cabTemperature; ///< 控制器温度 | |||
double robotAveragePower; ///< 机器人平均电压 | |||
double robotAverageCurrent; ///< 机器人平均电流 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public JointMonitorData[] jointMonitorData; ///< 机器人6个关节的监测数据 | |||
} | |||
/** | |||
* @brief 力矩传感器监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct TorqSensorMonitorData | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] | |||
public char[] ip; ///< 力矩传感器ip地址 | |||
int port; ///< 力矩传感器端口号 | |||
PayLoad payLoad; ///< 工具负载 | |||
int status; ///< 力矩传感器状态 | |||
int errcode; ///< 力矩传感器异常错误码 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] actTorque; ///< 力矩传感器实际接触力值 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] torque; ///< 力矩传感器原始读数值 | |||
} | |||
/** | |||
* @brief 机器人状态监测数据,使用get_robot_status函数更新机器人状态数据 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotStatus | |||
{ | |||
public int errcode; ///< 机器人运行出错时错误编号,0为运行正常,其它为运行异常 | |||
public int inpos; ///< 机器人运动是否到位标志,0为没有到位,1为运动到位 | |||
public int powered_on; ///< 机器人是否上电标志,0为没有上电,1为上电 | |||
public int enabled; ///< 机器人是否使能标志,0为没有使能,1为使能 | |||
public double rapidrate; ///< 机器人运动倍率 | |||
public int protective_stop; ///< 机器人是否检测到碰撞,0为没有检测到碰撞,1为检测到碰撞 | |||
public int emergency_stop; ///< 机器人是否急停,0为没有急停,1为急停 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public int[] dout; ///< 机器人控制柜数字输出信号,dout[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | |||
public int[] tio_dout; ///< 机器人末端工具数字输出信号,tio_dout[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public int[] extio; ///< 机器人外部应用数字输出信号,extio[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public int[] din; ///< 机器人控制柜数字输入信号,din[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | |||
public int[] tio_din; ///< 机器人末端工具数字输入信号,tio_din[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public double[] ain; ///< 机器人控制柜模拟输入信号,ain[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | |||
public double[] tio_ain; ///< 机器人末端工具模拟输入信号,tio_ain[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public double[] aout; ///< 机器人控制柜模拟输出信号,aout[0]为信号的个数 | |||
public int current_tool_id; ///< 机器人目前使用的工具坐标系id | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] cartesiantran_position; ///< 机器人末端所在的笛卡尔空间位置 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] joint_position; ///< 机器人关节空间位置 | |||
public int on_soft_limit; ///< 机器人是否处于限位,0为没有触发限位保护,1为触发限位保护 | |||
public int current_user_id; ///< 机器人目前使用的用户坐标系id | |||
public int drag_status; ///< 机器人是否处于拖拽状态,0为没有处于拖拽状态,1为处于拖拽状态 | |||
public RobotMonitorData robot_monitor_data; ///< 机器人状态监测数据 | |||
public TorqSensorMonitorData torq_sensor_monitor_data; ///< 机器人力矩传感器状态监测数据 | |||
int is_socket_connect; ///< sdk与控制器连接通道是否正常,0为连接通道异常,1为连接通道正常 | |||
} | |||
/** | |||
* @brief 机器人错误码数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct ErrorCode | |||
{ | |||
public long code; ///< 错误码编号 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 120)] | |||
public char[] message; ///< 错误码对应提示信息 | |||
} | |||
/** | |||
* @brief 轨迹复现配置参数数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct TrajTrackPara | |||
{ | |||
public double xyz_interval; ///< 空间位置采集精度 | |||
public double rpy_interval; ///< 姿态采集精度 | |||
public double vel; ///< 执行脚本运行速度 | |||
public double acc; ///< 执行脚本运行加速度 | |||
} | |||
/** | |||
* @brief 多个字符串存储数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct MultStrStorType | |||
{ | |||
public int len; ///< 字符串个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128 * 128)] | |||
public char[] message; ///< 错误码对应提示信息 | |||
} | |||
/** | |||
* @brief 运动参数可选项 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct OptionalCond | |||
{ | |||
int executingLineId; ///< 控制命令id编号 | |||
} | |||
/** | |||
* @brief 网络异常机器人运动自动终止类型枚举 | |||
*/ | |||
public enum ProcessType | |||
{ | |||
MOT_KEEP, ///< 网络异常时机器人继续保持原来的运动 | |||
MOT_PAUSE, ///< 网络异常时机器人暂停运动 | |||
MOT_ABORT ///< 网络异常时机器人终止运动 | |||
} | |||
/** | |||
* @brief 柔顺控制参数类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct AdmitCtrlType | |||
{ | |||
int opt; ///< 柔顺方向,可选值为 1 2 3 4 5 6分别对应 fx fy fz mx my mz,0代表没有勾选 | |||
double ft_user; ///< 用户用多大的力才能让机器人的沿着某个方向以最大速度进行运动 | |||
double ft_rebound; ///< 回弹力:机器人回到初始状态的能力 | |||
double ft_constant; ///< 恒力 | |||
int ft_normal_track; ///< 法向跟踪是否开启,0为没有开启,1为开启 | |||
} | |||
/** | |||
* @brief 机器人柔顺控制参数类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotAdmitCtrl | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public AdmitCtrlType[] admit_ctrl; | |||
} | |||
/** | |||
* @brief 速度柔顺控制等级和比率等级设置 | |||
* 速度柔顺控制分三个等级,并且 1>rate1>rate2>rate3>rate4>0 | |||
* 等级为1时,只能设置rate1,rate2两个等级。rate3,rate4的值为0 | |||
* 等级为2时,只能设置rate1,rate2,rate3 三个等级。rate4的值为0 | |||
* 等级为3时,能设置 rate1,rate2,rate3,rate4 4个等级 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct VelCom | |||
{ | |||
int vc_level; //速度柔顺控制等级 | |||
double rate1; //比率1等级 | |||
double rate2; //比率2等级 | |||
double rate3; //比率3等级 | |||
double rate4; //比率4等级 | |||
} | |||
/** | |||
* @brief 力传感器的受力分量和力矩分量 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct FTxyz | |||
{ | |||
double fx; // 沿x轴受力分量 | |||
double fy; // 沿y轴受力分量 | |||
double fz; // 沿z轴受力分量 | |||
double tx; // 绕x轴力矩分量 | |||
double ty; // 绕y轴力矩分量 | |||
double tz; // 绕z轴力矩分量 | |||
} | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,61 @@ | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Peripheral; | |||
using BPASmartClient.SerialPort; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.Juicer | |||
{ | |||
public class JuicerMachine : BasePeripheral | |||
{ | |||
JuicerHelper juicerHelper = new JuicerHelper(); | |||
public override void Init() | |||
{ | |||
juicerHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
IsConnected = juicerHelper.IsOpen; | |||
if (!IsConnected) IsWork = false; | |||
while (IsConnected) | |||
{ | |||
IsWork = true; | |||
if (status != null) | |||
{ | |||
SetStatus("GetDeviceStatus", juicerHelper.GetDeviceStatus()); | |||
} | |||
Thread.Sleep(500); | |||
} | |||
Thread.Sleep(1000); | |||
}), $"设备[{DeviceId}]果汁机读取线程", true); | |||
EventBus.EventBus.GetInstance().Subscribe<WriteJuicer>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteJuicer; | |||
juicerHelper.StartCook(Convert.ToByte(par?.Value)); | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
protected override void InitStatus() | |||
{ | |||
} | |||
} | |||
} |
@@ -49,6 +49,10 @@ namespace BPASmartClient.Lebai | |||
status["RobotOK"] = LebaiHelper.GetInstance().GetValueAsync().Ok; | |||
status["RobotValue"] = LebaiHelper.GetInstance().GetValueAsync().Value; | |||
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] =(ELebaiRModel)LebaiHelper.GetInstance().robotData.RobotMode.Mode; | |||
status["RobotValue1"] = LebaiHelper.GetInstance().GetValueAsync(1).Value; | |||
status["GetInput"] = LebaiHelper.GetInstance().GetInput(); | |||
status["GetInput2"] = LebaiHelper.GetInstance().GetInput(2); | |||
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode; | |||
LebaiHelper.GetInstance().GetRobotModeStatus(); | |||
Thread.Sleep(10); | |||
}, "获取乐白机器人数据"); | |||
@@ -0,0 +1,14 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,71 @@ | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.Model.PLC; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.Peripheral; | |||
using BPASmartClient.SerialPort; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.MCU | |||
{ | |||
public class MCUMachine : BasePeripheral | |||
{ | |||
MCUSerialHelper mCUSerialHelper = new MCUSerialHelper(); | |||
public override void Init() | |||
{ | |||
mCUSerialHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate); | |||
EventBus.EventBus.GetInstance().Subscribe<ReadMcu>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as ReadMcu; | |||
if (status != null) | |||
{ | |||
SetStatus(par?.TagName, mCUSerialHelper.GetInputStatus(Convert.ToByte(par?.ReadPar))); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<WriteMcu>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteMcu; | |||
switch (par?.TagName) | |||
{ | |||
case "OutputControl": | |||
mCUSerialHelper.OutputControl(Convert.ToByte(par?.Address), Convert.ToBoolean(par?.Value)); | |||
break; | |||
case "ServoControl": | |||
mCUSerialHelper.ServoControl(Convert.ToByte(par?.Address), Convert.ToByte(par?.Value)); | |||
break; | |||
default: | |||
break; | |||
} | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
protected override void InitStatus() | |||
{ | |||
} | |||
} | |||
} |
@@ -48,11 +48,15 @@ namespace BPASmartClient.PLC | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteModel; | |||
//M32.7地址复位 | |||
modbusTcp.Write(par?.Address, par?.Value); | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
@@ -1,4 +1,4 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
@@ -9,6 +9,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Message\BPASmartClient.Message.csproj" /> | |||
</ItemGroup> | |||
@@ -0,0 +1,211 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Modbus | |||
{ | |||
public class MODBUS | |||
{ | |||
/// <summary> | |||
/// 赋值string | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="value"></param> | |||
/// <returns></returns> | |||
public static void SetString(ushort[] src, int start, string value) | |||
{ | |||
byte[] bytesTemp = Encoding.UTF8.GetBytes(value); | |||
ushort[] dest = Bytes2Ushorts(bytesTemp); | |||
dest.CopyTo(src, start); | |||
} | |||
/// <summary> | |||
/// 获取string | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="len"></param> | |||
/// <returns></returns> | |||
public static string GetString(ushort[] src, int start, int len) | |||
{ | |||
ushort[] temp = new ushort[len]; | |||
for (int i = 0; i < len; i++) | |||
{ | |||
temp[i] = src[i + start]; | |||
} | |||
byte[] bytesTemp = Ushorts2Bytes(temp); | |||
string res = Encoding.UTF8.GetString(bytesTemp).Trim(new char[] { '\0' }); | |||
return res; | |||
} | |||
/// <summary> | |||
/// 赋值Real类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="value"></param> | |||
public static void SetReal(ushort[] src, int start, float value) | |||
{ | |||
byte[] bytes = BitConverter.GetBytes(value); | |||
ushort[] dest = Bytes2Ushorts(bytes); | |||
dest.CopyTo(src, start); | |||
} | |||
/// <summary> | |||
/// 获取float类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <returns></returns> | |||
public static float GetReal(ushort[] src, int start) | |||
{ | |||
ushort[] temp = new ushort[2]; | |||
for (int i = 0; i < 2; i++) | |||
{ | |||
temp[i] = src[i + start]; | |||
} | |||
byte[] bytesTemp = Ushorts2Bytes(temp); | |||
float res = BitConverter.ToSingle(bytesTemp, 0); | |||
return res; | |||
} | |||
/// <summary> | |||
/// 赋值Short类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="value"></param> | |||
public static void SetShort(ushort[] src, int start, short value) | |||
{ | |||
byte[] bytes = BitConverter.GetBytes(value); | |||
ushort[] dest = Bytes2Ushorts(bytes); | |||
dest.CopyTo(src, start); | |||
} | |||
/// <summary> | |||
/// 获取short类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <returns></returns> | |||
public static short GetShort(ushort[] src, int start) | |||
{ | |||
ushort[] temp = new ushort[1]; | |||
temp[0] = src[start]; | |||
byte[] bytesTemp = Ushorts2Bytes(temp); | |||
short res = BitConverter.ToInt16(bytesTemp, 0); | |||
return res; | |||
} | |||
public static bool[] GetBools(ushort[] src, int start, int num) | |||
{ | |||
ushort[] temp = new ushort[num]; | |||
for (int i = start; i < start + num; i++) | |||
{ | |||
temp[i] = src[i + start]; | |||
} | |||
byte[] bytes = Ushorts2Bytes(temp); | |||
bool[] res = Bytes2Bools(bytes); | |||
return res; | |||
} | |||
private static bool[] Bytes2Bools(byte[] b) | |||
{ | |||
bool[] array = new bool[8 * b.Length]; | |||
for (int i = 0; i < b.Length; i++) | |||
{ | |||
for (int j = 0; j < 8; j++) | |||
{ | |||
array[i * 8 + j] = (b[i] & 1) == 1;//判定byte的最后一位是否为1,若为1,则是true;否则是false | |||
b[i] = (byte)(b[i] >> 1);//将byte右移一位 | |||
} | |||
} | |||
return array; | |||
} | |||
private static byte Bools2Byte(bool[] array) | |||
{ | |||
if (array != null && array.Length > 0) | |||
{ | |||
byte b = 0; | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (array[i]) | |||
{ | |||
byte nn = (byte)(1 << i);//左移一位,相当于×2 | |||
b += nn; | |||
} | |||
} | |||
return b; | |||
} | |||
return 0; | |||
} | |||
private static ushort[] Bytes2Ushorts(byte[] src, bool reverse = false) | |||
{ | |||
int len = src.Length; | |||
byte[] srcPlus = new byte[len + 1]; | |||
src.CopyTo(srcPlus, 0); | |||
int count = len >> 1; | |||
if (len % 2 != 0) | |||
{ | |||
count += 1; | |||
} | |||
ushort[] dest = new ushort[count]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] << 8 | srcPlus[2 * i + 1] & 0xff); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] & 0xff | srcPlus[2 * i + 1] << 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
private static byte[] Ushorts2Bytes(ushort[] src, bool reverse = false) | |||
{ | |||
int count = src.Length; | |||
byte[] dest = new byte[count << 1]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 8); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 0); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 0); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
} | |||
} |
@@ -1,9 +1,11 @@ | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Message; | |||
using NModbus; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Net.Sockets; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
@@ -107,28 +109,6 @@ namespace BPASmartClient.Modbus | |||
return -1; | |||
} | |||
//public void Readbool(ushort startAddress, ushort len, Action<bool[]> action) | |||
//{ | |||
// object result; | |||
// result = Read(startAddress, CommandType.Coils, len); | |||
// if (result != null) | |||
// { | |||
// if (result is bool[] bools) | |||
// { | |||
// if (bools.Length == len) | |||
// { | |||
// action(bools); | |||
// } | |||
// } | |||
// else if (result is bool bl) | |||
// { | |||
// List<bool> boolLists = new List<bool>(); | |||
// boolLists.Add(bl); | |||
// action(boolLists.ToArray()); | |||
// } | |||
// } | |||
//} | |||
public object Read(string address, ushort len = 1, byte slaveAddress = 1) | |||
{ | |||
if (address == null || tcpClient == null) return default(object); | |||
@@ -228,125 +208,65 @@ namespace BPASmartClient.Modbus | |||
} | |||
} | |||
//public object Read(ushort startAddress, CommandType readType, ushort num = 1, byte slaveAddress = 1) | |||
//{ | |||
// object result = new object(); | |||
// if (tcpClient == null) return result; | |||
// if (num <= 0) return result; | |||
// try | |||
// { | |||
// switch (readType) | |||
// { | |||
// case CommandType.Coils: | |||
// result = master.ReadCoils(slaveAddress, startAddress, num); | |||
// break; | |||
// case CommandType.Inputs: | |||
// result = master.ReadInputs(slaveAddress, startAddress, num); | |||
// break; | |||
// case CommandType.HoldingRegisters: | |||
// result = master.ReadHoldingRegisters(slaveAddress, startAddress, num); | |||
// break; | |||
// case CommandType.InputRegisters: | |||
// result = master.ReadInputRegisters(slaveAddress, startAddress, num); | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// if (result == null) return new object(); | |||
// if (result is bool[] bools) | |||
// { | |||
// if (bools.Length == 1) | |||
// return bools[0]; | |||
// else | |||
// return bools; | |||
// } | |||
// if (result is ushort[] ushorts) | |||
// { | |||
// if (ushorts.Length == 1) | |||
// return ushorts[0]; | |||
// else | |||
// return ushorts; | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// MessageLog.GetInstance.ShowEx($"读取地址:【{startAddress}】,读取类型:【{readType}】出错,{ex.ToString()}"); | |||
// if (ex.InnerException is SocketException) | |||
// { | |||
// tcpClient = null; | |||
// Connect(); | |||
// } | |||
// } | |||
// return result; | |||
//} | |||
//public bool Write(ushort startAddress, CommandType writeType, object InputValue, byte slaveAddress = 1) | |||
//{ | |||
// bool result = false; | |||
// if (tcpClient == null) return result; | |||
// if (!(InputValue is bool || InputValue is bool[] || InputValue is ushort || InputValue is ushort[])) return result; | |||
// try | |||
// { | |||
// switch (writeType) | |||
// { | |||
// case CommandType.Coils: | |||
// if (InputValue is bool boolValue) | |||
// master.WriteSingleCoil(slaveAddress, startAddress, boolValue); | |||
// if (InputValue is bool[] boolsValue) | |||
// master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue); | |||
// break; | |||
// case CommandType.HoldingRegisters: | |||
// if (InputValue is ushort ushortValue) | |||
// master.WriteSingleRegister(slaveAddress, startAddress, ushortValue); | |||
// if (InputValue is ushort[] ushortsValue) | |||
// { | |||
// int len = 100; | |||
// if (ushortsValue.Length > len) | |||
// { | |||
// List<ushort[]> ushortLists = new List<ushort[]>(); | |||
// for (int i = 0; i < ushortsValue.Length / len; i++) | |||
// { | |||
// ushortLists.Add(ushortsValue.Skip(0).Take(len).ToArray()); | |||
// } | |||
// int y = ushortsValue.Length % len; | |||
// if (y > 0) | |||
// { | |||
// ushortLists.Add(ushortsValue.Skip(ushortsValue.Length - y).Take(y).ToArray()); | |||
// } | |||
// foreach (var item in ushortLists) | |||
// { | |||
// master.WriteMultipleRegisters(slaveAddress, startAddress, item); | |||
// startAddress += (ushort)item.Length; | |||
// } | |||
// } | |||
// else | |||
// { | |||
// master.WriteMultipleRegisters(slaveAddress, startAddress, ushortsValue); | |||
// } | |||
// } | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
// if (ex.InnerException is SocketException) | |||
// { | |||
// tcpClient = null; | |||
// Connect(); | |||
// } | |||
// return false; | |||
// } | |||
// return true; | |||
//} | |||
#region 字符串数据读写 | |||
/// <summary> | |||
/// 赋值string | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <param name="value"></param> | |||
/// <returns></returns> | |||
public void SetString(string StartAddress, string value) | |||
{ | |||
var bytes = Encoding.UTF8.GetBytes(value); | |||
Write(StartAddress, bytes.BytesToUshorts()); | |||
} | |||
/// <summary> | |||
/// 获取string | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <param name="len"></param> | |||
/// <returns></returns> | |||
public string GetString(string StartAddress, ushort len) | |||
{ | |||
var res = Read(StartAddress, len); | |||
if (res != null && res is ushort[] ushorts) | |||
{ | |||
return Encoding.UTF8.GetString(ushorts.UshortsToBytes()).Trim(new char[] { '\0' }); | |||
} | |||
return String.Empty; | |||
} | |||
#endregion | |||
#region 浮点数数据读写 | |||
/// <summary> | |||
/// 赋值Real类型数据 | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <param name="value"></param> | |||
public void SetReal(string StartAddress, float value) | |||
{ | |||
var bytes = BitConverter.GetBytes(value); | |||
Write(StartAddress, bytes.BytesToUshorts()); | |||
} | |||
/// <summary> | |||
/// 获取float类型数据 | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <returns></returns> | |||
public float GetReal(string StartAddress) | |||
{ | |||
var res = Read(StartAddress, 2); | |||
if (res != null && res is ushort[] ushorts) | |||
{ | |||
return BitConverter.ToSingle(ushorts.UshortsToBytes(), 0); | |||
} | |||
return 0; | |||
} | |||
#endregion | |||
#region 批量数据读取 | |||
/// <summary> | |||
@@ -11,6 +11,8 @@ namespace BPASmartClient.Model | |||
public class BaseEvent : IEvent | |||
{ | |||
public int DeviceId { get; set; } | |||
public string TagName { get; set; } | |||
public DeviceClientType deviceClientType { get; set; } | |||
} | |||
} |
@@ -8,7 +8,9 @@ namespace BPASmartClient.Model.PLC | |||
{ | |||
public class ReadModel : BaseEvent | |||
{ | |||
public string Address { get; set; } | |||
public ushort Length { get; set; } | |||
public object ReadPar { get; set; } | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using BPASmartClient.Model.单片机.Enum; | |||
using BPASmartClient.Model.PLC; | |||
using BPASmartClient.Model.单片机.Enum; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
@@ -16,7 +17,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机下杯 | |||
/// </summary> | |||
public class SCChip_TakeCupEvent :BaseEvent | |||
public class SCChip_TakeCupEvent : BaseEvent | |||
{ | |||
/// <summary> | |||
/// 杯 | |||
@@ -27,7 +28,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机舵机打料 | |||
/// </summary> | |||
public class SCChip_MakeIceCreamEvent :BaseEvent | |||
public class SCChip_MakeIceCreamEvent : BaseEvent | |||
{ | |||
public IC_SE SteeringEngine { get; set; } | |||
} | |||
@@ -35,7 +36,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机舵机打开或者关闭 | |||
/// </summary> | |||
public class SCChip_SESwitchCreamEvent :BaseEvent | |||
public class SCChip_SESwitchCreamEvent : BaseEvent | |||
{ | |||
public IC_SE SteeringEngine { get; set; } | |||
public bool IsOpen { get; set; } | |||
@@ -44,7 +45,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机控制冰淇淋机器转 | |||
/// </summary> | |||
public class SCChip_RotorSwitchEvent :BaseEvent | |||
public class SCChip_RotorSwitchEvent : BaseEvent | |||
{ | |||
public bool TurnOn { get; set; } | |||
} | |||
@@ -62,4 +63,14 @@ namespace BPASmartClient.Model.单片机 | |||
{ | |||
} | |||
public class WriteMcu : WriteModel | |||
{ | |||
} | |||
public class ReadMcu : ReadModel | |||
{ | |||
} | |||
} |
@@ -0,0 +1,66 @@ | |||
using BPASmartClient.Model.PLC; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model | |||
{ | |||
public class JuicerModel | |||
{ | |||
#region 果汁机设备MORKT2 Lebai机器人 | |||
public const int JUICE2_初始位 = 10021; | |||
public const int JUICE2_检测位回原点 = 10023; | |||
public const int JUICE2_取纸杯 = 10006; | |||
public const int JUICE2_二次取杯 = 10008; | |||
public const int JUICE2_纸杯检测 = 10007; | |||
public const int JUICE2_再检测 = 10024; | |||
public const int JUICE2_接咖啡 = 10009; | |||
public const int JUICE2_放咖啡杯 = 10010; | |||
public const int JUICE2_接茶叶 = 10017; | |||
public const int JUICE2_接茶水 = 10018; | |||
public const int JUICE2_接水 = 10020; | |||
public const int JUICE2_放水杯 = 10019; | |||
public const int JUICE2_接果汁公共位 = 10011; | |||
public const int JUICE2_接1号果汁 = 10012; | |||
public const int JUICE2_接2号果汁 = 10013; | |||
public const int JUICE2_接3号果汁 = 10014; | |||
public const int JUICE2_接4号果汁 = 10015; | |||
public const int JUICE2_放果汁杯 = 10016; | |||
#endregion | |||
#region 果汁机设备 MORKT1 JAKA机器人 | |||
public const int JUICE_初始位 = 20000; | |||
public const int JUICE_取杯 = 20001; | |||
public const int JUICE_取杯检测 = 20010; | |||
public const int JUICE_接咖啡 = 20020; | |||
public const int JUICE_接1号果汁 = 20030; | |||
public const int JUICE_接2号果汁 = 20040; | |||
public const int JUICE_接3号果汁 = 20050; | |||
public const int JUICE_接4号果汁 = 20060; | |||
public const int JUICE_接茶 = 20070; | |||
public const int JUICE_接茶水 = 20075; | |||
public const int JUICE_接水 = 20080; | |||
public const int JUICE_放咖啡杯 = 20090; | |||
public const int JUICE_放果汁杯 = 20100; | |||
public const int JUICE_放茶水杯 = 20110; | |||
public const int JUICE_放杯 = 20120; | |||
public const int JUICE_放杯检测 = 20120; | |||
#endregion | |||
} | |||
public class WriteJuicer : WriteModel | |||
{ | |||
} | |||
public class ReadJuicer : ReadModel | |||
{ | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model | |||
{ | |||
public class JakaModel | |||
{ | |||
public const string SENCE_取杯 = "10000"; | |||
public const string SENCE_放杯位检测 = "10100"; | |||
public const string SENCE_取杯检测 = "11000"; | |||
public const string SENCE_接咖啡 = "12000"; | |||
public const string SENCE_接果汁1 = "12001"; | |||
public const string SENCE_接果汁2 = "12002"; | |||
public const string SENCE_接果汁3 = "12003"; | |||
public const string SENCE_接果汁4 = "12004"; | |||
public const string SENCE_接茶 = "12005"; | |||
public const string SENCE_接水 = "12006"; | |||
public const string SENCE_接茶_接水 = "12007"; | |||
public const string SENCE_放咖啡杯 = "13000";//接饮料位---放饮料过渡位 | |||
public const string SENCE_放果汁杯1 = "13001"; | |||
public const string SENCE_放果汁杯2 = "13002"; | |||
public const string SENCE_放果汁杯3 = "13003"; | |||
public const string SENCE_放果汁杯4 = "13004"; | |||
public const string SENCE_放茶水杯 = "13005"; | |||
public const string SENCE_放杯 = "14000";//放杯过渡位到-放杯 | |||
public const string SENCE_放杯检测 = "15000"; | |||
public const string SENCE_初始位 = "20000"; | |||
} | |||
public class WriteJaka : BaseEvent | |||
{ | |||
public string Address { get; set; } | |||
public object Value { get; set; } | |||
} | |||
public class ReadJaka : BaseEvent | |||
{ | |||
public string Address { get; set; } | |||
public ushort Length { get; set; } | |||
public object ReadPar { get; set; } | |||
} | |||
} | |||
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model | |||
{ | |||
public class MorksSimorderModel : BaseEvent | |||
{ | |||
public int NoodleLoc { get; set; } | |||
public int Bowloc { get; set; } | |||
} | |||
} |
@@ -21,7 +21,6 @@ namespace BPASmartClient.MorkF | |||
public StirFryBom stirFryBom = new StirFryBom();//创建获取流程的对象 | |||
List<int> resultorder = new List<int>();//调试变量 | |||
public static readonly object taskLock = new object(); | |||
/// <summary> | |||
/// 入口 | |||
/// </summary> | |||
@@ -37,8 +36,26 @@ namespace BPASmartClient.MorkF | |||
{ | |||
ActionManage.GetInstance.Register(PLCInite, "InitCommand"); | |||
ActionManage.GetInstance.Register(InitialData, "SimultaorOrder"); | |||
ActionManage.GetInstance.Register(MaterialOne, "MaterialOne"); | |||
ActionManage.GetInstance.Register(MaterialTwo, "MaterialTwo"); | |||
ActionManage.GetInstance.Register(MaterialThree, "MaterialThree"); | |||
ActionManage.GetInstance.Register(MaterialFour, "MaterialFour"); | |||
ActionManage.GetInstance.Register(MaterialFive, "MaterialFive"); | |||
ActionManage.GetInstance.Register(ManualOpenExhaust, "OpenExhaust"); | |||
ActionManage.GetInstance.Register(CloseExhaust, "CloaseExhaust"); | |||
ActionManage.GetInstance.Register(StartQX,"StartQXOne"); | |||
ActionManage.GetInstance.Register(StartQX, "StartQXTwo"); | |||
ActionManage.GetInstance.Register(ShreddCabbage, "ShreddCabbage"); | |||
ActionManage.GetInstance.Register(FryPork, "FryPork"); | |||
ActionManage.GetInstance.Register(XingBaoGu, "XingBaoGu"); | |||
ActionManage.GetInstance.Register(TakePot, "TakePot"); | |||
ActionManage.GetInstance.Register(TakePotReset, "TakePotReset"); | |||
ActionManage.GetInstance.Register(TakeMaterial, "TakeMaterial"); | |||
ActionManage.GetInstance.Register(ManualOutMeal, "OutMeal"); | |||
ActionManage.GetInstance.Register<Action>(AddOil,"AddOil"); | |||
ActionManage.GetInstance.Register(TakeOff, "TakeOff"); | |||
ActionManage.GetInstance.Register(OneBlock, "OneBlock"); | |||
ActionManage.GetInstance.Register(TwoBlock, "TwoBlock"); | |||
@@ -49,9 +66,22 @@ namespace BPASmartClient.MorkF | |||
ActionManage.GetInstance.Register(OverThreeBlock, "OverThreeBlock"); | |||
ActionManage.GetInstance.Register(OverGoOn, "OverGoOn"); | |||
ActionManage.GetInstance.Register(OverGoDown, "OverGoDown"); | |||
ActionManage.GetInstance.Register(ShreddCabbage, "ShreddCabbage"); | |||
ActionManage.GetInstance.Register(FryPork, "FryPork"); | |||
ActionManage.GetInstance.Register(XingBaoGu, "XingBaoGu"); | |||
ActionManage.GetInstance.Register(AutoModel, "AutoModel"); | |||
ActionManage.GetInstance.Register(ManualModel, "ManualModel"); | |||
ActionManage.GetInstance.Register<Action>(AddOil, "SecAddOil"); | |||
ActionManage.GetInstance.Register(TakeOff, "SecTakeOff"); | |||
ActionManage.GetInstance.Register(OneBlock, "SecOneBlock"); | |||
ActionManage.GetInstance.Register(TwoBlock, "SecTwoBlock"); | |||
ActionManage.GetInstance.Register(ThreeBlock, "SecThreeBlock"); | |||
ActionManage.GetInstance.Register(OverTurnOff, "SecOverTurnOff"); | |||
ActionManage.GetInstance.Register(OverOneBlock, "SecOverOneBlock"); | |||
ActionManage.GetInstance.Register(OverTwoBlock, "SecOverTwoBlock"); | |||
ActionManage.GetInstance.Register(OverThreeBlock, "SecOverThreeBlock"); | |||
ActionManage.GetInstance.Register(OverGoOn, "SecOverGoOn"); | |||
ActionManage.GetInstance.Register(OverGoDown, "SecOverGoDown"); | |||
ActionManage.GetInstance.Register(AutoModel, "SecAutoModel"); | |||
ActionManage.GetInstance.Register(ManualModel, "SecManualModel"); | |||
} | |||
/// <summary> | |||
/// 手撕包菜流程 | |||
@@ -129,65 +159,156 @@ namespace BPASmartClient.MorkF | |||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T6, PotActions = new List<StirFryPotAction>() { StirFryPotAction.搅拌臂下位, StirFryPotAction.快速旋转 }, During = 55 }); | |||
stirFryBom.AddAction(new StirFryAction() { Time = StirFryTime.T11, RobotActions = new List<StirFryRobotAction>() { StirFryRobotAction.灶取锅 } }); | |||
} | |||
public void TakePot() | |||
public void StartQX(object obj) | |||
{ | |||
if ((int)obj == 1) | |||
WriteData("M1.4", true); | |||
if ((int)obj == 2) | |||
WriteData("M1.7", true); | |||
} | |||
public void ManualOpenExhaust() | |||
{ | |||
WriteData("M0.7",true); | |||
} | |||
public void CloseExhaust() | |||
{ | |||
WriteData("M0.7",false); | |||
} | |||
public void TakeMaterial() | |||
{ | |||
WriteData("M14.1",true); | |||
} | |||
public void ManualOutMeal() | |||
{ | |||
WriteData("M14.2",true); | |||
} | |||
public void MaterialOne() | |||
{ | |||
WriteData("M13.0",true); | |||
} | |||
WriteData("M14.0", true); | |||
public void MaterialTwo() | |||
{ | |||
WriteData("M13.1", true); | |||
} | |||
public void MaterialThree() | |||
{ | |||
WriteData("M13.2", true); | |||
} | |||
public void MaterialFour() | |||
{ | |||
WriteData("M13.3", true); | |||
} | |||
public void MaterialFive() | |||
{ | |||
WriteData("M13.4", true); | |||
} | |||
public void AutoModel(object obj) | |||
{ | |||
WriteData("0.3", true); | |||
} | |||
public void ManualModel() | |||
{ | |||
WriteData("0.2", true); | |||
} | |||
public void AddOil(object obj) | |||
{ | |||
if ((int)obj == 1) | |||
{ | |||
Task.Run(() => { WriteData("M2.7", true); Task.Delay(4000).Wait(); WriteData("M2.7", false); }); | |||
} | |||
public void TakePotReset() | |||
if ((int)obj == 2) | |||
{ | |||
Task.Run(() => { WriteData("M3.1", true); Task.Delay(4000).Wait(); WriteData("M3.1", false); }); | |||
} | |||
} | |||
public void TakePot(object obj) | |||
{ | |||
WriteData("M14.0", true); | |||
} | |||
public void TakePotReset(object obj) | |||
{ | |||
WriteData("M14.0", false); | |||
} | |||
public void TakeOff() | |||
public void TakeOff(object obj) | |||
{ | |||
WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0001 | |||
if ((int)obj == 1) | |||
WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000 | |||
if ((int)obj == 2) | |||
WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000 | |||
} | |||
public void OneBlock() | |||
public void OneBlock(object obj) | |||
{ | |||
//WriteData("M13.1", true); | |||
// WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001 | |||
//WriteData("M0.7", false);//无订单关闭抽风机 | |||
WriteData("M13.0", true); | |||
if ((int)obj == 1) | |||
WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001 | |||
if ((int)obj == 2) | |||
WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001 | |||
} | |||
public void TwoBlock() | |||
public void TwoBlock(object obj) | |||
{ | |||
//WriteData("M13.1", false); | |||
WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0001 | |||
if ((int)obj == 1) | |||
WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010 | |||
if ((int)obj == 2) | |||
WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010 | |||
} | |||
public void ThreeBlock() | |||
public void ThreeBlock(object obj) | |||
{ | |||
// WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0001 | |||
WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false }); | |||
if ((int)obj == 1) | |||
WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011 | |||
if ((int)obj == 2) | |||
WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011 | |||
} | |||
public void OverTurnOff() | |||
public void OverTurnOff(object obj) | |||
{ | |||
WriteData("M7.0", true); | |||
if ((int)obj == 1) | |||
WriteData("M7.0", true); | |||
if ((int)obj == 2) | |||
WriteData("M7.4", true); | |||
} | |||
public void OverOneBlock() | |||
public void OverOneBlock(object obj) | |||
{ | |||
WriteData("M7.1", true); | |||
if ((int)obj == 1) | |||
WriteData("M7.1", true); | |||
if ((int)obj == 2) | |||
WriteData("M7.5", true); | |||
} | |||
public void OverTwoBlock() | |||
public void OverTwoBlock(object obj) | |||
{ | |||
WriteData("M7.2", true); | |||
if ((int)obj == 1) | |||
WriteData("M7.2", true); | |||
if ((int)obj == 2) | |||
WriteData("M7.6",true); | |||
} | |||
public void OverThreeBlock() | |||
public void OverThreeBlock(object obj) | |||
{ | |||
WriteData("M7.3", true); | |||
if ((int)obj == 1) | |||
WriteData("M7.3", true); | |||
if ((int)obj == 2) | |||
WriteData("M7.7",true); | |||
} | |||
public void OverGoOn() | |||
public void OverGoOn(object obj) | |||
{ | |||
WriteData("M8.0", true); | |||
if ((int)obj == 1) | |||
WriteData("M8.0", true); | |||
if ((int)obj == 2) | |||
WriteData("M8.4",true); | |||
} | |||
public void OverGoDown() | |||
public void OverGoDown(object obj) | |||
{ | |||
WriteData("M8.2", true); | |||
if ((int)obj == 1) | |||
WriteData("M8.2", true); | |||
if ((int)obj == 2) | |||
WriteData("M8.6", true); | |||
} | |||
public void FlowInite() | |||
{ | |||
@@ -255,6 +376,7 @@ namespace BPASmartClient.MorkF | |||
GetStatus("M2.0", new Action<bool[]>((bools) => | |||
{ | |||
morkF.KitchenOneStatus = bools[1]; | |||
morkF.KitchenSecondStatus = bools[4]; | |||
morkF.FallOilComplete = bools[8]; | |||
})); | |||
GetStatus("M8.0", new Action<bool[]>((bools) => | |||
@@ -339,7 +461,7 @@ namespace BPASmartClient.MorkF | |||
{ | |||
if (order.MorkOrder.GoodBatchings == null) return; | |||
OrderCount++; | |||
DeviceProcessLogShow($"接收到{OrderCount}次订单"); | |||
DeviceProcessLogShow($"接收到{OrderCount}次订单"); | |||
foreach (var item in order.MorkOrder.GoodBatchings) | |||
{ | |||
var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||
@@ -405,7 +527,7 @@ namespace BPASmartClient.MorkF | |||
morkF.listStirBom.RemoveAt(0); | |||
foreach (var res in bom.StirFryActions) | |||
{ | |||
DeviceProcessLogShow($"执行流程{res.Time}"); | |||
DeviceProcessLogShow($"执行流程{res.Time}"); | |||
//机器人线程 | |||
Task taskRobot = Task.Run(new Action(() => | |||
{ | |||
@@ -524,7 +646,7 @@ namespace BPASmartClient.MorkF | |||
morkF.listStirBom.RemoveAt(0); | |||
foreach (var res in bom.StirFryActions)//遍历所有流程 | |||
{ | |||
DeviceProcessLogShow($"执行流程{res.Time}"); | |||
DeviceProcessLogShow($"执行流程{res.Time}"); | |||
//机器人线程 | |||
Task taskRobot = Task.Run(new Action(() => | |||
{ | |||
@@ -647,7 +769,7 @@ namespace BPASmartClient.MorkF | |||
if (morkF.MinorOutMealComplete) | |||
{ | |||
morkF.TakePlateLock = false; | |||
morkF.PotInPlace = false; | |||
morkF.SecondPotInPlace = false; | |||
morkF.MinorProcessExcuteLock = false; | |||
morkF.MinorOrderMaterialCom = false; | |||
} | |||
@@ -718,7 +840,7 @@ namespace BPASmartClient.MorkF | |||
morkF.MainOutMealComplete = false; | |||
morkF.MinorOutMealComplete = false; | |||
// OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COOKING); | |||
DeviceProcessLogShow($"订单【{order.SuborderId}】执行取碗控制"); | |||
DeviceProcessLogShow($"订单【{order.SuborderId}】执行取碗控制"); | |||
} | |||
} | |||
} | |||
@@ -741,20 +863,43 @@ namespace BPASmartClient.MorkF | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
TakePotToKitchen(); | |||
WriteData("M1.5", false);//清洗模组1完成复位 | |||
WriteData("M2.0", false);//清洗模组2完成复位 | |||
if (!morkF.CleanModule && !morkF.KitchenOneStatus && morkF.CleanComplete) | |||
{ | |||
//取1号锅到1号灶台 | |||
TakePotToKitchen(1); | |||
morkF.CurrentPutPotLoc = 1; | |||
WriteData("M1.5", false);//清洗模组1完成复位 | |||
} | |||
if (!morkF.SecondCleanModule && !morkF.KitchenSecondStatus && morkF.SecondCleanComplete) | |||
{ | |||
//取2号锅到2号灶台 | |||
TakePotToKitchen(2); | |||
morkF.CurrentPutPotLoc = 2; | |||
WriteData("M2.0", false);//清洗模组2完成复位 | |||
} | |||
if (morkF.MainProcessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制"); | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制"); | |||
if (morkF.MinorProessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制"); | |||
while (!morkF.PutPotToKitchenComlete) | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制"); | |||
if (morkF.CurrentPutPotLoc == 1) | |||
{ | |||
Task.Delay(5).Wait(); | |||
while (!morkF.PutPotToKitchenComlete) | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
morkF.PotInPlace = morkF.PutPotToKitchenComlete;//锅到位 | |||
WriteData("M14.0", false);//机器人取锅完成复位 | |||
} | |||
if (morkF.CurrentPutPotLoc == 2) | |||
{ | |||
while (!morkF.PutPotToSecondKitchenComlete) | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
morkF.SecondPotInPlace = morkF.PutPotToSecondKitchenComlete; | |||
WriteData("M14.4", false);//机器人取锅完成复位 | |||
} | |||
morkF.PotInPlace = morkF.PutPotToKitchenComlete;//锅到位 | |||
WriteData("M14.0", false);//机器人取锅完成复位 | |||
Thread.Sleep(2000); | |||
@@ -783,7 +928,7 @@ namespace BPASmartClient.MorkF | |||
private void TakeBurdenATask() | |||
{ | |||
int loc = 0; | |||
while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位 | |||
while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
@@ -793,15 +938,24 @@ namespace BPASmartClient.MorkF | |||
TakeBurden(loc); | |||
TurnReset(loc);//转台复位 | |||
DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行到转台{loc}位置取料"); | |||
DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行到转台{loc}位置取料"); | |||
} | |||
//等待取料完成 | |||
while (!morkF.TakeMaterialComplete) | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
morkF.MainOrderMaterialCom = false; | |||
WriteData("M14.1", false);//机器人取料完成复位 | |||
if (morkF.MainProcessStatus) | |||
{ | |||
morkF.MainOrderMaterialCom = false; | |||
WriteData("M14.1", false);//机器人取料完成复位 | |||
} | |||
if (morkF.MinorProessStatus) | |||
{ | |||
morkF.MinorOrderMaterialCom = false; | |||
WriteData("M14.5", false);//机器人取料完成复位 | |||
} | |||
morkF.TurnTableLock = false;//转台互锁解除 | |||
@@ -811,7 +965,7 @@ namespace BPASmartClient.MorkF | |||
/// </summary> | |||
private void TakeBurdenBTask() | |||
{ | |||
while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位 | |||
while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
@@ -820,7 +974,7 @@ namespace BPASmartClient.MorkF | |||
int loc = order.MaterialLoc; | |||
TakeBurden(loc); | |||
TurnReset(loc);//转台复位 | |||
DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行取B料"); | |||
DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行取B料"); | |||
} | |||
//等待取料完成 | |||
while (!morkF.TakeMaterialComplete) | |||
@@ -828,7 +982,16 @@ namespace BPASmartClient.MorkF | |||
Task.Delay(5).Wait(); | |||
} | |||
morkF.MainOrderMaterialCom = false; | |||
WriteData("M14.1", false);//机器人取料完成复位 | |||
if (morkF.MainProcessStatus) | |||
{ | |||
morkF.MainOrderMaterialCom = false; | |||
WriteData("M14.1", false);//机器人取料完成复位 | |||
} | |||
if (morkF.MinorProessStatus) | |||
{ | |||
morkF.MinorOrderMaterialCom = false; | |||
WriteData("M14.5", false);//机器人取料完成复位 | |||
} | |||
morkF.TurnTableLock = false;//转台互锁解除 | |||
//while (!morkF.FallMaterialComplete)//等待倒料完成 | |||
//{ | |||
@@ -842,7 +1005,7 @@ namespace BPASmartClient.MorkF | |||
/// <exception cref="NotImplementedException"></exception> | |||
private void TakeBurdenCTask() | |||
{ | |||
while (morkF.RoobotIdle || !morkF.PotInPlace || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位 | |||
while (morkF.RoobotIdle || (!morkF.PotInPlace && !morkF.SecondPotInPlace) || !morkF.MaterialArriveComplete)//等待机器人空闲以及锅到位 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
@@ -851,7 +1014,7 @@ namespace BPASmartClient.MorkF | |||
int loc = order.MaterialLoc; | |||
TakeBurden(loc); | |||
TurnReset(loc);//转台复位 | |||
DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行取C料"); | |||
DeviceProcessLogShow($"订单【{ order.SuborderId}】,执行取C料"); | |||
} | |||
DeviceProcessLogShow($"剩余配料数量{morkF.TakeMaterialQueue.Count}"); | |||
//等待取料完成 | |||
@@ -860,7 +1023,16 @@ namespace BPASmartClient.MorkF | |||
Task.Delay(5).Wait(); | |||
} | |||
morkF.MainOrderMaterialCom = false; | |||
WriteData("M14.1", false);//机器人取料完成复位 | |||
if (morkF.MainProcessStatus) | |||
{ | |||
morkF.MainOrderMaterialCom = false; | |||
WriteData("M14.1", false);//机器人取料完成复位 | |||
} | |||
if (morkF.MinorProessStatus) | |||
{ | |||
morkF.MinorOrderMaterialCom = false; | |||
WriteData("M14.5", false);//机器人取料完成复位 | |||
} | |||
morkF.TurnTableLock = false;//转台互锁解除 | |||
//while (!morkF.FallMaterialComplete) | |||
//{ | |||
@@ -891,9 +1063,9 @@ namespace BPASmartClient.MorkF | |||
RobotOutMeal(); | |||
WriteData("M1.2", false);//供盘复位 | |||
if (morkF.MainProcessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制"); | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到清洗台控制"); | |||
if (morkF.MinorProessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制"); | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到清洗台控制"); | |||
} | |||
@@ -902,27 +1074,30 @@ namespace BPASmartClient.MorkF | |||
/// </summary> | |||
private void CleanPotTask() | |||
{ | |||
while (!morkF.PlaceRinseTableComplete || morkF.CleanModule) | |||
while (!morkF.PlaceRinseTableComplete || ((morkF.CleanModule && !morkF.MainProcessStatus) && (morkF.SecondCleanModule && !morkF.MinorProessStatus))) | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
if (morkF.MainProcessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制"); | |||
if (morkF.MinorProessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制"); | |||
WriteData("M14.2", false);//机器人出餐完成复位 | |||
//OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK); | |||
CleanModuleControl("Start"); | |||
if (morkF.MainProcessStatus)//主流程 | |||
{ | |||
WriteData("M14.2", false);//机器人2号锅出餐完成复位 | |||
CleanModuleControl("Start"); | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行清洗操作"); | |||
morkF.MainProcessFlag = false; | |||
minorReset.Set(); | |||
} | |||
else if (morkF.MinorProessStatus)//辅流程 | |||
if (morkF.MinorProessStatus) | |||
{ | |||
WriteData("M14.6", false);//机器人2号锅出餐完成复位 | |||
CleanModuleControl("Start"); | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行清洗操作"); | |||
morkF.MinorProcessFlag = false; | |||
mainReset.Set(); | |||
} | |||
//OrderChange(morkF.CurrentOrderId, ORDER_STATUS.COMPLETED_COOK); | |||
} | |||
/// <summary> | |||
/// 任务复位重启 | |||
@@ -957,12 +1132,23 @@ namespace BPASmartClient.MorkF | |||
{ | |||
TurnMachineOrientControl("Down"); | |||
while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成 | |||
if (morkF.MainProcessStatus) | |||
{ | |||
Task.Delay(5).Wait(); | |||
while (!morkF.TurnMachineDownComplete)//等待翻转机下降完成 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
WriteData("M8.3", false);//下降完成复位 | |||
} | |||
if (morkF.MinorProessStatus) | |||
{ | |||
while (!morkF.SecondTurnMachineDownComplete)//等待翻转机下降完成 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
WriteData("M8.7", false);//下降完成复位 | |||
} | |||
WriteData("M8.3", false);//下降完成复位 | |||
DeviceProcessLogShow($"翻转机下降完成"); | |||
DeviceProcessLogShow($"翻转机下降完成"); | |||
//if (morkF.MaterialCount == 3 && morkF.MainProcessStatus) | |||
//{ | |||
// morkF.MainProcessWait = true; | |||
@@ -983,11 +1169,22 @@ namespace BPASmartClient.MorkF | |||
Task.Delay(5).Wait(); | |||
} | |||
TurnMachineOrientControl("Top");//翻转机上升 | |||
while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成 | |||
if (morkF.MainProcessStatus) | |||
{ | |||
Task.Delay(5).Wait(); | |||
while (!morkF.TurnMachineUpComplete)//等待翻转机上升完成以及取料完成 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
WriteData("M8.1", false);//上升完成复位 | |||
} | |||
if (morkF.MinorProessStatus) | |||
{ | |||
while (!morkF.SecondTurnMachineUpComplete)//等待翻转机上升完成以及取料完成 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
WriteData("M8.5", false);//上升完成复位 | |||
} | |||
WriteData("M8.1", false);//上升完成复位 | |||
if (morkF.MainProcessStatus)//代表主流程执行的操作 | |||
{ | |||
if (!morkF.MainOrderMaterialCom) | |||
@@ -1007,7 +1204,7 @@ namespace BPASmartClient.MorkF | |||
} | |||
morkF.MainOrderMaterialCom = true; | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】,配料倒料完成"); | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】,配料倒料完成"); | |||
} | |||
else //辅程准备阻塞 | |||
{ | |||
@@ -1019,7 +1216,7 @@ namespace BPASmartClient.MorkF | |||
if (!morkF.MinorOrderMaterialCom) | |||
{ | |||
WriteData("M14.3", true);//倒料 | |||
while (!morkF.FallMaterialComplete)//等待倒料完成 | |||
while (!morkF.SecondFallMaterialComplete)//等待倒料完成 | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
@@ -1033,7 +1230,7 @@ namespace BPASmartClient.MorkF | |||
} | |||
morkF.MinorOrderMaterialCom = true; | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】,配料倒料完成"); | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】,配料倒料完成"); | |||
} | |||
else //主流程准备阻塞 | |||
{ | |||
@@ -1041,7 +1238,7 @@ namespace BPASmartClient.MorkF | |||
} | |||
} | |||
DeviceProcessLogShow("翻转机上升完成"); | |||
DeviceProcessLogShow("翻转机上升完成"); | |||
} | |||
private void GetStatus(string key, Action<bool[]> action) | |||
@@ -1073,41 +1270,71 @@ namespace BPASmartClient.MorkF | |||
switch (number) | |||
{ | |||
case 0: | |||
WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { false, false, false, false, false, false, false, false });//0000 0000 | |||
break; | |||
case 1: | |||
WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { true, false, false, false, false, false, false, false });//0000 0001 | |||
break; | |||
case 2: | |||
WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { false, true, false, false, false, false, false, false });//0000 0010 | |||
break; | |||
case 3: | |||
WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { true, true, false, false, false, false, false, false });//0000 0011 | |||
break; | |||
case 4: | |||
WriteData("M4.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { false, false, true, false, false, false, false, false });//0000 0100 | |||
break; | |||
case 5: | |||
WriteData("M4.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { true, false, true, false, false, false, false, false });//0000 0101 | |||
break; | |||
case 6: | |||
WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { false, true, true, false, false, false, false, false });//0000 0110 | |||
break; | |||
case 7: | |||
WriteData("M4.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { true, true, true, false, false, false, false, false });//0000 0111 | |||
break; | |||
case 8: | |||
WriteData("M4.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { false, false, false, true, false, false, false, false });//0000 1000 | |||
break; | |||
case 9: | |||
WriteData("M4.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M4.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M5.0", new bool[] { true, false, false, true, false, false, false, false });//0000 1001 | |||
break; | |||
} | |||
if (morkF.MainProcessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制"); | |||
DeviceProcessLogShow($"订单【{ morkF.MainCurrentOrderId}】执行取锅到灶台控制"); | |||
if (morkF.MinorProessStatus) | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制"); | |||
DeviceProcessLogShow($"订单【{ morkF.MinorCurrentOrderId}】执行取锅到灶台控制"); | |||
} | |||
public void TurnMaterialStore(int loc) | |||
{ | |||
@@ -1146,16 +1373,22 @@ namespace BPASmartClient.MorkF | |||
/// <summary> | |||
/// 取锅到灶台 | |||
/// </summary> | |||
public void TakePotToKitchen() | |||
public void TakePotToKitchen(int loc) | |||
{ | |||
WriteData("M14.0", true); | |||
if (loc == 1) | |||
WriteData("M14.0", true); | |||
if (loc == 2) | |||
WriteData("M14.4", true); | |||
} | |||
/// <summary> | |||
/// 机器人出餐并将锅放置清洗台位置 | |||
/// </summary> | |||
public void RobotOutMeal() | |||
{ | |||
WriteData("M14.2", true); | |||
if (morkF.MainProcessStatus) | |||
WriteData("M14.2", true);//1号锅出餐 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M14.6", true);//2号锅出餐 | |||
} | |||
/// <summary> | |||
/// 注油 | |||
@@ -1166,15 +1399,17 @@ namespace BPASmartClient.MorkF | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
WriteData("M2.7", true);//加油 | |||
if (morkF.MainProcessStatus) | |||
WriteData("M2.7", true);//加油 | |||
if (morkF.MinorProessStatus) | |||
WriteData("M3.1", true);//加油 | |||
WriteData("M0.7", true);//打开抽风机 | |||
DeviceProcessLogShow("开始注油"); | |||
while (!morkF.FallOilComplete) | |||
DeviceProcessLogShow("开始注油"); | |||
while (!morkF.FallOilComplete || !morkF.SecondOilComplete) | |||
{ | |||
Task.Delay(5).Wait(); | |||
} | |||
DeviceProcessLogShow("注油完成"); | |||
DeviceProcessLogShow("注油完成"); | |||
} | |||
/// <summary> | |||
@@ -1185,11 +1420,10 @@ namespace BPASmartClient.MorkF | |||
{ | |||
switch (orientation) | |||
{ | |||
case "Top": WriteData("M8.0", true); break; | |||
// case "Middle": WriteData("", 1); break; | |||
case "Down": WriteData("M8.2", true); break; | |||
case "Top": if (morkF.MainProcessStatus) WriteData("M8.0", true); if (morkF.MinorProessStatus) WriteData("M8.4", true); break; | |||
case "Down": if (morkF.MainProcessStatus) WriteData("M8.2", true); if (morkF.MinorProessStatus) WriteData("M8.6", true); break; | |||
} | |||
DeviceProcessLogShow($"翻转机执行{orientation}操作"); | |||
DeviceProcessLogShow($"翻转机执行{orientation}操作"); | |||
} | |||
/// <summary> | |||
/// 翻转机档位控制 | |||
@@ -1202,39 +1436,61 @@ namespace BPASmartClient.MorkF | |||
} | |||
switch (gear) | |||
{ | |||
case 0: WriteData("M7.0", true); Task.Delay(1000).Wait(); break;//关闭翻炒机 | |||
case 1: WriteData("M7.1", true); break;//翻炒机1挡 | |||
case 2: WriteData("M7.2", true); break;//翻炒机2挡 | |||
case 3: WriteData("M7.3", true); break;//翻炒机3挡 | |||
case 0: if (morkF.MainProcessStatus) WriteData("M7.0", true); Task.Delay(1000).Wait(); if (morkF.MinorProessStatus) WriteData("M7.4", true); break;//关闭翻炒机 | |||
case 1: if (morkF.MainProcessStatus) WriteData("M7.1", true); if (morkF.MinorProessStatus) WriteData("M7.5", true); break;//翻炒机1挡 | |||
case 2: if (morkF.MainProcessStatus) WriteData("M7.2", true); if (morkF.MinorProessStatus) WriteData("M7.6", true); break;//翻炒机2挡 | |||
case 3: if (morkF.MainProcessStatus) WriteData("M7.3", true); if (morkF.MinorProessStatus) WriteData("M7.7", true); break;//翻炒机3挡 | |||
} | |||
DeviceProcessLogShow($"翻转机档位调至{gear}挡"); | |||
DeviceProcessLogShow($"翻转机档位调至{gear}挡"); | |||
} | |||
/// <summary> | |||
/// 取A,B,C料 | |||
/// 倒A,B,C料 | |||
/// </summary> | |||
public void TakeBurden(int loc) | |||
{ | |||
WriteData("M14.1", true);//机器人取料 | |||
if (morkF.MainProcessStatus && morkF.PotInPlace) | |||
WriteData("M14.1", true);//机器人倒料至1号锅 | |||
if (morkF.MinorProessStatus && morkF.SecondPotInPlace) | |||
WriteData("M14.5", true);//机器人倒料至2号锅 | |||
} | |||
/// <summary> | |||
/// 清洗模组1启停控制 | |||
/// </summary> | |||
public void CleanModuleControl(string status) | |||
{ | |||
if (status == "Start") | |||
if (morkF.MainProcessStatus) | |||
{ | |||
WriteData("M1.4", true); | |||
if (status == "Start") | |||
{ | |||
WriteData("M1.4", true); | |||
} | |||
if (status == "Stop") | |||
{ | |||
WriteData("M1.4", false); | |||
} | |||
DeviceProcessLogShow($"清洗模组1执行【{status}】操作"); | |||
} | |||
if (status == "Stop") | |||
if (morkF.MinorProessStatus) | |||
{ | |||
WriteData("M1.4", false); | |||
if (status == "Start") | |||
{ | |||
WriteData("M1.7", true); | |||
} | |||
if (status == "Stop") | |||
{ | |||
WriteData("M1.7", false); | |||
} | |||
DeviceProcessLogShow($"清洗模组2执行【{status}】操作"); | |||
} | |||
DeviceProcessLogShow($"清洗模组执行【{status}】操作"); | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void SimOrder() | |||
{ | |||
} | |||
} | |||
} |
@@ -50,17 +50,30 @@ namespace BPASmartClient.MorkF | |||
/// </summary> | |||
public bool KitchenSecondStatus { get; set; } | |||
/// <summary> | |||
/// 注油完成状态 | |||
/// 锅灶1注油完成状态 | |||
/// </summary> | |||
public bool FallOilComplete { get; set; } | |||
/// <summary> | |||
/// 翻转机上升完成状态 | |||
/// 锅灶2注油完成状态 | |||
/// </summary> | |||
public bool SecondOilComplete { get; set; } | |||
/// <summary> | |||
/// 锅灶1翻转机上升完成状态 | |||
/// </summary> | |||
public bool TurnMachineUpComplete { get; set; } | |||
/// <summary> | |||
/// 翻转机下降完成状态 | |||
/// 锅灶2翻转机上升完成状态 | |||
/// </summary> | |||
public bool SecondTurnMachineUpComplete { get; set; } | |||
/// <summary> | |||
/// 锅灶1翻转机下降完成状态 | |||
/// </summary> | |||
public bool TurnMachineDownComplete { get; set; } | |||
/// <summary> | |||
/// 锅灶2翻转机下降完成状态 | |||
/// </summary> | |||
public bool SecondTurnMachineDownComplete { get; set; } | |||
/// <summary> | |||
/// 料仓旋转到位状态 | |||
/// </summary> | |||
@@ -70,18 +83,26 @@ namespace BPASmartClient.MorkF | |||
/// </summary> | |||
public bool RoobotIdle { get; set; } | |||
/// <summary> | |||
/// 放锅至灶台完成状态 | |||
/// 放锅至灶台1完成状态 | |||
/// </summary> | |||
public bool PutPotToKitchenComlete { get; set; } | |||
/// <summary> | |||
/// 放锅至灶台2完成状态 | |||
/// </summary> | |||
public bool PutPotToSecondKitchenComlete { get; set; } | |||
/// <summary> | |||
/// 机器人取料完成状态 | |||
/// </summary> | |||
public bool TakeMaterialComplete { get; set; } | |||
/// <summary> | |||
/// 机器人放锅至清洗台完成状态 | |||
/// 机器人放锅至清洗台1完成状态 | |||
/// </summary> | |||
public bool PlaceRinseTableComplete { get; set; } | |||
/// <summary> | |||
/// 机器人放锅至清洗台2完成状态 | |||
/// </summary> | |||
public bool PlaceRinseSecondTableComplete { get; set; } | |||
/// <summary> | |||
/// 订单取配料队列 | |||
/// </summary> | |||
@@ -132,10 +153,14 @@ namespace BPASmartClient.MorkF | |||
/// </summary> | |||
public bool TakeAllBurdenComplete { get; set; } | |||
/// <summary> | |||
/// 锅到位 true:到位 false:未到位 | |||
/// 锅1到位 true:到位 false:未到位 | |||
/// </summary> | |||
public bool PotInPlace { get; set; } | |||
/// <summary> | |||
/// 锅2到位 true:到位 false:未到位 | |||
/// </summary> | |||
public bool SecondPotInPlace { get; set; } | |||
/// <summary> | |||
/// true:烹饪完成 | |||
/// </summary> | |||
public bool CookingComplete { get; set; } | |||
@@ -144,10 +169,14 @@ namespace BPASmartClient.MorkF | |||
/// </summary> | |||
public bool AddOilComplete { get; set; } | |||
/// <summary> | |||
/// 倒料完成 | |||
/// 1号锅倒料完成 | |||
/// </summary> | |||
public bool FallMaterialComplete { get; set; } | |||
/// <summary> | |||
/// 2号锅倒料完成 | |||
/// </summary> | |||
public bool SecondFallMaterialComplete { get; set; } | |||
/// <summary> | |||
/// 供盘互锁 | |||
/// </summary> | |||
public bool TakePlateLock { get; set; } | |||
@@ -241,6 +270,10 @@ namespace BPASmartClient.MorkF | |||
/// 主流程执行状态 | |||
/// </summary> | |||
public bool MainProcessStatus { get; set; } | |||
/// <summary> | |||
/// 当前放锅位置 1:1号锅 2: 2号锅 | |||
/// </summary> | |||
public int CurrentPutPotLoc { get; set; } | |||
} | |||
} | |||
@@ -5,7 +5,7 @@ | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.MorkF.View" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
d:DesignHeight="600" d:DesignWidth="1300"> | |||
<UserControl.Resources> | |||
<ResourceDictionary> | |||
<ResourceDictionary.MergedDictionaries> | |||
@@ -16,30 +16,79 @@ | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="60"></RowDefinition> | |||
<RowDefinition Height="120" ></RowDefinition> | |||
<RowDefinition Height="100"></RowDefinition> | |||
<RowDefinition></RowDefinition> | |||
</Grid.RowDefinitions> | |||
<GroupBox Header="设备控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="120"> | |||
<WrapPanel Orientation="Horizontal" VerticalAlignment="Top" Margin="0,5,0,0"> | |||
<Button Content="初始化" Command="{Binding PlcInite}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="模拟订单" Command="{Binding SimulateOrder}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="自动模式" Command="{ Binding AutoModel}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="手动模式" Command="{Binding ManualModel}" Margin="10,0,10,0"></Button> | |||
<Button Content="打开抽风" Command="{Binding OpenExhaust}" Margin="10,0,10,0"></Button> | |||
<Button Content="关闭抽风" Command="{Binding CloaseExhaust}" Margin="10,0,10,0"></Button> | |||
<Button Content="料仓1" Command="{Binding MaterialOne}" Margin="10,0,10,0"></Button> | |||
<Button Content="料仓2" Command="{Binding MaterialTwo}" Margin="10,0,10,0"></Button> | |||
<Button Content="料仓3" Command="{Binding MaterialThree}" Margin="10,0,10,0"></Button> | |||
<Button Content="料仓4" Command="{Binding MaterialFour}" Margin="10,0,10,0"></Button> | |||
<Button Content="料仓5" Command="{Binding MaterialFive}" Margin="10,0,10,0"></Button> | |||
<Button Content="供盘" Command="{Binding OutPlate}" Margin="10,0,10,0"></Button> | |||
<Button Content="清洗模组1启动" Command="{Binding StartQXOne}" Margin="10,0,10,0"></Button> | |||
<Button Content="清洗模组2启动" Command="{Binding StartQXTwo}" Margin="10,10,10,0" Cursor="Hand"></Button> | |||
</WrapPanel> | |||
</GroupBox> | |||
<GroupBox Header="菜品选择" FontSize="15" Foreground="Aqua" Grid.Row="1" Margin="0,0,0,40" VerticalAlignment="Top" Height="100"> | |||
<WrapPanel Orientation="Horizontal" Height="52" VerticalAlignment="Center" > | |||
<Button Content="手撕包菜" Command="{Binding ShreddCabbage}" Margin="10,0,10,0"></Button> | |||
<Button Content="盐煎肉" Command="{Binding FryPork}" Margin="10,0,10,0"></Button> | |||
<Button Content="酱烧杏鲍菇" Command="{Binding XingBaoGu}" Margin="10,0,10,0"></Button> | |||
</WrapPanel> | |||
</GroupBox> | |||
<StackPanel Orientation="Vertical" Grid.Row="2"> | |||
<GroupBox Header="机器人控制" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="95"> | |||
<WrapPanel Orientation="Horizontal" Grid.RowSpan="2" VerticalAlignment="Top" Margin="0,5,0,0" > | |||
<Button Content="取锅" Command="{Binding TakePot}" Margin="10,0,10,0"></Button> | |||
<!--<Button Content="取锅复位" Command="{Binding TakePotReset}" Margin="10,0,10,0"></Button>--> | |||
<Button Content="取料" Command="{Binding TakeMaterial}" Margin="10,0,10,0"></Button> | |||
<Button Content="出餐" Command="{Binding OutMeal}" Margin="10,0,10,0"></Button> | |||
</WrapPanel> | |||
</GroupBox> | |||
<GroupBox Header="炒锅1" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140"> | |||
<WrapPanel VerticalAlignment="Top" Margin="0,5,0,0"> | |||
<Button Content="注油" Command="{Binding AddOil}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热关闭" Command="{Binding TempTurnOff}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热1挡" Command="{Binding OneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热2挡" Command="{Binding TwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热3挡" Command="{Binding ThreeBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机关闭" Command="{Binding OverTurnOff}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="翻炒机上升" Command="{Binding OverGoOn}" Margin="10,0,15,0" Cursor="Hand"></Button> | |||
<Button Content="翻炒机下降" Command="{Binding OverGoDown}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机1挡" Command="{Binding OverOneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机2挡" Command="{Binding OverTwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机3挡" Command="{Binding OverThreeBlock}" Margin="10,0,10,0"></Button> | |||
</WrapPanel> | |||
</GroupBox> | |||
<GroupBox Header="炒锅2" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" Height="140"> | |||
<WrapPanel VerticalAlignment="Top" Margin="0,5,0,0"> | |||
<Button Content="注油" Command="{Binding SecAddOil}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热关闭" Command="{Binding SecTempTurnOff}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热1挡" Command="{Binding SecOneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热2挡" Command="{Binding SecTwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热3挡" Command="{Binding SecThreeBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机关闭" Command="{Binding SecOverTurnOff}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="翻炒机上升" Command="{Binding SecOverGoOn}" Margin="10,0,15,0" Cursor="Hand"></Button> | |||
<Button Content="翻炒机下降" Command="{Binding SecOverGoDown}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机1挡" Command="{Binding SecOverOneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机2挡" Command="{Binding SecOverTwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机3挡" Command="{Binding SecOverThreeBlock}" Margin="10,0,10,0"></Button> | |||
</WrapPanel> | |||
</GroupBox> | |||
<StackPanel Orientation="Horizontal" Grid.Row="0"> | |||
<Button Content="初始化" Command="{Binding PlcInite}" Margin="10,0,10,0" Cursor="Hand"></Button> | |||
<Button Content="模拟订单" Command="{Binding SimulateOrder}" Margin="10,0,10,0"></Button> | |||
<Button Content="手撕包菜" Command="{Binding ShreddCabbage}" Margin="10,0,10,0"></Button> | |||
<Button Content="盐煎肉" Command="{Binding FryPork}" Margin="10,0,10,0"></Button> | |||
<Button Content="酱烧杏鲍菇" Command="{Binding XingBaoGu}" Margin="10,0,10,0"></Button> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Grid.Row="1"> | |||
<Button Content="取锅" Command="{Binding TakePot}" Margin="10,0,10,0"></Button> | |||
<Button Content="取锅复位" Command="{Binding TakePotReset}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热关闭" Command="{Binding TempTurnOff}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热1挡" Command="{Binding OneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热2挡" Command="{Binding TwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="加热3挡" Command="{Binding ThreeBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机关闭" Command="{Binding OverTurnOff}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机上升" Command="{Binding OverGoOn}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机下降" Command="{Binding OverGoDown}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机1挡" Command="{Binding OverOneBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机2挡" Command="{Binding OverTwoBlock}" Margin="10,0,10,0"></Button> | |||
<Button Content="翻炒机3挡" Command="{Binding OverThreeBlock}" Margin="10,0,10,0"></Button> | |||
</StackPanel> | |||
</Grid> | |||
</UserControl> |
@@ -14,42 +14,104 @@ namespace BPASmartClient.MorkF.ViewModel | |||
public RelayCommand PlcInite { get; set; } | |||
public RelayCommand SimulateOrder { get; set; } | |||
public RelayCommand MaterialOne { get; set; } | |||
public RelayCommand MaterialTwo { get; set; } | |||
public RelayCommand MaterialThree { get; set; } | |||
public RelayCommand MaterialFour { get; set; } | |||
public RelayCommand MaterialFive { get; set; } | |||
public RelayCommand OpenExhaust { get;set; } | |||
public RelayCommand CloaseExhaust { get; set; } | |||
public RelayCommand StartQXOne { get; set; } | |||
public RelayCommand StartQXTwo { get; set; } | |||
public RelayCommand ShreddCabbage { get; set; } | |||
public RelayCommand FryPork { get; set; } | |||
public RelayCommand XingBaoGu { get; set; } | |||
public RelayCommand TakePot { get; set; } | |||
public RelayCommand TakePotReset { get; set; } | |||
public RelayCommand TakeMaterial { get; set; } | |||
public RelayCommand OutMeal { get; set; } | |||
public RelayCommand AddOil { get; set; } | |||
public RelayCommand TempTurnOff { get; set; } | |||
public RelayCommand OneBlock { get; set; } | |||
public RelayCommand TwoBlock { get; set; } | |||
public RelayCommand ThreeBlock { get; set; } | |||
public RelayCommand OverTurnOff { get; set; } | |||
public RelayCommand OverOneBlock { get; set; } | |||
public RelayCommand OverTwoBlock { get; set; } | |||
public RelayCommand OverThreeBlock { get; set; } | |||
public RelayCommand OverGoOn { get; set; } | |||
public RelayCommand OverGoDown { get; set; } | |||
public RelayCommand ShreddCabbage { get; set; } | |||
public RelayCommand FryPork { get; set; } | |||
public RelayCommand XingBaoGu { get; set; } | |||
public RelayCommand AutoModel { get; set; } | |||
public RelayCommand ManualModel { get; set; } | |||
public RelayCommand SecAddOil { get; set; } | |||
public RelayCommand SecTempTurnOff { get; set; } | |||
public RelayCommand SecOneBlock { get; set; } | |||
public RelayCommand SecTwoBlock { get; set; } | |||
public RelayCommand SecThreeBlock { get; set; } | |||
public RelayCommand SecOverTurnOff { get; set; } | |||
public RelayCommand SecOverOneBlock { get; set; } | |||
public RelayCommand SecOverTwoBlock { get; set; } | |||
public RelayCommand SecOverThreeBlock { get; set; } | |||
public RelayCommand SecOverGoOn { get; set; } | |||
public RelayCommand SecOverGoDown { get; set; } | |||
public RelayCommand SecAutoModel { get; set; } | |||
public RelayCommand SecManualModel { get; set; } | |||
public DebugViewModel() | |||
{ | |||
PlcInite = new RelayCommand(() => { ActionManage.GetInstance.Send("InitCommand"); }); | |||
SimulateOrder = new RelayCommand(() => { ActionManage.GetInstance.Send("SimultaorOrder"); }); | |||
TakePot = new RelayCommand(() => { ActionManage.GetInstance.Send("TakePot"); }); | |||
TakePotReset = new RelayCommand(() => { ActionManage.GetInstance.Send("TakePotReset"); }); | |||
TempTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("TakeOff"); }); | |||
OneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OneBlock"); }); | |||
TwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("TwoBlock"); }); | |||
ThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("ThreeBlock"); }); | |||
OverTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTurnOff"); }); | |||
OverOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverOneBlock"); }); | |||
OverTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTwoBlock"); }); | |||
OverThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverThreeBlock"); }); | |||
OverGoOn = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoOn"); }); | |||
OverGoDown = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoDown"); }); | |||
MaterialOne= new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialOne"); }); | |||
MaterialTwo = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialTwo"); }); | |||
MaterialThree = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialThree"); }); | |||
MaterialFour = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialFour"); }); | |||
MaterialFive = new RelayCommand(() => { ActionManage.GetInstance.Send("MaterialFive"); }); | |||
OpenExhaust = new RelayCommand(() => { ActionManage.GetInstance.Send("OpenExhaust"); }); | |||
CloaseExhaust = new RelayCommand(() => { ActionManage.GetInstance.Send("CloseExhaust"); }); | |||
StartQXOne=new RelayCommand(() => { ActionManage.GetInstance.Send("StartQXOne",1); }); | |||
StartQXTwo = new RelayCommand(() => { ActionManage.GetInstance.Send("StartQXTwo",2); }); | |||
ShreddCabbage = new RelayCommand(() => { ActionManage.GetInstance.Send("ShreddCabbage"); }); | |||
FryPork = new RelayCommand(() => { ActionManage.GetInstance.Send("FryPork"); }); | |||
XingBaoGu = new RelayCommand(() => { ActionManage.GetInstance.Send("XingBaoGu"); }); | |||
} | |||
TakePot = new RelayCommand(() => { ActionManage.GetInstance.Send("TakePot"); }); | |||
TakePotReset = new RelayCommand(() => { ActionManage.GetInstance.Send("TakePotReset"); }); | |||
TakeMaterial= new RelayCommand(() => { ActionManage.GetInstance.Send("TakeMaterial"); }); | |||
OutMeal = new RelayCommand(() => { ActionManage.GetInstance.Send("OutMeal"); }); | |||
AddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 1); }); | |||
TempTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("TakeOff", 1); }); | |||
OneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OneBlock",1); }); | |||
TwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("TwoBlock",1); }); | |||
ThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("ThreeBlock",1); }); | |||
OverTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTurnOff",1); }); | |||
OverOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverOneBlock",1); }); | |||
OverTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTwoBlock",1); }); | |||
OverThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverThreeBlock",1); }); | |||
OverGoOn = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoOn",1); }); | |||
OverGoDown = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoDown",1); }); | |||
AutoModel = new RelayCommand(()=>{ActionManage.GetInstance.Send("AutoModel",1); }); | |||
ManualModel = new RelayCommand(() => { ActionManage.GetInstance.Send("ManualModel",1); }); | |||
SecAddOil = new RelayCommand(() => { ActionManage.GetInstance.Send("AddOil", 2); }); | |||
SecTempTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("TakeOff", 2); }); | |||
SecOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OneBlock", 2); }); | |||
SecTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("TwoBlock", 2); }); | |||
SecThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("ThreeBlock", 2); }); | |||
SecOverTurnOff = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTurnOff", 2); }); | |||
SecOverOneBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverOneBlock", 2); }); | |||
SecOverTwoBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverTwoBlock", 2); }); | |||
SecOverThreeBlock = new RelayCommand(() => { ActionManage.GetInstance.Send("OverThreeBlock", 2); }); | |||
SecOverGoOn = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoOn", 2); }); | |||
SecOverGoDown = new RelayCommand(() => { ActionManage.GetInstance.Send("OverGoDown", 2); }); | |||
SecAutoModel = new RelayCommand(() => { ActionManage.GetInstance.Send("AutoModel", 2); }); | |||
SecManualModel = new RelayCommand(() => { ActionManage.GetInstance.Send("ManualModel", 2); }); | |||
} | |||
} | |||
} |
@@ -377,7 +377,7 @@ namespace BPASmartClient.MorkM | |||
{ | |||
values.Add(2);//分 | |||
values.Add(0);//秒 | |||
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address =$"VW{ 116 + (loc * 6) }" , Value = values.ToArray() }); | |||
EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = $"VW{ 116 + (loc * 6) }", Value = values.ToArray() }); | |||
} | |||
else //荤菜 | |||
{ | |||
@@ -837,8 +837,8 @@ namespace BPASmartClient.MorkM | |||
if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); | |||
}), "WriteBools"); | |||
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice");//设备初始化注册 | |||
ActionManage.GetInstance.Register(new Action<object>((o) => {SimOrder(o); }), "SimOrder");//模拟订单委托注册 | |||
ActionManage.GetInstance.Register(new Action<object>((o) => { SimOrder(o); }), "SimOrder");//模拟订单委托注册 | |||
} | |||
private void WriteData(string address, object value) | |||
{ | |||
@@ -877,7 +877,7 @@ namespace BPASmartClient.MorkM | |||
public override void Stop() | |||
{ | |||
} | |||
public override void ReadData() | |||
@@ -987,7 +987,11 @@ namespace BPASmartClient.MorkM | |||
})); | |||
} | |||
public override void SimOrder() | |||
{ | |||
} | |||
#endregion | |||
@@ -51,6 +51,10 @@ | |||
<TextBox | |||
Grid.Column="1" | |||
Margin="10,0" | |||
Foreground="#9934F7f7" | |||
Background="Transparent" | |||
BorderBrush="#00c2f4" | |||
CaretBrush="Aqua" | |||
IsEnabled="{Binding IsEnable}" | |||
Text="{Binding Loc}" /> | |||
@@ -89,64 +93,70 @@ | |||
</ScrollViewer> | |||
<UniformGrid Grid.Row="1" Columns="2"> | |||
<Button | |||
Margin="10,10,10,0" | |||
Command="{Binding AddSimDataCommand}" | |||
Content="新增模拟数据" | |||
/> | |||
<Button | |||
Margin="10,10,10,0" | |||
Grid.Column="1" | |||
Command="{Binding SimOrderCommand}" | |||
Content="模拟订单" Cursor="Hand" | |||
/> | |||
<Button | |||
Margin="10,10,10,0" | |||
Command="{Binding AddSimDataCommand}" | |||
Content="新增模拟数据" | |||
/> | |||
</UniformGrid> | |||
</StackPanel> | |||
</Grid> | |||
<Grid Grid.Column="1" Margin="20,0,0,0"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition Height="80" /> | |||
<RowDefinition Height="80" /> | |||
<RowDefinition Height="80" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal"> | |||
<StackPanel Orientation="Vertical" > | |||
<!--#region 控制按钮--> | |||
<Button | |||
Margin="10,10,10,0" | |||
Margin="0,10,10,0" | |||
Command="{Binding InitCommand}" | |||
Content="初始化" Cursor="Hand" | |||
Width="200" | |||
VerticalAlignment="Center" | |||
HorizontalAlignment="Left" | |||
Content="设备初始化" Cursor="Hand" | |||
Grid.Row="0" | |||
/> | |||
<Button | |||
Margin="10,10,10,0" | |||
<CheckBox | |||
Margin="0,10,0,0" | |||
Grid.Row="1" | |||
Height="20" | |||
VerticalAlignment="Center" | |||
HorizontalAlignment="Left" | |||
Background="#FF2AB2E7" | |||
Content="启用本地模拟程序" | |||
FontSize="14" | |||
Foreground="#00c2f4" | |||
IsChecked="{Binding EnableLocalSimOrder}" | |||
/> | |||
<!--<Button | |||
Margin="10,5,10,0" | |||
Command="{Binding InitCommand}" | |||
Content="停止" | |||
/> | |||
/>--> | |||
<Button | |||
<!--<Button | |||
x:Name="button_loop" | |||
Margin="10,10,10,0" | |||
Command="{Binding LoopSimOrderCommand}" | |||
Content="{Binding LoopOrderButtonContent}" | |||
/> | |||
/>--> | |||
<!--#endregion--> | |||
</StackPanel> | |||
<CheckBox | |||
Grid.Row="2" | |||
Height="20" | |||
VerticalAlignment="Center" | |||
Background="#FF2AB2E7" | |||
Content="启用本地模拟程序" | |||
FontSize="14" | |||
Foreground="#00c2f4" | |||
IsChecked="{Binding EnableLocalSimOrder}" | |||
/> | |||
</Grid> | |||
</Grid> | |||
@@ -512,12 +512,12 @@ namespace BPASmartClient.MorkS | |||
//新增,待测试 | |||
//if (mORKS.RbOutMealComplete) | |||
//{ | |||
// ResetCookComplete(); | |||
// mORKS.CookCompleteFlatBit = false; | |||
// DeviceProcessLogShow("取餐过程中复位出餐完成信号"); | |||
//} | |||
if (mORKS.RbOutMealComplete) | |||
{ | |||
ResetCookComplete(); | |||
mORKS.CookCompleteFlatBit = false; | |||
DeviceProcessLogShow("取餐过程中复位出餐完成信号"); | |||
} | |||
mORKS.OutMealId = mORKS.IngredientsCompleteId; | |||
@@ -734,6 +734,26 @@ namespace BPASmartClient.MorkS | |||
await Task.Delay(1000); | |||
WriteData("M0.0", false); | |||
} | |||
public override void SimOrder() | |||
{ | |||
EventBus.EventBus.GetInstance().Subscribe<MorksSimorderModel>(0, delegate (IEvent @event, EventCallBackHandle callBackHandle) | |||
{ | |||
if (@event != null && @event is MorksSimorderModel msm) | |||
{ | |||
string guid = Guid.NewGuid().ToString(); | |||
if (msm.NoodleLoc >= 1 && msm.NoodleLoc <= 5) | |||
{ | |||
mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.NoodleLoc, SuborderId = guid }); | |||
} | |||
if (msm.Bowloc >= 10 && msm.Bowloc <= 11) | |||
{ | |||
mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.Bowloc, SuborderId = guid }); | |||
} | |||
} | |||
}); | |||
} | |||
#endregion | |||
@@ -15,18 +15,60 @@ | |||
<vm:DebugViewModel /> | |||
</UserControl.DataContext> | |||
<Grid> | |||
<UserControl.Resources> | |||
<Style x:Key="TextboxStyle" TargetType="TextBox"> | |||
<Setter Property="FontSize" Value="18" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="Foreground" Value="{StaticResource TitleBorderColor}" /> | |||
<Setter Property="Width" Value="150" /> | |||
<Setter Property="BorderBrush" Value="{StaticResource TitleBorderColor}" /> | |||
<Setter Property="BorderThickness" Value="1" /> | |||
<Setter Property="CaretBrush" Value="Aqua" /> | |||
</Style> | |||
</UserControl.Resources> | |||
<Grid Margin="20"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="35" /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<Button | |||
Grid.Row="0" | |||
Width="150" | |||
Margin="10,0,0,0" | |||
HorizontalAlignment="Left" | |||
Command="{Binding InitCommand}" | |||
Content="初始化设备" | |||
Style="{StaticResource ButtonStyle}" /> | |||
<StackPanel> | |||
<StackPanel Margin="10,0,0,20" Orientation="Horizontal"> | |||
<TextBlock | |||
FontSize="18" | |||
Foreground="{StaticResource TitleBorderColor}" | |||
Text="面条位置:" /> | |||
<TextBox Style="{StaticResource TextboxStyle}" Text="{Binding NoodleLoc}" /> | |||
</StackPanel> | |||
<StackPanel Margin="10,0,0,20" Orientation="Horizontal"> | |||
<TextBlock | |||
FontSize="18" | |||
Foreground="{StaticResource TitleBorderColor}" | |||
Text="面碗位置:" /> | |||
<TextBox Style="{StaticResource TextboxStyle}" Text="{Binding BowlLoc}" /> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal"> | |||
<Button | |||
Grid.Row="0" | |||
Width="130" | |||
HorizontalAlignment="Left" | |||
Command="{Binding SimOrderCommand}" | |||
Content="模拟订单" | |||
Style="{StaticResource ButtonStyle}" /> | |||
<Button | |||
Grid.Row="0" | |||
Width="120" | |||
HorizontalAlignment="Left" | |||
Command="{Binding InitCommand}" | |||
Content="初始化设备" | |||
Style="{StaticResource ButtonStyle}" /> | |||
</StackPanel> | |||
</StackPanel> | |||
</Grid> | |||
</UserControl> |
@@ -4,8 +4,10 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.EventBus; | |||
namespace BPASmartClient.MorkS.ViewModel | |||
{ | |||
@@ -14,8 +16,22 @@ namespace BPASmartClient.MorkS.ViewModel | |||
public DebugViewModel() | |||
{ | |||
InitCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("InitDevice"); }); | |||
SimOrderCommand = new RelayCommand(() => | |||
{ | |||
new MorksSimorderModel() { Bowloc = this.BowlLoc, NoodleLoc = this.NoodleLoc }.Publish(); | |||
}); | |||
} | |||
public RelayCommand InitCommand { get; set; } | |||
public RelayCommand SimOrderCommand { get; set; } | |||
public int NoodleLoc { get { return _mNoodleLoc; } set { _mNoodleLoc = value; OnPropertyChanged(); } } | |||
private int _mNoodleLoc = 1; | |||
public int BowlLoc { get { return _mBowlLoc; } set { _mBowlLoc = value; OnPropertyChanged(); } } | |||
private int _mBowlLoc = 10; | |||
} | |||
} |
@@ -6,4 +6,11 @@ | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Juicer\BPASmartClient.Juicer.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,8 +0,0 @@ | |||
using System; | |||
namespace BPASmartClient.MorkTLebaiJC | |||
{ | |||
public class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,869 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Linq; | |||
using System.Threading; | |||
using System.Collections.Concurrent; | |||
using System.Diagnostics; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Device; | |||
using BPA.Message.Enum; | |||
using BPA.Message; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.EventBus; | |||
using static BPASmartClient.EventBus.EventBus; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model.乐白机器人; | |||
using BPASmartClient.Model.单片机; | |||
namespace BPASmartClient.MorkTLebaiJC | |||
{ | |||
/* | |||
* 冰淇淋咖啡机组合套装 | |||
* 物料位置: | |||
* 1:冰淇料 | |||
* 2:冰淇淋杯 | |||
* 5:咖啡 | |||
* 6:咖啡杯 | |||
* 9: 茶 | |||
* 10: 茶杯 | |||
*/ | |||
public class Control_MORKJC2 : BaseDevice | |||
{ | |||
//private CoffeEndCook coffeEndCook = new CoffeEndCook();//模拟咖啡制作成功 | |||
//咖啡机主控程序 | |||
//private CoffeeMachine coffeeMachine; | |||
//物料存放位置 | |||
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | |||
//容器位置 | |||
private string holderLoc; | |||
/// <summary> | |||
/// 获取乐百机器人的数据 | |||
/// </summary> | |||
//SignalResult lebai = new SignalResult(); | |||
//主料位置 | |||
private string mainMaterialLoc; | |||
//子订单ID | |||
private string subOrderId; | |||
private bool enableFunny = false; | |||
private DateTime lastRecvdOrder = DateTime.Now; | |||
private bool working = false; | |||
/// <summary> | |||
/// 果汁机做法,true:热饮,false:冷饮 | |||
/// </summary> | |||
private bool GuMake = false; | |||
//private SerialPortClient commProxy; | |||
public void ConnectOk() | |||
{ | |||
} | |||
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>(); | |||
public void Init() | |||
{ | |||
//ActionManage.GetInstance.Register(new Action<object>((s) => | |||
//{ | |||
// if (s is DrCoffeeDrinksCode cf) | |||
// { | |||
// DoCoffee(); | |||
// } | |||
// else if (s is Dictionary<string, string> ms) | |||
// { | |||
// if (ms.ContainsKey("Button")) | |||
// { | |||
// switch (ms["Button"]) | |||
// { | |||
// case "启动示教": | |||
// JuicerModel.GetInstance.StartTeachMode(); | |||
// break; | |||
// case "停止示教": | |||
// JuicerModel.GetInstance.EndtTeachMode(); | |||
// break; | |||
// case "启动机器人": | |||
// JuicerModel.GetInstance.StartRobot(); | |||
// break; | |||
// case "急停": | |||
// JuicerModel.GetInstance.EStopRobot(); | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// } | |||
// } | |||
//}), "SimCoffee"); | |||
//构建所有商品物料信息 | |||
batchings = PolymerBatching.BuildAll(); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, CoffeEndCookHandle); | |||
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); | |||
//一系列外围基础配置 | |||
var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value; | |||
var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value; | |||
//咖啡机创建 | |||
//coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee)); | |||
Main(); | |||
ReadData(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
while (IsHealth && (morkOrderPushes.Count > 0)) | |||
{ | |||
working = true; | |||
if (morkOrderPushes.TryDequeue(out MorkOrderPush order)) | |||
{ | |||
MessageLog.GetInstance.Show($"开始制作订单[{order.SortNum}]"); | |||
//商品类型 | |||
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; | |||
//子订单ID | |||
subOrderId = order.SuborderId; | |||
//遍历物料 | |||
foreach (var item in order.GoodBatchings) | |||
{ | |||
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||
if (res != null) | |||
{ | |||
//获取主料和容器位置 | |||
switch (batchings[res.BatchingLoc].BatchingClass) | |||
{ | |||
case BATCHING_CLASS.HOLDER: | |||
holderLoc = res.BatchingLoc; | |||
break; | |||
case BATCHING_CLASS.MAIN_MATERIAL: | |||
// mainMaterialLoc ="1"; | |||
mainMaterialLoc = res.BatchingLoc; | |||
//验证商品是咖啡还是冰淇淋 | |||
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER) | |||
{ | |||
//获取当前物料所属商品类型 | |||
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
//根据商品类型执行具体制作流程 | |||
switch (currentGoodsType) | |||
{ | |||
case GOODS_TYPE.COFFEE: | |||
DoCoffee(); | |||
break; | |||
case GOODS_TYPE.JUICE: | |||
GuMake = order.MakeID == "2"; | |||
DoJuicer(); | |||
break; | |||
case GOODS_TYPE.TEA: | |||
DoTea(); | |||
break; | |||
case GOODS_TYPE.WATER: | |||
DoWater(); | |||
break; | |||
case GOODS_TYPE.NEITHER: | |||
MessageLog.GetInstance.Show("未知的商品类型"); | |||
break; | |||
} | |||
} | |||
working = false; | |||
lastRecvdOrder = DateTime.Now; | |||
} | |||
Thread.Sleep(1000); | |||
}), "订单制作"); | |||
} | |||
public void Main() | |||
{ | |||
//咖啡机开启主线程 | |||
//coffeeMachine.Start(); | |||
//开始心跳刷新,根据咖啡机及冰淇淋机来判断 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//GeneralConfig.Healthy = | |||
// JuicerModel.GetInstance.IsConnected && | |||
// MorkCStatus.GetInstance().CanDo && | |||
// JuicerHelper.GetInstance.IsOpen && | |||
// MCUSerialHelper.GetInstance.IsOpen; | |||
//GeneralConfig.Healthy = true; | |||
Thread.Sleep(100); | |||
}), "MORK-IC心跳刷新"); | |||
//ThreadManage.GetInstance.Start(new Action(() => | |||
//{ | |||
// while (!JuicerModel.GetInstance.IsConnected) | |||
// { | |||
// Thread.Sleep(10); | |||
// } | |||
// //Sence(JuicerModel.SENCE_欢迎); | |||
//}), "MORK-JC欢迎"); | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | |||
} | |||
public void DataParse<T>(T order) | |||
{ | |||
if (order is MorkOrderPush morkOrderPush) | |||
{ | |||
morkOrderPushes.Enqueue(morkOrderPush); | |||
} | |||
} | |||
/// <summary> | |||
/// 验证当前是做咖啡还是做冰淇淋 | |||
/// </summary> | |||
/// <param name="batchingLoc">物料位置</param> | |||
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc) | |||
{ | |||
if (batchings.ContainsKey(batchingLoc)) | |||
return batchings[batchingLoc].GoodsType; | |||
return GOODS_TYPE.NEITHER; | |||
} | |||
private AutoResetEvent are = new AutoResetEvent(false); | |||
private void Wait(int value = 101) | |||
{ | |||
while (!((bool)peripheralStatus["RobotOK"] && (int)peripheralStatus["RobotValue"] == value)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
} | |||
private void Sence(int sen) | |||
{ | |||
new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = sen }.Publish(); | |||
} | |||
private T GetStatus<T>(string key) | |||
{ | |||
if (peripheralStatus.ContainsKey(key)) | |||
{ | |||
if (peripheralStatus[key] != null) | |||
{ | |||
return (T)(peripheralStatus[key]); | |||
} | |||
} | |||
return default; | |||
} | |||
int[] devStatusBy = new int[2] { 0, 0 }; | |||
bool outCupCheck = false;//放纸杯位置有无判断 | |||
/// <summary> | |||
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确 | |||
/// </summary> | |||
int bSensorInput; | |||
/// <summary> | |||
/// 延迟的超时时间 | |||
/// </summary> | |||
DateTime delayTimeOut; | |||
/// <summary> | |||
/// 做咖啡 | |||
/// </summary> | |||
private void DoCoffee() | |||
{ | |||
#region 接咖啡流程 | |||
are.Reset(); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
MessageLog.GetInstance.Show("咖啡杯取杯完成"); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接咖啡); | |||
Wait(); | |||
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水 | |||
//Task.Delay(10000).Wait();//模拟接咖啡 | |||
//coffeEndCook.Publish();//模拟咖啡制作完成 | |||
are.WaitOne(1000 * 360); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放咖啡杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("咖啡制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 做茶 | |||
/// </summary> | |||
private void DoTea() | |||
{ | |||
#region 接茶流程 | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
MessageLog.GetInstance.Show("取茶杯完成"); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接茶叶); | |||
Wait(); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 90 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 150 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 90 }.Publish(); | |||
Thread.Sleep(3000); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接茶水); | |||
Wait(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = true }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(46000); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放水杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("茶水制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 接开水 | |||
/// </summary> | |||
private void DoWater() | |||
{ | |||
#region 接水流程 | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接水); | |||
Wait(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = true }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(46000); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
//添加控制接水机构程序 | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放水杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("纯净水制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 果汁机控制信号 | |||
/// </summary> | |||
private byte JuicerNum; | |||
/// <summary> | |||
/// 做果汁 | |||
/// </summary> | |||
private void DoJuicer() | |||
{ | |||
#region 接果汁流程 | |||
are.Reset(); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
int JuicerNum1 = int.Parse(mainMaterialLoc); | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x00; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x01; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接1号果汁); | |||
Wait(); | |||
break; | |||
case 53: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x02; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x03; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接2号果汁); | |||
Wait(); | |||
break; | |||
case 54: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x04; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x05; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接3号果汁); | |||
Wait(); | |||
break; | |||
case 55: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x06; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x07; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接4号果汁); ; | |||
Wait(); | |||
break; | |||
default: | |||
JuicerNum = 0x00; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE_接1号果汁); | |||
Wait(); | |||
break; | |||
} | |||
var devStatus = GetStatus<int[]>("GetDeviceStatus"); | |||
var devStatus1 = Convert.ToString(devStatus[0], 2); | |||
var devStatus2 = devStatus[1]; | |||
if (devStatus1.IndexOf("0") == 1 && devStatus2 == 0) | |||
{ | |||
new WriteJuicer() { Value = JuicerNum }.Publish(); | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (!(devStatusBy[1] == 0)) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (devStatusBy.Length != 2) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
} | |||
} | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
Thread.Sleep(5000); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放果汁杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("果汁制作完成"); | |||
} | |||
////模拟果汁 | |||
//Thread.Sleep(15000); | |||
//while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
//{ | |||
// if (!outCupCheck) | |||
// MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
// outCupCheck = true; | |||
//} | |||
//outCupCheck = false; | |||
//new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
//Sence(JuicerModel.JUICE2_放果汁杯); | |||
//Wait(); | |||
//OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
//MessageLog.GetInstance.Show("果汁制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 取杯的次数 | |||
/// </summary> | |||
private int nCnt; | |||
private int checkCnt;//检测次数 | |||
public override DeviceClientType DeviceType => throw new NotImplementedException(); | |||
/// <summary> | |||
/// 取杯流程 | |||
/// </summary> | |||
/// <returns>0:无意义,1:取杯成功 2:取杯失败</returns> | |||
private int takeCup() | |||
{ | |||
try | |||
{ | |||
nCnt = 0; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_初始位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_取纸杯); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_纸杯检测); | |||
Wait(); | |||
nCnt++; | |||
Thread.Sleep(2000); | |||
while (checkCnt < 3) | |||
{ | |||
if (!GetStatus<bool>("GetInput")) | |||
{ | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_再检测); | |||
Wait(); | |||
} | |||
else | |||
{ | |||
break; | |||
} | |||
checkCnt++; | |||
} | |||
checkCnt = 0; | |||
while (!GetStatus<bool>("GetInput")) //读取传感器的值 | |||
{ | |||
if (nCnt > 3) | |||
{ | |||
nCnt = 0; | |||
MessageLog.GetInstance.ShowEx("三次取杯失败,回原点"); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_检测位回原点); | |||
Wait(); | |||
return 2; | |||
} | |||
else | |||
{ | |||
nCnt++; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_二次取杯); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_纸杯检测); | |||
Wait(); | |||
checkCnt = 0; | |||
while (checkCnt < 3) | |||
{ | |||
if (!GetStatus<bool>("GetInput")) | |||
{ | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_再检测); | |||
Wait(); | |||
} | |||
else | |||
{ | |||
checkCnt = 0; | |||
return 1; | |||
} | |||
checkCnt++; | |||
} | |||
} | |||
Thread.Sleep(1000); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.Show(ex.ToString()); | |||
} | |||
return 1; | |||
} | |||
/// <summary> | |||
/// 放杯 | |||
/// </summary> | |||
/// <returns>0:无意义 1:放杯成功 2:执行失败(传感器还有信号) 3:放杯异常</returns> | |||
private int putCup() | |||
{ | |||
try | |||
{ | |||
if (GetStatus<bool>("RobotValue1")) return 2; | |||
Sence(JuicerModel.JUICE_放杯); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish(); | |||
Sence(JuicerModel.JUICE_放杯检测); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish(); | |||
if (GetStatus<bool>("GetInput2")) | |||
{ | |||
return 1; | |||
} | |||
else | |||
{ | |||
return 3; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.Show(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 检测放杯位,是否有杯子 | |||
/// </summary> | |||
/// <returns>0:无意义 1:没有杯子 2:有杯子 </returns> | |||
private int checkCup() | |||
{ | |||
try | |||
{ | |||
while (GetStatus<bool>("RobotValue1")) | |||
{ | |||
Thread.Sleep(100); | |||
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 1) return 2; | |||
} | |||
MessageLog.GetInstance.Show("放杯位有杯子未取走,等待取走,最多等待60s,即跳出流程"); | |||
return 1; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.Show(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
private void CoffeEndCookHandle(IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
are.Set(); | |||
} | |||
//public void ReadData() | |||
//{ | |||
// //ThreadManage.GetInstance.StartLong(new Action(() => | |||
// //{ | |||
// // lebai = JuicerModel.GetInstance.GetValueAsync(); | |||
// // JuicerModel.GetInstance.GetRobotModeStatus(); | |||
// // //JuicerModel.GetInstance.GetInput(); | |||
// // Thread.Sleep(100); | |||
// //}), "乐百机器人数据读取", true); | |||
//} | |||
public void SimOrder<T>(T simOrder) | |||
{ | |||
//if (morkOrderPushes.Count > 0) | |||
//{ | |||
// morkOrderPushes.Clear(); | |||
//} | |||
//morkOrderPushes.Enqueue(simOrder as MorkOrderPush); | |||
} | |||
/// <summary> | |||
/// IOT 广播消息命令 | |||
/// </summary> | |||
//public void IotBroadcast<T>(T broadcast) | |||
//{ | |||
// if (broadcast != null && broadcast is IOTCommandModel iOTCommand) | |||
// { | |||
// switch (iOTCommand.CommandName) | |||
// { | |||
// case 0://控制类 | |||
// if (iOTCommand.CommandValue != null) | |||
// { | |||
// if (iOTCommand.CommandValue.ContainsKey("SimOrder")) | |||
// { | |||
// //SimOrder(new SimOrderData { NoodleLoc = 1, BowlLoc = 10 }); | |||
// } | |||
// } | |||
// break; | |||
// case 1://设置属性 | |||
// break; | |||
// case 2://通知消息 | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// } | |||
//} | |||
public override void DoMain() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void ReadData() | |||
{ | |||
} | |||
public override void MainTask() | |||
{ | |||
} | |||
public override void ResetProgram() | |||
{ | |||
} | |||
public override void SimOrder() | |||
{ | |||
} | |||
public class SimOrderData | |||
{ | |||
public string id { get; set; } | |||
public int OrderStatus { get; set; } | |||
public string Loc { get; set; } | |||
public MorkOrderPush morkOrder { get; set; } | |||
public SimOrderData() | |||
{ | |||
id = Guid.NewGuid().ToString(); | |||
OrderStatus = 0; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,152 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkTLebaiJC | |||
{ | |||
internal enum GOODS_TYPE | |||
{ | |||
/// <summary> | |||
/// 未知 | |||
/// </summary> | |||
NEITHER, | |||
/// <summary> | |||
/// 咖啡 | |||
/// </summary> | |||
COFFEE, | |||
/// <summary> | |||
/// 果汁 | |||
/// </summary> | |||
JUICE, | |||
/// <summary> | |||
/// 茶水 | |||
/// </summary> | |||
TEA, | |||
/// <summary> | |||
/// 水 | |||
/// </summary> | |||
WATER, | |||
/// <summary> | |||
/// 杯子 | |||
/// </summary> | |||
CUP | |||
} | |||
internal enum BATCHING_CLASS | |||
{ | |||
HOLDER, | |||
MAIN_MATERIAL, | |||
} | |||
internal class PolymerBatching | |||
{ | |||
internal const string Juicer_MAIN_BATCHIN1_LOC = "52"; | |||
internal const string Juicer_MAIN_BATCHIN2_LOC = "53"; | |||
internal const string Juicer_MAIN_BATCHIN3_LOC = "54"; | |||
internal const string Juicer_MAIN_BATCHIN4_LOC = "55"; | |||
//internal const string Juicer_MAIN_BATCHIN5_LOC = "56"; | |||
//internal const string Juicer_MAIN_BATCHIN6_LOC = "57"; | |||
//internal const string Juicer_MAIN_BATCHIN7_LOC = "58"; | |||
//internal const string Juicer_MAIN_BATCHIN8_LOC = "59"; | |||
internal const string COFFEE_HOLDER_LOC = "30"; | |||
internal const string TEA_HOLDER_LOC = "51"; | |||
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() { | |||
{"1", GOODS_TYPE.COFFEE}, | |||
{"2", GOODS_TYPE.COFFEE}, | |||
{"3", GOODS_TYPE.COFFEE}, | |||
{"4", GOODS_TYPE.COFFEE}, | |||
{"5", GOODS_TYPE.COFFEE}, | |||
{"6", GOODS_TYPE.COFFEE}, | |||
{"7", GOODS_TYPE.COFFEE}, | |||
{"8", GOODS_TYPE.COFFEE}, | |||
{"9", GOODS_TYPE.COFFEE}, | |||
{"10",GOODS_TYPE.COFFEE}, | |||
{"11",GOODS_TYPE.COFFEE}, | |||
{"12",GOODS_TYPE.COFFEE}, | |||
{"13",GOODS_TYPE.COFFEE}, | |||
{"14",GOODS_TYPE.COFFEE}, | |||
{"15",GOODS_TYPE.COFFEE}, | |||
{"16",GOODS_TYPE.COFFEE}, | |||
{"17",GOODS_TYPE.COFFEE}, | |||
{"18",GOODS_TYPE.COFFEE}, | |||
{"19",GOODS_TYPE.COFFEE}, | |||
{"20",GOODS_TYPE.COFFEE}, | |||
{"21",GOODS_TYPE.COFFEE}, | |||
{"22",GOODS_TYPE.COFFEE}, | |||
{"23",GOODS_TYPE.COFFEE}, | |||
{"24",GOODS_TYPE.COFFEE}, | |||
{"25",GOODS_TYPE.COFFEE}, | |||
{ COFFEE_HOLDER_LOC,GOODS_TYPE.CUP}, | |||
{"56",GOODS_TYPE.TEA }, | |||
{"61",GOODS_TYPE.WATER }, | |||
{Juicer_MAIN_BATCHIN1_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN2_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN3_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN4_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN5_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN6_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN7_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN8_LOC,GOODS_TYPE.JUICE}, | |||
}; | |||
public GOODS_TYPE GoodsType { get; set; } | |||
public BATCHING_CLASS BatchingClass { get; set; } | |||
private string loc; | |||
public string Loc | |||
{ | |||
get { return loc; } | |||
set | |||
{ | |||
loc = value; | |||
if (GOODS_TYPES.ContainsKey(loc)) | |||
GoodsType = GOODS_TYPES[loc]; | |||
switch (loc) | |||
{ | |||
case COFFEE_HOLDER_LOC: | |||
case TEA_HOLDER_LOC: | |||
BatchingClass = BATCHING_CLASS.HOLDER; | |||
break; | |||
default: | |||
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL; | |||
break; | |||
} | |||
} | |||
} | |||
internal static Dictionary<string, PolymerBatching> BuildAll() | |||
{ | |||
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>(); | |||
foreach (var item in GOODS_TYPES) | |||
{ | |||
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key }); | |||
} | |||
return temp; | |||
} | |||
//internal static IC_SE GetIceCreamSE(string loc, out string sence) | |||
//{ | |||
// switch (loc) | |||
// { | |||
// case Juicer_MAIN_BATCHIN1_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// case Juicer_MAIN_BATCHIN2_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁2; | |||
// return IC_SE.SE_2; | |||
// case Juicer_MAIN_BATCHIN3_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁3; | |||
// return IC_SE.SE_3; | |||
// default: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// } | |||
//} | |||
} | |||
} |
@@ -33,7 +33,7 @@ namespace BPASmartClient.MorkT | |||
public override void DoMain() | |||
{ | |||
if(Json<KeepDataBase>.Data.IsVerify) | |||
if (Json<KeepDataBase>.Data.IsVerify) | |||
{ | |||
IsHealth = true; | |||
} | |||
@@ -88,18 +88,18 @@ namespace BPASmartClient.MorkT | |||
}); | |||
} | |||
MakeCoffeeProcess(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> | |||
{ | |||
if(o != null && o.Length > 0 && o[0] is bool resultValue) | |||
{ | |||
if(!resultValue)//取餐口有空余位置 | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (o) => | |||
{ | |||
if (o != null && o.Length > 0 && o[0] is bool resultValue) | |||
{ | |||
if (!resultValue)//取餐口有空余位置 | |||
{ | |||
MakeIceCreamProcess(); | |||
MakeCoffeeComplete(); | |||
} | |||
} | |||
}); | |||
MakeIceCreamProcess(); | |||
MakeCoffeeComplete(); | |||
} | |||
} | |||
}); | |||
} | |||
@@ -115,7 +115,7 @@ namespace BPASmartClient.MorkT | |||
GetStatus("RobotMode", new Action<object>((o) => | |||
{ | |||
if (o is ELebaiRModel eLebaiRModel) | |||
if (o is ELebaiRModel eLebaiRModel) | |||
{ | |||
morkT.RobotMode = eLebaiRModel; | |||
} | |||
@@ -288,7 +288,7 @@ namespace BPASmartClient.MorkT | |||
morkT.batchings = PolymerBatching.BuildAll(); | |||
//商品类型 | |||
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; | |||
foreach (var item in order.MorkOrder.GoodBatchings) | |||
{ | |||
var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||
@@ -338,7 +338,7 @@ namespace BPASmartClient.MorkT | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
@@ -355,9 +355,9 @@ namespace BPASmartClient.MorkT | |||
return morkT.batchings[batchingLoc].GoodsType; | |||
return GOODS_TYPE.NEITHER; | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
@@ -395,7 +395,7 @@ namespace BPASmartClient.MorkT | |||
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); | |||
GetAndCheeckCoffe(orderLoc);//取咖啡杯 | |||
if (!morkT.GetCoffeeCup) return; | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点 | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051 }); //接咖啡后回原点 | |||
Wait(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); | |||
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() {DeviceId = DeviceId, DrinkCode = (Model.咖啡机.Enum.DrCoffeeDrinksCode)int.Parse(orderLoc.Loc) });//接咖啡控制 | |||
@@ -404,7 +404,7 @@ namespace BPASmartClient.MorkT | |||
} | |||
} | |||
} | |||
@@ -453,7 +453,7 @@ namespace BPASmartClient.MorkT | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10031 }); //SENCE_取咖啡杯 | |||
Wait(); | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId= DeviceId ,Cup = IC_CUP.CUP_COFFEE});//落碗控制 | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent { DeviceId = DeviceId, Cup = IC_CUP.CUP_COFFEE });//落碗控制 | |||
Thread.Sleep(500); | |||
DeviceProcessLogShow("尝试取咖啡杯!"); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); | |||
@@ -465,7 +465,7 @@ namespace BPASmartClient.MorkT | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }, (o) => { }); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent { DeviceId = DeviceId, Pin = 1 }, (o)=> | |||
{ | |||
if(o != null && o.Length > 0 && o[0] is bool resultValue) | |||
if (o != null && o.Length > 0 && o[0] is bool resultValue) | |||
{ | |||
result = resultValue; | |||
} | |||
@@ -512,41 +512,41 @@ namespace BPASmartClient.MorkT | |||
{ | |||
//if (IceCreamCanMake()) | |||
//{ | |||
if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
{ | |||
DoIceCream(order); | |||
} | |||
//if(peripheralStatus.ContainsKey("IceCreamCurrentMode")) | |||
//{ | |||
// if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); | |||
//} | |||
//if(peripheralStatus.ContainsKey("IceCreamCXB")) | |||
//{ | |||
// if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
// { | |||
// bool result = true; | |||
// EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => | |||
// { | |||
// if (res[0] is bool resultValue) | |||
// { | |||
// result = resultValue; | |||
// } | |||
// }); | |||
// if (result) | |||
// { | |||
// if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); | |||
// morkT.IceIsOK = false; | |||
// } | |||
// else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
// { | |||
// morkT.IceIsOK = true; | |||
// DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); | |||
// DoIceCream(order); | |||
// } | |||
// } | |||
//} | |||
if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
{ | |||
DoIceCream(order); | |||
} | |||
//if(peripheralStatus.ContainsKey("IceCreamCurrentMode")) | |||
//{ | |||
// if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); | |||
//} | |||
//if(peripheralStatus.ContainsKey("IceCreamCXB")) | |||
//{ | |||
// if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
// { | |||
// bool result = true; | |||
// EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => | |||
// { | |||
// if (res[0] is bool resultValue) | |||
// { | |||
// result = resultValue; | |||
// } | |||
// }); | |||
// if (result) | |||
// { | |||
// if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); | |||
// morkT.IceIsOK = false; | |||
// } | |||
// else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
// { | |||
// morkT.IceIsOK = true; | |||
// DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); | |||
// DoIceCream(order); | |||
// } | |||
// } | |||
//} | |||
//} | |||
} | |||
@@ -559,12 +559,12 @@ namespace BPASmartClient.MorkT | |||
{ | |||
GetIceCreamCup(); | |||
CheckICeCreaCup(); | |||
if(morkT.GetIceCreamCup) | |||
if (morkT.GetIceCreamCup) | |||
{ | |||
GetIceCream(order); | |||
PutIceCream(order); | |||
} | |||
} | |||
/// <summary> | |||
@@ -730,7 +730,7 @@ namespace BPASmartClient.MorkT | |||
bool result = false; | |||
int retry = 3; | |||
DateTime beginTime = DateTime.Now; | |||
while (!result) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => | |||
@@ -748,7 +748,7 @@ namespace BPASmartClient.MorkT | |||
if (DateTime.Now.Subtract(beginTime).TotalSeconds > 5) | |||
{ | |||
DeviceProcessLogShow("超时未出料,重新发送打料指令"); | |||
EventBus.EventBus.GetInstance().Publish( new GSIceCream_ModeSetEvent() { DeviceId =DeviceId, Mode = MORKI_MODE.打料 }); | |||
EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent() { DeviceId = DeviceId, Mode = MORKI_MODE.打料 }); | |||
beginTime = DateTime.Now; | |||
retry--; | |||
} | |||
@@ -758,5 +758,9 @@ namespace BPASmartClient.MorkT | |||
Thread.Sleep(5000); | |||
} | |||
public override void SimOrder() | |||
{ | |||
} | |||
} | |||
} |
@@ -6,4 +6,11 @@ | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.JAKA\BPASmartClient.JAKA.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Juicer\BPASmartClient.Juicer.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MCU\BPASmartClient.MCU.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,8 +0,0 @@ | |||
using System; | |||
namespace BPASmartClient.MorktJAKAJC | |||
{ | |||
public class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,832 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Linq; | |||
using System.Threading; | |||
using System.Collections.Concurrent; | |||
using System.Diagnostics; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Device; | |||
using BPA.Message.Enum; | |||
using BPA.Message; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.EventBus; | |||
using static BPASmartClient.EventBus.EventBus; | |||
using BPASmartClient.Model.PLC; | |||
using BPASmartClient.Model.单片机; | |||
namespace BPASmartClient.MorktJAKAJC | |||
{ | |||
/* | |||
* 冰淇淋咖啡机组合套装 | |||
* 物料位置: | |||
* 1:冰淇料 | |||
* 2:冰淇淋杯 | |||
* 5:咖啡 | |||
* 6:咖啡杯 | |||
* 9: 茶 | |||
* 10: 茶杯 | |||
*/ | |||
public class Control_MORKJC : BaseDevice | |||
{ | |||
GVL_MORKJC mORKD = new GVL_MORKJC(); | |||
//咖啡机主控程序 | |||
//private CoffeeMachine coffeeMachine; | |||
////果汁机主控程序 | |||
//private JuicerMachine juicerMachine; | |||
////单片机主控程序 | |||
//private ICChipMachine icchipMachine; | |||
//物料存放位置 | |||
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | |||
//容器位置 | |||
private string holderLoc; | |||
//主料位置 | |||
private string mainMaterialLoc; | |||
//子订单ID | |||
private string subOrderId; | |||
private bool enableFunny = false; | |||
private DateTime lastRecvdOrder = DateTime.Now; | |||
private bool working = false; | |||
/// <summary> | |||
/// 果汁机做法,true:热饮,false:冷饮 | |||
/// </summary> | |||
private bool GuMake = false; | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | |||
} | |||
//private SerialPortClient commProxy; | |||
public void ConnectOk() | |||
{ | |||
} | |||
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>(); | |||
public void Init() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((s) => | |||
{ | |||
if (s is DrCoffeeDrinksCode cf) | |||
{ | |||
mainMaterialLoc = ((int)cf).ToString(); | |||
DoCoffee(); | |||
} | |||
}), "SimCoffee"); | |||
//构建所有商品物料信息 | |||
batchings = PolymerBatching.BuildAll(); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, DRCoffee_CoffeEndCookEventHandle); | |||
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); | |||
//一系列外围基础配置 | |||
var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value; | |||
var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value; | |||
//咖啡机创建 | |||
//coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee)); | |||
Main(); | |||
ReadData(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
while (morkOrderPushes.Count > 0) | |||
{ | |||
while (enableFunny) { Thread.Sleep(10); } | |||
DeviceProcessLogShow("当前非自嗨模式,允许开工"); | |||
working = true; | |||
if (morkOrderPushes.TryDequeue(out MorkOrderPush order)) | |||
{ | |||
DeviceProcessLogShow($"开始制作订单[{order.SortNum}]"); | |||
//商品类型 | |||
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; | |||
//子订单ID | |||
subOrderId = order.SuborderId; | |||
//遍历物料 | |||
foreach (var item in order.GoodBatchings) | |||
{ | |||
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||
if (res != null) | |||
{ | |||
//获取主料和容器位置 | |||
switch (batchings[res.BatchingLoc].BatchingClass) | |||
{ | |||
case BATCHING_CLASS.HOLDER: | |||
holderLoc = res.BatchingLoc; | |||
break; | |||
case BATCHING_CLASS.MAIN_MATERIAL: | |||
// mainMaterialLoc ="1"; | |||
mainMaterialLoc = res.BatchingLoc; | |||
//验证商品是咖啡还是冰淇淋 | |||
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER) | |||
{ | |||
//获取当前物料所属商品类型 | |||
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
//根据商品类型执行具体制作流程 | |||
switch (currentGoodsType) | |||
{ | |||
case GOODS_TYPE.COFFEE: | |||
DoCoffee(); | |||
break; | |||
case GOODS_TYPE.JUICE: | |||
GuMake = order.MakeID == "2"; | |||
DoJuicer(); | |||
break; | |||
case GOODS_TYPE.TEA: | |||
DoTea(); | |||
break; | |||
case GOODS_TYPE.WATER: | |||
DoWater(); | |||
break; | |||
case GOODS_TYPE.NEITHER: | |||
DeviceProcessLogShow("未知的商品类型"); | |||
break; | |||
} | |||
} | |||
working = false; | |||
lastRecvdOrder = DateTime.Now; | |||
} | |||
Thread.Sleep(1000); | |||
}), "订单制作"); | |||
} | |||
public void Main() | |||
{ | |||
//咖啡机开启主线程 | |||
//coffeeMachine.Start(); | |||
//开始心跳刷新,根据咖啡机及冰淇淋机来判断 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//IsHealth = | |||
// Write.IsConnected && | |||
// MorkCStatus.GetInstance().CanDo && | |||
// JuicerHelper.GetInstance.IsOpen && | |||
// MCUSerialHelper.GetInstance.IsOpen; | |||
//GeneralConfig.Healthy = true; | |||
Thread.Sleep(100); | |||
}), "MORK-IC心跳刷新"); | |||
//ThreadManage.GetInstance().Start(new Action(() => | |||
//{ | |||
// while (!Write.IsConnected) | |||
// { | |||
// Thread.Sleep(10); | |||
// } | |||
// //LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_欢迎); | |||
//}), "MORK-JC欢迎"); | |||
} | |||
public void DataParse<T>(T order) | |||
{ | |||
if (order is MorkOrderPush morkOrderPush) | |||
{ | |||
morkOrderPushes.Enqueue(morkOrderPush); | |||
} | |||
} | |||
/// <summary> | |||
/// 验证当前是做咖啡还是做冰淇淋 | |||
/// </summary> | |||
/// <param name="batchingLoc">物料位置</param> | |||
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc) | |||
{ | |||
if (batchings.ContainsKey(batchingLoc)) | |||
return batchings[batchingLoc].GoodsType; | |||
return GOODS_TYPE.NEITHER; | |||
} | |||
private AutoResetEvent are = new AutoResetEvent(false); | |||
private T GetStatus<T>(string key) | |||
{ | |||
if (peripheralStatus.ContainsKey(key)) | |||
{ | |||
if (peripheralStatus[key] != null) | |||
{ | |||
return (T)(peripheralStatus[key]); | |||
} | |||
} | |||
return default; | |||
} | |||
private void Wait(int value) | |||
{ | |||
while (!((GetStatus<int>("Get_RobotAO1") == value) && GetStatus<int>("GetProgramStatus") == 0))//判断文件是否已经执行结束 且 文件末端变量值==文件名 | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
} | |||
int[] devStatusBy = new int[2] { 0, 0 }; | |||
/// <summary> | |||
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确 | |||
/// </summary> | |||
int bSensorInput; | |||
/// <summary> | |||
/// 延迟的超时时间 | |||
/// </summary> | |||
DateTime delayTimeOut; | |||
/// <summary> | |||
/// 做咖啡 | |||
/// </summary> | |||
private void DoCoffee() | |||
{ | |||
#region 接咖啡流程 | |||
are.Reset(); | |||
// OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
DeviceProcessLogShow("咖啡杯取杯完成"); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接咖啡 }.Publish(); | |||
// Write("JaKaProgramName",JakaModel.SENCE_接咖啡); | |||
Wait(int.Parse(JakaModel.SENCE_接咖啡)); | |||
new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水 | |||
are.WaitOne(1000 * 180); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放咖啡杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放咖啡杯)); | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
//订单状态改变:完成 | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 做茶 | |||
/// </summary> | |||
private void DoTea() | |||
{ | |||
#region 接茶流程 | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
DeviceProcessLogShow("取茶杯完成"); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接茶)); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 130 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶_接水 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接茶_接水)); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(50000); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放茶水杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放茶水杯)); | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 接开水 | |||
/// </summary> | |||
private void DoWater() | |||
{ | |||
#region 接水流程 | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接水 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接水)); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(50000); | |||
//添加控制接水机构程序 | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放茶水杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放茶水杯)); | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 果汁机控制信号 | |||
/// </summary> | |||
private byte JuicerNum; | |||
/// <summary> | |||
/// 做果汁 | |||
/// </summary> | |||
private void DoJuicer() | |||
{ | |||
#region 接果汁流程 | |||
are.Reset(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
int JuicerNum1 = int.Parse(mainMaterialLoc); | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x00; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x01; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁1)); | |||
break; | |||
case 53: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x02; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x03; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁2 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁2)); | |||
break; | |||
case 54: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x04; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x05; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁3 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁3)); | |||
break; | |||
case 55: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x06; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x07; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁4 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁4)); | |||
break; | |||
default: | |||
JuicerNum = 0x00; | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁1)); | |||
break; | |||
} | |||
var devStatus = GetStatus<int[]>("GetDeviceStatus"); | |||
var devStatus1 = Convert.ToString(devStatus[0], 2); | |||
var devStatus2 = devStatus[1]; | |||
if (devStatus1.IndexOf("0") == 1 && devStatus2 == 0) | |||
{ | |||
if (sensor_Sign(1) == 1) | |||
{ | |||
new WriteJuicer() { Value = JuicerNum }.Publish(); | |||
} | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (!(devStatusBy[1] == 0)) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (devStatusBy.Length != 2) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
} | |||
} | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
Thread.Sleep(5000); | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
case 53: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯2 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯2)); | |||
break; | |||
case 54: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯3 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯3)); | |||
break; | |||
case 55: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯4 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯4)); | |||
break; | |||
default: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
} | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else | |||
{ | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
case 53: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯2 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯2)); | |||
break; | |||
case 54: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯3 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯3)); | |||
break; | |||
case 55: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯4 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯4)); | |||
break; | |||
default: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
} | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
private int getCup_cnt; | |||
/// <summary> | |||
/// 取杯流程 | |||
/// </summary> | |||
/// <returns>0:无意义,1:取杯成功 2:机构有杯子,取杯失败 3:机构没有杯子</returns> | |||
private int takeCup() | |||
{ | |||
try | |||
{ | |||
getCup_cnt = 0;//取杯次数复位 | |||
new WriteJaka() { TagName = "Set_RobotAO1", Value = 0 }.Publish(); | |||
Wait(0); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(10); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
new WriteJaka() { TagName = "Set_RobotAO1", Value = 0 }.Publish(); | |||
Wait(0); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯)); | |||
bSensorInput = sensor_Sign(1); | |||
if (bSensorInput == 2) | |||
{ | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯检测)); | |||
DeviceProcessLogShow("落杯器没有纸杯了"); | |||
return 3; | |||
} | |||
if (bSensorInput == 1) | |||
{ | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯检测)); | |||
bSensorInput = sensor_Sign(1); | |||
/*delayTimeOut = DateTime.Now; | |||
bSensorInput = sensor_Sign(1); | |||
while (bSensorInput == 3) | |||
{ | |||
Thread.Sleep(100); | |||
bSensorInput = sensor_Sign(1); | |||
}*/ | |||
while (getCup_cnt < 4 && (bSensorInput == 2 || bSensorInput == 3)) | |||
{ | |||
DeviceProcessLogShow($"第{getCup_cnt}次取杯失败"); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯)); | |||
getCup_cnt = getCup_cnt + 1; | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯检测)); | |||
bSensorInput = sensor_Sign(1); | |||
} | |||
if (bSensorInput == 1) | |||
{ | |||
return 1; | |||
} | |||
else | |||
{ | |||
return 2; | |||
} | |||
} | |||
return 1; | |||
} | |||
catch (Exception ex) | |||
{ | |||
DeviceProcessLogShow(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 放杯 | |||
/// </summary> | |||
/// <returns>0:无意义 1:执行成功 2:执行失败(传感器还有信号)</returns> | |||
private int putCup() | |||
{ | |||
try | |||
{ | |||
while (checkCup() == 2) | |||
{ | |||
Thread.Sleep(100); | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放杯)); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(10); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(10); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放杯检测)); | |||
bSensorInput = sensor_Sign(2); | |||
delayTimeOut = DateTime.Now; | |||
while (bSensorInput == 2) | |||
{ | |||
Thread.Sleep(100); | |||
bSensorInput = sensor_Sign(2); | |||
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 2) return 2; | |||
} | |||
if (bSensorInput == 2) | |||
{ | |||
DeviceProcessLogShow("放杯失败传感器没有信号"); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
return 1; | |||
} | |||
return 1; | |||
} | |||
catch (Exception ex) | |||
{ | |||
DeviceProcessLogShow(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
private int cnt_Check; | |||
public override DeviceClientType DeviceType => throw new NotImplementedException(); | |||
/// <summary> | |||
/// 检测放杯位,是否有杯子 | |||
/// </summary> | |||
/// <returns>0:无意义 1:没有杯子 2:有杯子 </returns> | |||
private int checkCup() | |||
{ | |||
try | |||
{ | |||
//cnt_Check = 0; | |||
bSensorInput = sensor_Sign(2); | |||
if (bSensorInput == 2) | |||
{ | |||
DeviceProcessLogShow($"放杯位传感器没有信号:{cnt_Check}"); | |||
return 1; | |||
} | |||
else if (bSensorInput == 1) | |||
{ | |||
DeviceProcessLogShow($"放杯位传感器有信号:{cnt_Check}"); | |||
return 2; | |||
} | |||
return 2; | |||
} | |||
catch (Exception ex) | |||
{ | |||
DeviceProcessLogShow(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
private T McuRead<T>(string tagName, object par) | |||
{ | |||
new ReadMcu() { DeviceId = DeviceId, TagName = tagName, ReadPar = par }; | |||
if (peripheralStatus.ContainsKey(tagName)) | |||
{ | |||
if (peripheralStatus[tagName] != null) | |||
{ | |||
return (T)peripheralStatus[tagName]; | |||
} | |||
} | |||
return default; | |||
} | |||
/// <summary> | |||
/// 传感器防抖0.2s内检测20次, | |||
/// </summary> | |||
/// <param name="num"></param> | |||
/// <returns></returns> | |||
private int sensor_Sign(byte num) | |||
{ | |||
DeviceProcessLogShow($"开始检测{num}号传感器信号"); | |||
int cnt = 0; | |||
cnt_Check = 0; | |||
while (true) | |||
{ | |||
Thread.Sleep(10); | |||
bSensorInput = McuRead<int>("GetInputStatus", num); | |||
if (bSensorInput == 1) | |||
{ | |||
cnt_Check = cnt_Check + 1; | |||
cnt = cnt + 1; | |||
} | |||
else if (bSensorInput == 2) | |||
{ | |||
cnt_Check = cnt_Check - 1; | |||
cnt = cnt + 1; | |||
} | |||
if (cnt >= 20) | |||
{ | |||
break; | |||
} | |||
} | |||
if (cnt_Check >= 0) | |||
{ | |||
DeviceProcessLogShow($"{num}传感器有信号:{cnt_Check}"); | |||
return 1; | |||
} | |||
else | |||
{ | |||
DeviceProcessLogShow($"{num}传感器没有信号:{cnt_Check}"); | |||
return 2; | |||
} | |||
} | |||
private void DRCoffee_CoffeEndCookEventHandle(IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
are.Set(); | |||
} | |||
public void SimOrder<T>(T simOrder) | |||
{ | |||
} | |||
public override void DoMain() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void ReadData() | |||
{ | |||
} | |||
public override void MainTask() | |||
{ | |||
} | |||
public override void ResetProgram() | |||
{ | |||
} | |||
public override void SimOrder() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
using BPASmartClient.Device; | |||
namespace BPASmartClient.MorktJAKAJC | |||
{ | |||
public class GVL_MORKJC : IStatus | |||
{ | |||
} | |||
} |
@@ -0,0 +1,152 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorktJAKAJC | |||
{ | |||
internal enum GOODS_TYPE | |||
{ | |||
/// <summary> | |||
/// 未知 | |||
/// </summary> | |||
NEITHER, | |||
/// <summary> | |||
/// 咖啡 | |||
/// </summary> | |||
COFFEE, | |||
/// <summary> | |||
/// 果汁 | |||
/// </summary> | |||
JUICE, | |||
/// <summary> | |||
/// 茶水 | |||
/// </summary> | |||
TEA, | |||
/// <summary> | |||
/// 水 | |||
/// </summary> | |||
WATER, | |||
/// <summary> | |||
/// 杯子 | |||
/// </summary> | |||
CUP | |||
} | |||
internal enum BATCHING_CLASS | |||
{ | |||
HOLDER, | |||
MAIN_MATERIAL, | |||
} | |||
internal class PolymerBatching | |||
{ | |||
internal const string Juicer_MAIN_BATCHIN1_LOC = "52"; | |||
internal const string Juicer_MAIN_BATCHIN2_LOC = "53"; | |||
internal const string Juicer_MAIN_BATCHIN3_LOC = "54"; | |||
internal const string Juicer_MAIN_BATCHIN4_LOC = "55"; | |||
//internal const string Juicer_MAIN_BATCHIN5_LOC = "56"; | |||
//internal const string Juicer_MAIN_BATCHIN6_LOC = "57"; | |||
//internal const string Juicer_MAIN_BATCHIN7_LOC = "58"; | |||
//internal const string Juicer_MAIN_BATCHIN8_LOC = "59"; | |||
internal const string COFFEE_HOLDER_LOC = "30"; | |||
internal const string TEA_HOLDER_LOC = "51"; | |||
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() { | |||
{"1", GOODS_TYPE.COFFEE}, | |||
{"2", GOODS_TYPE.COFFEE}, | |||
{"3", GOODS_TYPE.COFFEE}, | |||
{"4", GOODS_TYPE.COFFEE}, | |||
{"5", GOODS_TYPE.COFFEE}, | |||
{"6", GOODS_TYPE.COFFEE}, | |||
{"7", GOODS_TYPE.COFFEE}, | |||
{"8", GOODS_TYPE.COFFEE}, | |||
{"9", GOODS_TYPE.COFFEE}, | |||
{"10",GOODS_TYPE.COFFEE}, | |||
{"11",GOODS_TYPE.COFFEE}, | |||
{"12",GOODS_TYPE.COFFEE}, | |||
{"13",GOODS_TYPE.COFFEE}, | |||
{"14",GOODS_TYPE.COFFEE}, | |||
{"15",GOODS_TYPE.COFFEE}, | |||
{"16",GOODS_TYPE.COFFEE}, | |||
{"17",GOODS_TYPE.COFFEE}, | |||
{"18",GOODS_TYPE.COFFEE}, | |||
{"19",GOODS_TYPE.COFFEE}, | |||
{"20",GOODS_TYPE.COFFEE}, | |||
{"21",GOODS_TYPE.COFFEE}, | |||
{"22",GOODS_TYPE.COFFEE}, | |||
{"23",GOODS_TYPE.COFFEE}, | |||
{"24",GOODS_TYPE.COFFEE}, | |||
{"25",GOODS_TYPE.COFFEE}, | |||
{ COFFEE_HOLDER_LOC,GOODS_TYPE.CUP}, | |||
{"56",GOODS_TYPE.TEA }, | |||
{Juicer_MAIN_BATCHIN1_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN2_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN3_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN4_LOC,GOODS_TYPE.JUICE}, | |||
{"61",GOODS_TYPE.WATER}, | |||
//{Juicer_MAIN_BATCHIN5_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN6_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN7_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN8_LOC,GOODS_TYPE.JUICE}, | |||
}; | |||
public GOODS_TYPE GoodsType { get; set; } | |||
public BATCHING_CLASS BatchingClass { get; set; } | |||
private string loc; | |||
public string Loc | |||
{ | |||
get { return loc; } | |||
set | |||
{ | |||
loc = value; | |||
if (GOODS_TYPES.ContainsKey(loc)) | |||
GoodsType = GOODS_TYPES[loc]; | |||
switch (loc) | |||
{ | |||
case COFFEE_HOLDER_LOC: | |||
case TEA_HOLDER_LOC: | |||
BatchingClass = BATCHING_CLASS.HOLDER; | |||
break; | |||
default: | |||
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL; | |||
break; | |||
} | |||
} | |||
} | |||
internal static Dictionary<string, PolymerBatching> BuildAll() | |||
{ | |||
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>(); | |||
foreach (var item in GOODS_TYPES) | |||
{ | |||
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key }); | |||
} | |||
return temp; | |||
} | |||
//internal static IC_SE GetIceCreamSE(string loc, out string sence) | |||
//{ | |||
// switch (loc) | |||
// { | |||
// case Juicer_MAIN_BATCHIN1_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// case Juicer_MAIN_BATCHIN2_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁2; | |||
// return IC_SE.SE_2; | |||
// case Juicer_MAIN_BATCHIN3_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁3; | |||
// return IC_SE.SE_3; | |||
// default: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// } | |||
//} | |||
} | |||
} |
@@ -47,12 +47,22 @@ namespace BPASmartClient.Peripheral | |||
return null; | |||
} | |||
public void SetStatus(string statusName, object value) | |||
{ | |||
if (status.ContainsKey(statusName)) | |||
status[statusName] = value; | |||
else | |||
status.TryAdd(statusName, value); | |||
} | |||
public abstract void Start(); | |||
public abstract void Stop(); | |||
public abstract void Init(); | |||
//public abstract void ReadData(string address); | |||
public abstract void WriteData(string address, object value); | |||
public ConcurrentDictionary<string, object> GetAllStatus() | |||
@@ -55,6 +55,8 @@ namespace BPASmartClient.Peripheral | |||
void WriteData(string address, object value); | |||
//void ReadData(string address); | |||
/// <summary> | |||
/// 初始化 | |||
/// </summary> | |||
@@ -39,5 +39,6 @@ namespace BPASmartClient.SCChip | |||
/// 检测物品距离 | |||
/// </summary> | |||
ARTICLE_DIST = 0x06 | |||
} | |||
} |
@@ -0,0 +1,113 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Message; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.IO.Ports; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.SerialPort | |||
{ | |||
public class JuicerHelper | |||
{ | |||
//private volatile static JuicerHelper _Instance; | |||
//public static JuicerHelper GetInstance => _Instance ?? (_Instance = new JuicerHelper()); | |||
//private JuicerHelper() { } | |||
private System.IO.Ports.SerialPort comPort = new System.IO.Ports.SerialPort(); | |||
ConcurrentQueue<byte[]> SerialMessages = new ConcurrentQueue<byte[]>(); | |||
public bool IsOpen => comPort.IsOpen; | |||
public bool Open(string portName, int baudRate) | |||
{ | |||
while (!System.IO.Ports.SerialPort.GetPortNames().Contains(portName)) | |||
{ | |||
Thread.Sleep(1000); | |||
} | |||
while (!comPort.IsOpen) | |||
{ | |||
comPort.PortName = portName; | |||
comPort.BaudRate = baudRate; | |||
comPort.DataBits = 8; | |||
comPort.Parity = Parity.None; | |||
comPort.StopBits = StopBits.One; | |||
comPort.ReadTimeout = 1000; | |||
comPort.WriteTimeout = 1000; | |||
//comPort.DataReceived += ComPort_DataReceived; | |||
comPort.RtsEnable = true; | |||
try | |||
{ | |||
comPort.Open(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
Thread.Sleep(5000); | |||
} | |||
} | |||
MessageLog.GetInstance.Show($"{portName} 串口打开成功"); | |||
return comPort.IsOpen; | |||
} | |||
/// <summary> | |||
/// 开始制作 | |||
/// </summary> | |||
/// <param name="aisle"></param> | |||
/// <returns></returns> | |||
public bool StartCook(byte aisle) | |||
{ | |||
byte sum = (byte)(0x21 + aisle); | |||
byte checksum = (byte)~sum; | |||
checksum++; | |||
byte[] buffers = new byte[6] { 0x7E, 0x03, 0x00, 0x21, aisle, checksum }; | |||
if (comPort.IsOpen) | |||
{ | |||
comPort.Write(buffers, 0, buffers.Length); | |||
while (comPort.BytesToRead < 6) | |||
{ | |||
Thread.Sleep(1); | |||
} | |||
byte[] receive = new byte[comPort.BytesToRead]; | |||
comPort.Read(receive, 0, receive.Length); | |||
if (receive.Length == 6) | |||
return receive[4] == 1; | |||
} | |||
return false; | |||
} | |||
/// <summary> | |||
/// 获取果汁机状态 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <returns></returns> | |||
public int[] GetDeviceStatus() | |||
{ | |||
List<int> res = new List<int>(); | |||
byte[] buffers = new byte[5] { 0x7E, 0x02, 0x00, 0x13, 0xED }; | |||
if (comPort.IsOpen) | |||
{ | |||
comPort.Write(buffers, 0, buffers.Length); | |||
DateTime newDate = DateTime.Now; | |||
while (comPort.BytesToRead < 33) | |||
{ | |||
Thread.Sleep(1); | |||
if (DateTime.Now.Subtract(newDate).TotalSeconds >= 2) break; | |||
} | |||
byte[] receive = new byte[comPort.BytesToRead]; | |||
comPort.Read(receive, 0, receive.Length); | |||
if (receive.Length == 33) | |||
{ | |||
res.Add(receive.Skip(24).Take(4).ToArray().BytesToInt()); | |||
res.Add(receive.Skip(28).Take(4).ToArray().BytesToInt()); | |||
} | |||
return res.ToArray(); | |||
} | |||
return default; | |||
} | |||
} | |||
} |
@@ -0,0 +1,140 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.IO; | |||
using System.IO.Ports; | |||
using System.Threading; | |||
using System.Collections.Concurrent; | |||
using BPASmartClient.Message; | |||
namespace BPASmartClient.SerialPort | |||
{ | |||
public class MCUSerialHelper | |||
{ | |||
//private volatile static MCUSerialHelper _Instance; | |||
//public static MCUSerialHelper GetInstance => _Instance ?? (_Instance = new MCUSerialHelper()); | |||
//private MCUSerialHelper() { } | |||
private System.IO.Ports.SerialPort comPort = new System.IO.Ports.SerialPort(); | |||
public bool IsOpen => comPort.IsOpen; | |||
public bool Open(string portName, int baudRate) | |||
{ | |||
while (!System.IO.Ports.SerialPort.GetPortNames().Contains(portName)) | |||
{ | |||
Thread.Sleep(1000); | |||
} | |||
while (!comPort.IsOpen) | |||
{ | |||
comPort.PortName = portName; | |||
comPort.BaudRate = baudRate; | |||
comPort.DataBits = 8; | |||
comPort.Parity = Parity.None; | |||
comPort.StopBits = StopBits.One; | |||
comPort.ReadTimeout = 1000; | |||
comPort.WriteTimeout = 1000; | |||
//comPort.RtsEnable = true; //设置为 true后会读取不到数据 | |||
//comPort.DtrEnable = true;//获取或设置一个值,该值在串行通信过程中启用数据终端就绪 (DTR) 信号。 | |||
//comPort.RtsEnable = true;//获取或设置一个值,该值指示在串行通信中是否启用请求发送 (RTS) 信号 | |||
try | |||
{ | |||
comPort.Open(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
Thread.Sleep(5000); | |||
} | |||
} | |||
MessageLog.GetInstance.Show($"{portName} 串口打开成功"); | |||
return comPort.IsOpen; | |||
} | |||
private static readonly object OutPutLock = new object(); | |||
/// <summary> | |||
/// 单片机输出端口控制 | |||
/// </summary> | |||
/// <param name="index">通道号 1 - 8 </param> | |||
/// <param name="value">控制值</param> | |||
public void OutputControl(byte index, bool value) | |||
{ | |||
lock (OutPutLock) | |||
{ | |||
byte NumValue = (byte)(value ? 0x01 : 0x00); | |||
byte[] buffers = new byte[6] { 0xCC, 0x01, 0x01, index, NumValue, 0xDD }; | |||
if (IsOpen) comPort.Write(buffers, 0, buffers.Length); | |||
} | |||
} | |||
/// <summary> | |||
/// 舵机控制 | |||
/// </summary> | |||
/// <param name="index">通道号 1 - 8</param> | |||
/// <param name="value">舵机位置 0 - 180</param> | |||
public void ServoControl(byte index, byte value) | |||
{ | |||
byte[] buffers = new byte[6] { 0xCC, 0x01, 0x02, index, value, 0xDD }; | |||
if (IsOpen) comPort.Write(buffers, 0, buffers.Length); | |||
} | |||
/// <summary> | |||
/// 获取单片机输入端口状态 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <returns>0:无意义 1:有信号 2:无信号 3:信号不正确</returns> | |||
public int GetInputStatus(byte index) | |||
{ | |||
if (index <= 0 || index > 8) return 0; | |||
byte[] buffers = new byte[6] { 0xCC, 0x01, 0x03, index, 0x00, 0xDD }; | |||
if (IsOpen) | |||
{ | |||
comPort.Write(buffers, 0, buffers.Length); | |||
DateTime dt = DateTime.Now; | |||
List<byte> receive = new List<byte>(); | |||
while (true) | |||
{ | |||
byte[] re = new byte[comPort.BytesToRead]; | |||
comPort.Read(re, 0, re.Length); | |||
if (re.Contains<byte>(0xcc) && re.Contains<byte>(0xDD)) receive.AddRange(re); | |||
comPort.DiscardInBuffer(); | |||
if (receive.Contains(0xcc) && receive.Contains(0xdd)) break; | |||
if (DateTime.Now.Subtract(dt).TotalSeconds >= 2) break; | |||
Thread.Sleep(1); | |||
} | |||
if (receive != null) | |||
{ | |||
int Reindex = Array.FindIndex(receive.ToArray(), p => p == 0xcc); | |||
if (Reindex < receive.Count && Reindex >= 0) | |||
{ | |||
var res = receive.GetRange(Array.FindIndex(receive.ToArray(), p => p == 0xcc), 6); | |||
if (res.ElementAt(2) == 0x03) | |||
{ | |||
if (res != null && res.Count() == 6 && res.ElementAt(4) == 0x01) | |||
{ | |||
return 1; | |||
} | |||
else if (res != null && res.Count() == 6 && res.ElementAt(4) == 0x00) | |||
{ | |||
return 2; | |||
} | |||
} | |||
else | |||
{ | |||
return 3; | |||
} | |||
} | |||
else | |||
{ | |||
return 0; | |||
} | |||
} | |||
} | |||
return 0; | |||
} | |||
} | |||
} |
@@ -20,28 +20,19 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
public DeviceMonitorViewModel() | |||
{ | |||
DeviceSwitch = new RelayCommand<object>((o) => | |||
{ | |||
if (o is string nameSpace) | |||
{ | |||
DeviceMonitors.Clear(); | |||
Assembly.Load(nameSpace.Substring(0, nameSpace.LastIndexOf("."))).GetTypes().ToList().ForEach((type) => | |||
{ | |||
if (type?.BaseType?.Name == "UserControl") | |||
{ | |||
var fe = type.GetConstructor(Type.EmptyTypes).Invoke(null) as FrameworkElement; | |||
DeviceMonitors.Add(new Device() { Name = fe.Name, Namespace = type?.FullName, fe = fe }); | |||
} | |||
}); | |||
} | |||
}); | |||
DeviceWindowSwitch = new RelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is string nameSpace) | |||
{ | |||
var fe = DeviceMonitors.FirstOrDefault(p => p.Namespace == nameSpace); | |||
if (fe != null) MainContent = fe.fe; | |||
foreach (var item in Devices) | |||
{ | |||
var fe = item.DeviceMonitors.FirstOrDefault(p => p.Namespace == nameSpace); | |||
if (fe != null) | |||
{ | |||
MainContent = fe.fe; | |||
break; | |||
} | |||
} | |||
} | |||
}); | |||
@@ -50,24 +41,6 @@ namespace BPASmartClient.ViewModel | |||
private void GetData() | |||
{ | |||
//var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); | |||
//string path = $"{LocaPath.GetInstance().GetDeviceConfigPath}{text}.json"; | |||
//if (File.Exists(path)) | |||
//{ | |||
// string JsonString = File.ReadAllText(path); | |||
// var result = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModelJson>>(JsonString); | |||
// if (result != null) | |||
// { | |||
// foreach (var shop in result)//店铺集合 | |||
// { | |||
// foreach (var device in shop.deviceModels)//设备集合 | |||
// { | |||
// Devices.Add(new Device() { Name = device.DeviceName, Namespace = device.DeviceNamespace }); | |||
// } | |||
// } | |||
// } | |||
//} | |||
var result = Plugin.GetInstance().GetPlugin<ConfigMgr>()?.deviceConfigModelJsons; | |||
if (result != null) | |||
{ | |||
@@ -75,29 +48,32 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
foreach (var device in shop.deviceModels)//设备集合 | |||
{ | |||
Devices.Add(new Device() { Name = device.DeviceName, Namespace = device.DeviceNamespace }); | |||
Devices.Add(new ControlDevice() { Name = device.DeviceName, Namespace = device.DeviceNamespace }); | |||
} | |||
} | |||
} | |||
if (Devices.Count > 0) | |||
{ | |||
Devices.ElementAt(0).IsChecked = true; | |||
DeviceMonitors.Clear(); | |||
Assembly.Load(Devices.ElementAt(0).Namespace.Substring(0, Devices.ElementAt(0).Namespace.LastIndexOf("."))).GetTypes().ToList().ForEach((type) => | |||
for (int i = 0; i < Devices.Count; i++) | |||
{ | |||
if (type?.BaseType?.Name == "UserControl") | |||
Devices.ElementAt(i).DeviceMonitors.Clear(); | |||
Assembly.Load(Devices.ElementAt(i).Namespace.Substring(0, Devices.ElementAt(i).Namespace.LastIndexOf("."))).GetTypes().ToList().ForEach((type) => | |||
{ | |||
var fe = type.GetConstructor(Type.EmptyTypes).Invoke(null) as FrameworkElement; | |||
DeviceMonitors.Add(new Device() { Name = fe.Name, Namespace = type?.FullName, fe = fe }); | |||
} | |||
}); | |||
if (DeviceMonitors.Count > 0) | |||
if (type?.BaseType?.Name == "UserControl") | |||
{ | |||
var fe = type.GetConstructor(Type.EmptyTypes).Invoke(null) as FrameworkElement; | |||
Devices.ElementAt(i).DeviceMonitors.Add(new Device() { Name = fe.Name, Namespace = type?.FullName, fe = fe }); | |||
} | |||
}); | |||
} | |||
if (Devices.ElementAt(0).DeviceMonitors.Count > 0) | |||
{ | |||
DeviceMonitors.ElementAt(0).IsChecked = true; | |||
if (DeviceMonitors.ElementAt(0).fe != null) MainContent = DeviceMonitors.ElementAt(0).fe; | |||
Devices.ElementAt(0).DeviceMonitors.ElementAt(0).IsChecked = true; | |||
if (Devices.ElementAt(0).DeviceMonitors.ElementAt(0).fe != null) MainContent = Devices.ElementAt(0).DeviceMonitors.ElementAt(0).fe; | |||
} | |||
} | |||
} | |||
@@ -109,12 +85,27 @@ namespace BPASmartClient.ViewModel | |||
public RelayCommand<object> DeviceWindowSwitch { get; set; } | |||
public ObservableCollection<Device> Devices { get; set; } = new ObservableCollection<Device>(); | |||
public ObservableCollection<ControlDevice> Devices { get; set; } = new ObservableCollection<ControlDevice>(); | |||
public ObservableCollection<Device> DeviceMonitors { get; set; } = new ObservableCollection<Device>(); | |||
} | |||
public class ControlDevice : ObservableObject | |||
{ | |||
public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } } | |||
private string _mName; | |||
public string Namespace { get { return _mNamespace; } set { _mNamespace = value; OnPropertyChanged(); } } | |||
private string _mNamespace; | |||
public bool IsChecked { get { return _mIsChecked; } set { _mIsChecked = value; OnPropertyChanged(); } } | |||
private bool _mIsChecked; | |||
public ObservableCollection<Device> DeviceMonitors { get; set; } = new ObservableCollection<Device>(); | |||
} | |||
public class Device : ObservableObject | |||
{ | |||
@@ -65,6 +65,7 @@ namespace BPASmartClient.ViewModel | |||
})); | |||
}); | |||
dispatcherTimer = new DispatcherTimer(); | |||
dispatcherTimer.Tick += delegate | |||
{ | |||
@@ -123,7 +123,7 @@ namespace BPASmartClient.ViewModel | |||
{ | |||
if (obj != null && deviceConfig.Count == 1) | |||
{ | |||
string DeviceName = obj?.ToString(); | |||
string DeviceName = obj?.GetType().GetProperty("DeviceName")?.GetValue(obj, null)?.ToString(); | |||
var res = deviceConfig.ElementAt(0).deviceModels.FirstOrDefault(p => p.DeviceName == DeviceName); | |||
if (res != null) | |||
deviceConfig.ElementAt(0).deviceModels.Remove(res); | |||
@@ -7,14 +7,14 @@ | |||
<add key="IsEnableTest" value="false"/> | |||
<!--开发环境--> | |||
<add key="apollouri" value="http://10.2.1.21:28080/"/> | |||
<!--<add key="apollouri" value="http://10.2.1.21:28080/"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.Config"/> | |||
<add key ="Namespaces" value="DEV.Config"/>--> | |||
<!--正式环境--><!-- | |||
<!--正式环境--> | |||
<add key="apollouri" value="http://47.108.65.220:28080/"/> | |||
<add key="AppId" value="order"/> | |||
<add key ="Namespaces" value="TEST1.Config"/>--> | |||
<add key ="Namespaces" value="TEST1.Config"/> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
@@ -33,6 +33,8 @@ | |||
<ProjectReference Include="..\BPASmartClient.MorkF\BPASmartClient.MorkF.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MorkM\BPASmartClient.MorkM.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MorkS\BPASmartClient.MorkS.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Morkt.JAKA.JC\BPASmartClient.MorkTJAKAJC.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MorkT.Lebai.JC\BPASmartClient.MorkTLebaiJC.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.MorkT\BPASmartClient.MorkT.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SCChip\BPASmartClient.SCChip.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.ViewModel\BPASmartClient.ViewModel.csproj" /> | |||
@@ -14,6 +14,13 @@ | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<!--#region 静态资源--> | |||
<ImageBrush x:Key="leftImage" ImageSource="/BPASmartClient.CustomResource;component/Image/leftImage.png" /> | |||
<ImageBrush x:Key="leftImageSub" ImageSource="/BPASmartClient.CustomResource;component/Image/leftImageSub.png" /> | |||
<ImageBrush x:Key="topImage" ImageSource="/BPASmartClient.CustomResource;component/Image/topImage.png" /> | |||
<!--#endregion--> | |||
<!--#region ListBox样式--> | |||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||
@@ -48,78 +55,245 @@ | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="60" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!-- 第一行是设备切换行 --> | |||
<ListBox | |||
x:Name="lstEnt" | |||
Margin="100,0,0,0" | |||
Background="{x:Null}" | |||
BorderBrush="{x:Null}" | |||
BorderThickness="0" | |||
ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}" | |||
ItemsSource="{Binding Devices}"> | |||
<ListBox.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<StackPanel Orientation="Horizontal" /> | |||
</ItemsPanelTemplate> | |||
</ListBox.ItemsPanel> | |||
<ListBox.ItemTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<RadioButton | |||
Margin="0,0,10,0" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Command="{Binding DataContext.DeviceSwitch, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||
CommandParameter="{Binding Namespace}" | |||
Content="{Binding Name}" | |||
GroupName="Devices" | |||
IsChecked="{Binding IsChecked}" | |||
Style="{StaticResource RectangleRadioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
<!-- 第二行是设备功能行 --> | |||
<Grid Grid.Row="1"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="100" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<ItemsControl ItemsSource="{Binding DeviceMonitors}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<!--#region 下拉列表单选按钮样式--> | |||
<Style x:Key="RadioMiniButtonStyle" TargetType="{x:Type RadioButton}"> | |||
<Setter Property="Margin" Value="5,10,1,0" /> | |||
<Setter Property="Width" Value="160" /> | |||
<Setter Property="Height" Value="30" /> | |||
<Setter Property="FontSize" Value="14" /> | |||
<Setter Property="FontFamily" Value="粗体" /> | |||
<Setter Property="Foreground" Value="#DDD" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||
<Setter Property="BorderBrush" Value="Transparent" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="Background" Value="#DDD" /> | |||
<Setter Property="HorizontalAlignment" Value="Right" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||
<Grid | |||
x:Name="templateRoot" | |||
Background="Transparent" | |||
SnapsToDevicePixels="True"> | |||
<Border x:Name="border2" /> | |||
<ContentPresenter | |||
x:Name="contentPresenter" | |||
Margin="{TemplateBinding Padding}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||
Content="{TemplateBinding Content}" | |||
ContentStringFormat="{TemplateBinding ContentStringFormat}" | |||
ContentTemplate="{TemplateBinding ContentTemplate}" | |||
Focusable="False" | |||
RecognizesAccessKey="True" | |||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="HasContent" Value="True"> | |||
<Setter Property="FocusVisualStyle"> | |||
<Setter.Value> | |||
<Style> | |||
<Setter Property="Control.Template"> | |||
<Setter.Value> | |||
<ControlTemplate> | |||
<Rectangle | |||
Margin="14,0,0,0" | |||
SnapsToDevicePixels="True" | |||
Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" | |||
StrokeDashArray="1 2" | |||
StrokeThickness="1" /> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter Property="Padding" Value="4,-1,0,0" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="{x:Null}" /> | |||
<Trigger Property="IsChecked" Value="true"> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter TargetName="border2" Property="Background" Value="{StaticResource ResourceKey=leftImageSub}" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="false"> | |||
<Setter TargetName="border2" Property="Background" Value="#101F3F" /> | |||
<!--<Setter TargetName="border2" Property="Background" Value="#4B8EC4" />--> | |||
<Setter Property="Foreground" Value="#4B8EC4" /> | |||
</Trigger> | |||
<MultiTrigger> | |||
<MultiTrigger.Conditions> | |||
<Condition Property="IsChecked" Value="false" /> | |||
<Condition Property="IsMouseOver" Value="True" /> | |||
</MultiTrigger.Conditions> | |||
<MultiTrigger.Setters> | |||
<Setter TargetName="border2" Property="Background" Value="#55007acc" /> | |||
</MultiTrigger.Setters> | |||
</MultiTrigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
<!--#region 下拉列表样式--> | |||
<Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}"> | |||
<Setter Property="FocusVisualStyle" Value="{x:Null}" /> | |||
<Setter Property="Height" Value="80" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Right" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Padding" Value="10,10" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ToggleButton}"> | |||
<Grid> | |||
<RadioButton | |||
Margin="0,10,0,10" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Command="{Binding DataContext.DeviceWindowSwitch, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" | |||
CommandParameter="{Binding Namespace}" | |||
Content="{Binding Name}" | |||
FontSize="16" | |||
GroupName="DeviceMotion" | |||
IsChecked="{Binding IsChecked}" | |||
Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||
<Border | |||
x:Name="border2" | |||
Margin="{TemplateBinding Padding}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||
Background="{TemplateBinding Background}"> | |||
<ContentPresenter | |||
Margin="{TemplateBinding Padding}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||
RecognizesAccessKey="True" | |||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||
</Border> | |||
</Grid> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
<ContentControl Grid.Column="1" Content="{Binding MainContent}" /> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsPressed" Value="true"> | |||
<Setter Property="Background" Value="#FFd2e7f4" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="true"> | |||
<Setter TargetName="border2" Property="Background" Value="{StaticResource ResourceKey=leftImage}" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="false"> | |||
<!--<Setter TargetName="border2" Property="Background" Value="#191E36" />--> | |||
<Setter TargetName="border2" Property="Background" Value="#4B8EC4" /> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="false"> | |||
<Setter Property="Foreground" Value="White" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</Grid> | |||
<Style x:Key="ExpanderStyle" TargetType="{x:Type Expander}"> | |||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" /> | |||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> | |||
<Setter Property="VerticalContentAlignment" Value="Stretch" /> | |||
<Setter Property="BorderBrush" Value="Transparent" /> | |||
<Setter Property="BorderThickness" Value="1" /> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type Expander}"> | |||
<DockPanel> | |||
<ToggleButton | |||
x:Name="HeaderSite" | |||
Height="40" | |||
MinWidth="0" | |||
MinHeight="0" | |||
Margin="1" | |||
Padding="{TemplateBinding Padding}" | |||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" | |||
Content="{TemplateBinding Header}" | |||
ContentTemplate="{TemplateBinding HeaderTemplate}" | |||
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" | |||
DockPanel.Dock="Top" | |||
FontFamily="{TemplateBinding FontFamily}" | |||
FontSize="{TemplateBinding FontSize}" | |||
FontStretch="{TemplateBinding FontStretch}" | |||
FontStyle="{TemplateBinding FontStyle}" | |||
FontWeight="{TemplateBinding FontWeight}" | |||
Foreground="{TemplateBinding Foreground}" | |||
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" | |||
Style="{StaticResource ToggleButtonStyle}" /> | |||
<ContentPresenter | |||
x:Name="ExpandSite" | |||
Margin="{TemplateBinding Padding}" | |||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |||
DockPanel.Dock="Left" | |||
Focusable="false" | |||
Visibility="Collapsed" /> | |||
</DockPanel> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsExpanded" Value="true"> | |||
<Setter TargetName="ExpandSite" Property="Visibility" Value="Visible" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
<!--#endregion--> | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="200" /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<!-- 侧边栏菜单设置 --> | |||
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"> | |||
<Grid> | |||
<ItemsControl ItemsSource="{Binding Devices}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<Expander | |||
x:Name="E1" | |||
IsExpanded="{Binding IsChecked}" | |||
Style="{DynamicResource ExpanderStyle}"> | |||
<Expander.Header> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="18" | |||
Foreground="White" | |||
Text="{Binding Name}" /> | |||
</Expander.Header> | |||
<ItemsControl Margin="0,0,0,10" ItemsSource="{Binding DeviceMonitors}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton | |||
Command="{Binding DataContext.DeviceWindowSwitch, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ScrollViewer}}" | |||
CommandParameter="{Binding Namespace}" | |||
Content="{Binding Name}" | |||
GroupName="All" | |||
IsChecked="{Binding IsChecked}" | |||
Style="{StaticResource RadioMiniButtonStyle}" /> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</Expander> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</Grid> | |||
</ScrollViewer> | |||
<!--#endregion--> | |||
<ContentControl Grid.Column="1" Content="{Binding MainContent}" /> | |||
</Grid> | |||
</UserControl> |
@@ -73,19 +73,19 @@ | |||
</Peripherals> | |||
</Device>--> | |||
<!--<Device Name="Morks" Module="BPASmartClient.MorkS.Control_Morks" DeviceId="100"> | |||
<Device Name="Morks" Module="BPASmartClient.MorkS.Control_Morks" DeviceId="100"> | |||
<Peripherals> | |||
<Peripheral Module="BPASmartClient.PLC.PLCMachine"> | |||
<Parameters> | |||
<IpAddress>127.0.0.1</IpAddress> | |||
<Port>502</Port> | |||
<PLCReadAddress>M,M230.0,24;M,M0.3,3;M,M100.0,16;M,M235.0,1;M,M102.0,7;M,M103.0,6;VW,VW372,1</PLCReadAddress> | |||
--><!--<PLCReadAddress>M,M230.0,24</PLCReadAddress>--><!-- | |||
<PLCReadAddress>M,M230.0,24</PLCReadAddress> | |||
</Parameters> | |||
</Peripheral> | |||
</Peripherals> | |||
</Device>-->-->--> | |||
<Device Name="MorkM" Module="BPASmartClient.MorkM.Control_MorkM" DeviceId="100"> | |||
</Device>-->--> | |||
<!--<Device Name="MorkM" Module="BPASmartClient.MorkM.Control_MorkM" DeviceId="100"> | |||
<Peripherals> | |||
<Peripheral Module="BPASmartClient.PLC.PLCMachine"> | |||
<Parameters> | |||
@@ -96,6 +96,6 @@ | |||
</Parameters> | |||
</Peripheral> | |||
</Peripherals> | |||
</Device>-->--> | |||
</Device>-->-->--> | |||
</BPADevices> |
@@ -106,7 +106,7 @@ | |||
<MenuItem | |||
Click="Debug_Click" | |||
FontSize="12" | |||
Header="调试界面" | |||
Header="调试" | |||
Tag="DebugView" /> | |||
@@ -140,24 +140,6 @@ namespace BPASmartClient | |||
} | |||
})); | |||
}), "IotBroadcast"); | |||
//var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); | |||
//string path = $"{LocaPath.GetInstance().GetDeviceConfigPath}{text}.json"; | |||
//if (File.Exists(path)) | |||
//{ | |||
// string JsonString = File.ReadAllText(path); | |||
// var result = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModelJson>>(JsonString); | |||
// if (result != null) | |||
// { | |||
// foreach (var shop in result)//店铺集合 | |||
// { | |||
// foreach (var device in shop.deviceModels)//设备集合 | |||
// { | |||
// dv.Items.Add(new MenuItem { Header = device.DeviceModule }); | |||
// } | |||
// } | |||
// } | |||
//} | |||
} | |||
/// <summary> | |||
/// 获取设备集合 | |||
@@ -223,7 +205,7 @@ namespace BPASmartClient | |||
} | |||
/// <summary> | |||
/// 菜单切换栏 | |||
/// </summary> | |||
@@ -253,15 +235,15 @@ namespace BPASmartClient | |||
} | |||
} | |||
private void Debug_Click(object sender,RoutedEventArgs e) | |||
private void Debug_Click(object sender, RoutedEventArgs e) | |||
{ | |||
try | |||
{ | |||
if (sender is MenuItem) | |||
{ | |||
// Type type = Assembly.Load("BPASmartClient.MorkT").GetType("BPASmartClient.MorkT.View.DebugView"); | |||
// Type type = Assembly.Load("BPASmartClient.MorkF").GetType("BPASmartClient.MorkF.View.DebugView"); | |||
Type type = Assembly.Load("BPASmartClient.MorkM").GetType("BPASmartClient.MorkM.View.DebugView"); | |||
Type type = Assembly.Load("BPASmartClient.MorkF").GetType("BPASmartClient.MorkF.View.DebugView"); | |||
//Type type = Assembly.Load("BPASmartClient.MorkM").GetType("BPASmartClient.MorkM.View.DebugView"); | |||
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); | |||
contentRegion.Content = (FrameworkElement)cti.Invoke(null); | |||
Title.Text = (sender as MenuItem).Header?.ToString() + "界面"; | |||
@@ -84,7 +84,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTLebaiJC | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJAKAJC", "BPASmartClient.Morkt.JAKA.JC\BPASmartClient.MorkTJAKAJC.csproj", "{6B0FD858-A60D-41B9-A923-358B0CE2A254}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT_HQ", "BPASmartClient.MorkT_HQ\BPASmartClient.MorkT_HQ.csproj", "{81527A58-D337-400F-92A9-C4A2906EAF59}" | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MCU", "BPASmartClient.MCU\BPASmartClient.MCU.csproj", "{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.JakaRobot", "BPASmartClient.JakaRobot\BPASmartClient.JakaRobot.csproj", "{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.JAKA", "BPASmartClient.JAKA\BPASmartClient.JAKA.csproj", "{C935435D-6182-4A01-8E59-B832B2FF0D72}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.Juicer", "BPASmartClient.Juicer\BPASmartClient.Juicer.csproj", "{C28A88B1-E449-484C-AC67-B5038FF2CA79}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
@@ -740,26 +746,86 @@ Global | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254}.Release|x64.Build.0 = Release|Any CPU | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254}.Release|x86.ActiveCfg = Release|Any CPU | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254}.Release|x86.Build.0 = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|x64.Build.0 = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Debug|x86.Build.0 = Debug|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|ARM.Build.0 = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|ARM64.Build.0 = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|x64.ActiveCfg = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|x64.Build.0 = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|x86.ActiveCfg = Release|Any CPU | |||
{81527A58-D337-400F-92A9-C4A2906EAF59}.Release|x86.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x64.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x86.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM64.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x64.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x64.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x86.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x86.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x64.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x86.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM64.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x64.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x64.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x86.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x86.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x64.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x86.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM64.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x64.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x64.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x86.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x86.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x64.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x86.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM64.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x64.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x64.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x86.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x86.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -797,7 +863,10 @@ Global | |||
{74DB1F85-9B73-4113-8FE4-A63754BC7DF9} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{0A06C9E5-5C42-4BCE-B6E6-D8054C72255D} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{81527A58-D337-400F-92A9-C4A2906EAF59} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | |||
EndGlobalSection | |||
GlobalSection(ExtensibilityGlobals) = postSolution | |||
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | |||