|
- using BPA.Helper;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.MorkCL.Model.Control
- {
- internal class RobotSet : RobotGet
- {
- /// <summary>
- /// 机器人任务控制
- /// </summary>
- /// <param name="MainTask"></param>
- /// <param name="SubTask"></param>
- public void RobotTaskControl(string MainTask, EDeviceType SubTask)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return;
- }
- if (ushort.TryParse(MainTask, out ushort mainTask))
- if (mainTask >= 0 && mainTask <= 24)
- {
- IsIdle.Wait();
- MyModbus.Write("GI1".ToModbusAdd(), (ushort)SubTask);
- MyModbus.Write("GI0".ToModbusAdd(), mainTask);
- }
- }
-
- /// <summary>
- /// 入库控制
- /// </summary>
- /// <param name="Loc"></param>
- public void WarehousingControl(string Loc,CancellationTokenSource Cts)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return;
- }
- if (ushort.TryParse(Loc, out ushort loc))
- {
- if (loc >= 1 && loc <= 12)
- {
- IsIdle.Wait(Cts: Cts);
- MyModbus.Write("GI0".ToModbusAdd(), (ushort)(loc + 29));
- }
- }
- }
- /// <summary>
- /// 去夹爪清洗维护位。
- /// </summary>
- /// <param name="Cts"></param>
- public void GoCleanLoc(CancellationTokenSource Cts = null)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return;
- }
- IsIdle.Wait(Cts: Cts);
- MyModbus.Write("GI0".ToModbusAdd(), 45);
- }
-
- /// <summary>
- /// 发送清洗完成。
- /// </summary>
- /// <param name="Cts"></param>
- public bool SendCleanFinish(CancellationTokenSource Cts = null)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return false;
- }
- //IsIdle.Wait(Cts: Cts);
- return MyModbus.Write("GM550".ToModbusAdd(), true).IsSuccess;
- }
-
- /// <summary>
- /// 机器人到位允许倒菜到炒锅
- /// </summary>
- /// <param name="num">炒锅类型</param>
- public void AllowPourVegetables(EDeviceType num)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return;
- }
- switch (num)
- {
- case EDeviceType.炒锅1:
- MyModbus.Write("GM500".ToModbusAdd(), true);
- break;
- case EDeviceType.炒锅2:
- MyModbus.Write("GM501".ToModbusAdd(), true);
- break;
- case EDeviceType.压力锅:
- MyModbus.Write("GM502".ToModbusAdd(), true);
- break;
- default:
- break;
- }
- }
- /// <summary>
- /// 禁止机器人倒菜到炒锅。
- /// </summary>
- /// <param name="num">炒锅类型</param>
- public void DisablePourVegetables(EDeviceType num)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return;
- }
- switch (num)
- {
- case EDeviceType.炒锅1:
- MyModbus.Write("GM500".ToModbusAdd(), false);
- break;
- case EDeviceType.炒锅2:
- MyModbus.Write("GM501".ToModbusAdd(), false);
- break;
- case EDeviceType.压力锅:
- MyModbus.Write("GM502".ToModbusAdd(), false);
- break;
- default:
- break;
- }
- }
- /// <summary>
- /// 出餐减速到位
- /// </summary>
- /// <param name="num">炒锅类型</param>
- public void ModerateInPlace(EDeviceType num)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return;
- }
- switch (num)
- {
- case EDeviceType.炒锅1:
- MyModbus.Write("GM503".ToModbusAdd(), true);
- break;
- case EDeviceType.炒锅2:
- MyModbus.Write("GM505".ToModbusAdd(), true);
- break;
- case EDeviceType.压力锅:
- MyModbus.Write("GM507".ToModbusAdd(), true);
- break;
- default:
- break;
- }
- }
-
- /// <summary>
- /// 出餐倒菜完成
- /// </summary>
- /// <param name="num">炒锅类型</param>
- public void DiningOutComplete(EDeviceType num)
- {
- if (MyModbus is null || !MyModbus.IsConnected())
- {
- return;
- }
- switch (num)
- {
- case EDeviceType.炒锅1:
- MyModbus.Write("GM504".ToModbusAdd(), true);
- break;
- case EDeviceType.炒锅2:
- MyModbus.Write("GM506".ToModbusAdd(), true);
- break;
- case EDeviceType.压力锅:
- MyModbus.Write("GM508".ToModbusAdd(), true);
- break;
- default:
- break;
- }
- }
-
- /// <summary>
- /// 设置远程启动(暂停后也可以启动) M702
- /// </summary>
- public bool RobotStart
- {
- get { return MyModbus.Read<bool>("GM702".ToModbusAdd()).Content; }
- set { MyModbus.Write("GM702".ToModbusAdd(), value); }
- }
-
- /// <summary>
- /// 设置远程暂停 M703
- /// </summary>
- public bool RobotSuspend
- {
- get { return MyModbus.Read<bool>("GM703".ToModbusAdd()).Content; }
- set { MyModbus.Write("GM703".ToModbusAdd(), value); }
- }
-
- /// <summary>
- /// 设置使能 M700
- /// </summary>
- public bool RobotEnable
- {
- get { return MyModbus.Read<bool>("GM700".ToModbusAdd()).Content; }
- set { MyModbus.Write("GM700".ToModbusAdd(), value); }
- }
-
- /// <summary>
- /// 机器人复位
- /// </summary>
- public bool RobotReset
- {
- get { return MyModbus.Read<bool>("GM701".ToModbusAdd()).Content; }
- set { MyModbus.Write("GM701".ToModbusAdd(), value); }
- }
-
- }
- }
|