using Community;
using Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Views;
namespace ViewModel.Robots
{
public class YamahaRobotVM : FeiYuRobotVM
{
///
/// 上报异常的委托事件
///
public override event delegeateExcep eventExcepReport;
#region 机器人控制器返回信息
private string connectionStatus;
///
/// 机器人控制器返回信息
///
public string ConnectionStatus
{
get { return connectionStatus; }
set
{
connectionStatus = value;
this.RaisePropertyChanged("ConnectionStatus");
}
}
#endregion
///
/// 交互返回信息
///
public string RCVInfo { get; set; }
#region 机器人连接
private bool robotConn;
///
/// 机器人连接
///
public bool RobotConn
{
get { return robotConn; }
set
{
robotConn = value;
if (value)
{
SendControl("@LOAD ");
}
else
{
if (RobotStart)
{
ServoOn = false;
RobotStart = false;
SendControl("@RESET");//复位程序
}
// SendControl("$Logout\r\n");
}
this.RaisePropertyChanged("RobotConn");
}
}
#endregion
#region 启动机器人开关
private bool robotStart;
///
/// 启动机器人开关
///
public bool RobotStart
{
get { return robotStart; }
set
{
robotStart = value;
if (MyThread != null)
{
if (value)
{
SendControl("@RUN"); //运行程序
}
else
{
SendControl("@STOP");//停止运行
}
}
this.RaisePropertyChanged("RobotStart");
}
}
#endregion
#region 使能开关
private bool servoOn;
///
/// 使能开关
///
public bool ServoOn
{
get { return servoOn; }
set
{
servoOn = value;
this.RaisePropertyChanged("ServoOn");
if (RobotConn)
{
if (value)
{
SendControl("@MOTOR ON");
ConnectionStatus = "使能开启";
}
else
{
SendControl("@MOTOR OFF");
ConnectionStatus = "使能关闭";
}
}
}
}
#endregion
#region 机器人重置
///
/// 机器人重置
///
///
public override void Reset(object obj)
{
//SendControl("@RESET"); "@ALMRST"
SendControl("@ALMRST");
SendControl("@RESET");//复位程序
}
#endregion
#region 构造函数
///
/// 构造函数
///
public YamahaRobotVM(MachineModel machine)
{
MyWindow = new Robot();
MyWindow.DataContext = this;
MachineObj = machine;
ResetCommand = new DelegateCommand();
ResetCommand.ExecuteAction = new Action