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
{
///
/// 机器人任务控制
///
///
///
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);
}
}
///
/// 入库控制
///
///
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));
}
}
}
///
/// 去夹爪清洗维护位。
///
///
public void GoCleanLoc(CancellationTokenSource Cts = null)
{
if (MyModbus is null || !MyModbus.IsConnected())
{
return;
}
IsIdle.Wait(Cts: Cts);
MyModbus.Write("GI0".ToModbusAdd(), 45);
}
///
/// 发送清洗完成。
///
///
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;
}
///
/// 机器人到位允许倒菜到炒锅
///
/// 炒锅类型
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;
}
}
///
/// 禁止机器人倒菜到炒锅。
///
/// 炒锅类型
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;
}
}
///
/// 出餐减速到位
///
/// 炒锅类型
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;
}
}
///
/// 出餐倒菜完成
///
/// 炒锅类型
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;
}
}
///
/// 设置远程启动(暂停后也可以启动) M702
///
public bool RobotStart
{
get { return MyModbus.Read("GM702".ToModbusAdd()).Content; }
set { MyModbus.Write("GM702".ToModbusAdd(), value); }
}
///
/// 设置远程暂停 M703
///
public bool RobotSuspend
{
get { return MyModbus.Read("GM703".ToModbusAdd()).Content; }
set { MyModbus.Write("GM703".ToModbusAdd(), value); }
}
///
/// 设置使能 M700
///
public bool RobotEnable
{
get { return MyModbus.Read("GM700".ToModbusAdd()).Content; }
set { MyModbus.Write("GM700".ToModbusAdd(), value); }
}
///
/// 机器人复位
///
public bool RobotReset
{
get { return MyModbus.Read("GM701".ToModbusAdd()).Content; }
set { MyModbus.Write("GM701".ToModbusAdd(), value); }
}
}
}