using Community;
using DAL;
using MahApps.Metro.Controls.Dialogs;
using Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace ViewModel
{
public class StandVM : NotificationObject
{
///
/// 上报异常的委托
///
///
public delegate void delegeateExcep(string str);
///
/// 上报异常的委托事件
///
public event delegeateExcep eventExcepReport;
///
/// 数据引擎
///
MainWindowDAL dal = new MainWindowDAL();
#region 站别参数
private StandModel myStand;
///
/// 站别参数
///
public StandModel MyStand
{
get { return myStand; }
set
{
myStand = value;
RaisePropertyChanged("MyStand");
}
}
#endregion
#region 输入信号
private List inputList;
///
/// 输入信号
///
public List InputList
{
get { return inputList; }
set
{
inputList = value;
RaisePropertyChanged("InputList");
}
}
#endregion
#region 输出信号
private List outputList;
///
/// 输出信号
///
public List OutputList
{
get { return outputList; }
set
{
outputList = value;
RaisePropertyChanged("OutputList");
}
}
#endregion
#region 通讯连接对象
private CommunicationManagementClass myConnect;
///
/// 通讯连接对象
///
public CommunicationManagementClass MyConnect
{
get { return myConnect; }
set
{
myConnect = value;
RaisePropertyChanged("MyConnect");
}
}
///
/// 测试软件返回的信息
///
CmdMessage TestSoftMessage { get; set; }
///
/// 测试仪器回调函数
///
///
private void TestContact_ReceiveCallback(string str)
{
TestSoftMessage = XmlTocmdResp(str);
TestLog(str);//记录日志信息
// TestSoftResp(TestSoftMessage);
}
#endregion
#region 取料点
///
/// 取料点
///
public RobotPoint TakePoint { get; set; }
#endregion
#region 放料点
///
/// 放料点
///
public RobotPoint PutPoint { get; set; }
#endregion
#region 指令集合
private List cmdList;
///
/// 指令集合
///
public List CmdList
{
get { return cmdList; }
set { cmdList = value; RaisePropertyChanged("CmdList"); }
}
#endregion
#region 选中的测试指令
private CommonClass selectCmd;
///
/// 选中的测试指令
///
public CommonClass SelectCmd
{
get { return selectCmd; }
set { selectCmd = value; RaisePropertyChanged("SelectCmd"); }
}
#endregion
#region 各种方法
///
/// 手动发送测试指令
///
public DelegateCommand ShouDongSendCmdCommand { get; set; }
///
/// 生产数据清零
///
public DelegateCommand CountClearedCommand { get; set; }
#endregion
///
/// 当前机种对象
///
public MachineModel CurrMachine { get; set; }
private bool isEnable;
///
/// 编辑权限
///
public bool IsEnable
{
get { return isEnable; }
set { isEnable = value; RaisePropertyChanged("IsEnable"); }
}
#region 构造函数
///
/// 构造函数
///
public StandVM(StandModel sm)
{
this.MyStand = sm;
this.InputList = dal.GetInputList(sm.StandType);
this.OutputList = dal.GetOutputList(sm.StandType);
BoxOpenState = new ShowInfo();
CmdList = new List() { new CommonClass() { CommonName="状态询问",CmdStr="A0 01 00 E0" },
new CommonClass() { CommonName="发送SN",CmdStr="SendSN"},
new CommonClass() { CommonName="PCB放置完成",CmdStr="A0 03 00 E0"},
new CommonClass() { CommonName="开始测试",CmdStr="A0 04 00 E0"},
};
ShouDongSendCmdCommand = new DelegateCommand() { ExecuteAction = new Action