using HandyControl.Controls;
using Ping9719.WpfEx;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
using WCS.Model;
using WCS.Model.ApiModel.Home;
using 智能仓储WCS管理系统.Api;
namespace 智能仓储WCS管理系统.ViewModel
{
public class DeviceViewModel : BindableBase
{
public ICommand ResetAllShelfCommand { get => new DelegateCommand(ResetAllShelf); }
///
/// 打开用户
///
public void ResetAllShelf()
{
#region 调用接口 请求重置所有货架的状态
var body = new ResetShelfStatusRequest()
{
IsResetAll = true,
GroupNames = LocalFile.Config.GroupName,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp(LocalFile.Config.ApiIpHost + "home/resetShelfStatus", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Warning("复位成功!");
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
#endregion
}
public ICommand BarcodePrintTemplateCommand { get => new DelegateCommand(BarcodePrintTemplate); }
public void BarcodePrintTemplate()
{
try
{
Folder.OpenFolderAndSelectedFile(LocalFile.PrintTemplatePath);
}
catch (Exception)
{
Growl.Error("打开文件夹失败。");
}
}
}
public class DeviceReadModel : BindableBase
{
#region 属性
private string Name_;
///
/// 名称
///
public string Name { get => Name_; set { SetProperty(ref Name_, value); } }
private object Value_;
///
/// 值
///
public object Value { get => Value_; set { SetProperty(ref Value_, value); } }
///
/// 是否可见
///
public bool IsExpanded { get; set; }
///
/// Excel原始数据
///
public ExcelDeviceReadModel ExcelTag { get; set; }
#endregion
}
public class DeviceWriteModel : BindableBase
{
#region 属性
private string Name_;
///
/// 名称
///
public string Name { get => Name_; set { SetProperty(ref Name_, value); } }
private object Value_;
///
/// 是否合格
///
public object Value { get => Value_; set { SetProperty(ref Value_, value); } }
///
/// 是否可见
///
public bool IsExpanded { get; set; }
///
/// Excel原始数据
///
public ExcelDeviceWriteModel ExcelTag { get; set; }
#endregion
}
public class DeviceUrnModel : BindableBase
{
#region 属性
private string Name_;
///
/// 名称
///
public string Name { get => Name_; set { SetProperty(ref Name_, value); } }
private bool IsGoTo_;
///
/// 是否推到位
///
public bool IsGoTo { get => IsGoTo_; set { SetProperty(ref IsGoTo_, value); } }
private bool IsRetTo_;
///
/// 是否回到位
///
public bool IsRetTo { get => IsRetTo_; set { SetProperty(ref IsRetTo_, value); } }
///
/// 是否可见
///
public bool IsExpanded { get; set; }
///
/// 自定义数据
///
public ExcelDeviceUrnModel ExcelTag { get; set; }
#endregion
}
public class DeviceServoModel : BindableBase
{
#region 属性
private string Name_;
///
/// 名称
///
public string Name { get => Name_; set { SetProperty(ref Name_, value); } }
private double JogSpeed_;
///
/// 手动模式速度
///
public double JogSpeed { get => JogSpeed_; set { SetProperty(ref JogSpeed_, value); } }
private double AutoSpeed_;
///
/// 自动模式速度
///
public double AutoSpeed { get => AutoSpeed_; set { SetProperty(ref AutoSpeed_, value); } }
private double Location_;
///
/// 伺服当前位置
///
public double Location { get => Location_; set { SetProperty(ref Location_, value); } }
private bool IsJog_ = true;
///
/// 是否主页显示为手动模式
///
public bool IsJog { get => IsJog_; set { SetProperty(ref IsJog_, value); } }
private bool IsFold_ = true;
///
/// 是否折叠
///
public bool IsFold { get => IsFold_; set { SetProperty(ref IsFold_, value); } }
///
/// 是否可见
///
public bool IsExpanded { get; set; }
private ExcelDeviceServoModel ExcelTag_;
///
/// 自定义数据
///
public ExcelDeviceServoModel ExcelTag { get => ExcelTag_; set { SetProperty(ref ExcelTag_, value); } }
#endregion
}
}