| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- using Newtonsoft.Json;
- using NPOI.Util;
- using Prism.Mvvm;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TeamAAS_VP.Models.PLC;
- using TeamAAS_VP.Models.Product;
- using TeamAAS_VP.Models.Robot;
- namespace TeamAAS_VP.Models
- {
- [JsonObject(MemberSerialization.OptOut)]
- public class ProductModel : BindableBase
- {
- private Guid _ID;
- public Guid ID
- {
- get { return _ID; }
- set { SetProperty(ref _ID, value); }
- }
- private string _Name;
- public string Name
- {
- get { return _Name; }
- set { SetProperty(ref _Name, value); }
- }
- private int _NumberCode;
- public int NumberCode
- {
- get { return _NumberCode; }
- set
- {
- SetProperty(ref _NumberCode, value);
- }
- }
- private string _Description;
- public string Description
- {
- get { return _Description; }
- set { SetProperty(ref _Description, value); }
- }
- private DateTime _DateTime;
- public DateTime DateTime
- {
- get { return _DateTime; }
- set { SetProperty(ref _DateTime, value); }
- }
- private ObservableCollection<CameraProcedure> _CameraProcedures;
- /// <summary>
- /// 相机流程集合
- /// </summary>
- public ObservableCollection<CameraProcedure> CameraProcedures
- {
- get { return _CameraProcedures; }
- set { SetProperty(ref _CameraProcedures, value); }
- }
- private CameraProcedure _SelectedProcedure;
- public CameraProcedure SelectedProcedure
- {
- get { return _SelectedProcedure; }
- set { SetProperty(ref _SelectedProcedure, value); }
- }
- private RobotPoint _RobotPoint;
- /// <summary>
- /// 机器人点位表
- /// </summary>
- public RobotPoint RobotPoint
- {
- get { return _RobotPoint; }
- set { SetProperty(ref _RobotPoint, value); }
- }
- private int _Speed;
- /// <summary>
- /// PTP速度
- /// </summary>
- public int Speed
- {
- get { return _Speed; }
- set { SetProperty(ref _Speed, value); }
- }
- private int _Accel;
- /// <summary>
- /// PTP加减速度
- /// </summary>
- public int Accel
- {
- get { return _Accel; }
- set { SetProperty(ref _Accel, value); }
- }
- private int _Speeds;
- /// <summary>
- /// CP速度
- /// </summary>
- public int Speeds
- {
- get { return _Speeds; }
- set { SetProperty(ref _Speeds, value); }
- }
- private int _Accels;
- /// <summary>
- /// CP加减速度
- /// </summary>
- public int Accels
- {
- get { return _Accels; }
- set { SetProperty(ref _Accels, value); }
- }
- private bool _Power;
- /// <summary>
- /// 功率
- /// </summary>
- public bool Power
- {
- get { return _Power; }
- set { SetProperty(ref _Power, value); }
- }
- private bool _IsUserUpCamera;
- /// <summary>
- /// 启用二次定位相机
- /// </summary>
- public bool IsUserUpCamera
- {
- get { return _IsUserUpCamera; }
- set { SetProperty(ref _IsUserUpCamera, value); }
- }
- private Guid _FixedUpCamera1ProcedureId;
- /// <summary>
- /// 固定向上相机1视觉流程ID
- /// </summary>
- public Guid FixedUpCamera1ProcedureId
- {
- get { return _FixedUpCamera1ProcedureId; }
- set { SetProperty(ref _FixedUpCamera1ProcedureId, value); }
- }
- private Guid _FixedUpCamera2ProcedureId;
- /// <summary>
- /// 固定向上相机2视觉流程ID
- /// </summary>
- public Guid FixedUpCamera2ProcedureId
- {
- get { return _FixedUpCamera2ProcedureId; }
- set { SetProperty(ref _FixedUpCamera2ProcedureId, value); }
- }
- // 二维码扫码流程ID
- private Guid _QrCodeProcedureId;
- public Guid QrCodeProcedureId
- {
- get { return _QrCodeProcedureId; }
- set { SetProperty(ref _QrCodeProcedureId, value); }
- }
- /// <summary>
- /// 固定向上的相机模板角度
- /// </summary>
- private double _FixedUpCameraTempletAngle;
- public double FixedUpCameraTempletAngle
- {
- get { return _FixedUpCameraTempletAngle; }
- set { SetProperty(ref _FixedUpCameraTempletAngle, value); }
- }
- private Guid _FixedDownCamera1ProcedureId;
- /// <summary>
- /// 固定向下相机取料流程ID
- /// </summary>
- public Guid FixedDownCamera1ProcedureId
- {
- get { return _FixedDownCamera1ProcedureId; }
- set { SetProperty(ref _FixedDownCamera1ProcedureId, value); }
- }
- private Guid _FixedDownCamera2ProcedureId;
- /// <summary>
- /// 固定向下相机取料流程ID
- /// </summary>
- public Guid FixedDownCamera2ProcedureId
- {
- get { return _FixedDownCamera2ProcedureId; }
- set { SetProperty(ref _FixedDownCamera2ProcedureId, value); }
- }
- private Guid _MoveDownCamera1LockPhotoProcedureId;
- /// <summary>
- /// 移动向下相机1锁付拍照流程ID
- /// </summary>
- public Guid MoveDownCamera1LockPhotoProcedureId
- {
- get { return _MoveDownCamera1LockPhotoProcedureId; }
- set { SetProperty(ref _MoveDownCamera1LockPhotoProcedureId, value); }
- }
- private Guid _MoveDownCamera2LockPhotoProcedureId;
- /// <summary>
- /// 移动向下相机2锁付拍照流程ID
- /// </summary>
- public Guid MoveDownCamera2LockPhotoProcedureId
- {
- get { return _MoveDownCamera2LockPhotoProcedureId; }
- set { SetProperty(ref _MoveDownCamera2LockPhotoProcedureId, value); }
- }
- private Guid _MoveDownCamer1PickPhotoProcedureId;
- /// <summary>
- /// 移动向下相机1取料拍照流程ID
- /// </summary>
- public Guid MoveDownCamer1PickPhotoProcedureId
- {
- get { return _MoveDownCamer1PickPhotoProcedureId; }
- set { SetProperty(ref _MoveDownCamer1PickPhotoProcedureId, value); }
- }
- private Guid _MoveDownCamer2PickPhotoProcedureId;
- /// <summary>
- /// 移动向下相机2取料拍照流程ID
- /// </summary>
- public Guid MoveDownCamer2PickPhotoProcedureId
- {
- get { return _MoveDownCamer2PickPhotoProcedureId; }
- set { SetProperty(ref _MoveDownCamer2PickPhotoProcedureId, value); }
- }
- private Guid _IndependentCamer1ProductProcedureId;
- /// <summary>
- /// 独立移动模组相机1产品定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer1ProductProcedureId
- {
- get { return _IndependentCamer1ProductProcedureId; }
- set { SetProperty(ref _IndependentCamer1ProductProcedureId, value); }
- }
- private Guid _IndependentCamer2ProductProcedureId;
- /// <summary>
- /// 独立移动模组相机2产品定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer2ProductProcedureId
- {
- get { return _IndependentCamer2ProductProcedureId; }
- set { SetProperty(ref _IndependentCamer2ProductProcedureId, value); }
- }
- private Guid _IndependentCamer3ProductProcedureId;
- /// <summary>
- /// 独立移动模组相机3产品定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer3ProductProcedureId
- {
- get { return _IndependentCamer3ProductProcedureId; }
- set { SetProperty(ref _IndependentCamer3ProductProcedureId, value); }
- }
- private Guid _IndependentCamer4ProductProcedureId;
- /// <summary>
- /// 独立移动模组相机4产品定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer4ProductProcedureId
- {
- get { return _IndependentCamer4ProductProcedureId; }
- set { SetProperty(ref _IndependentCamer4ProductProcedureId, value); }
- }
- private Guid _IndependentCamer1AuxProcedureId;
- /// <summary>
- /// 独立移动模组相机1辅料定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer1AuxProcedureId
- {
- get { return _IndependentCamer1AuxProcedureId; }
- set { SetProperty(ref _IndependentCamer1AuxProcedureId, value); }
- }
- private Guid _IndependentCamer2AuxProcedureId;
- /// <summary>
- /// 独立移动模组相机2辅料定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer2AuxProcedureId
- {
- get { return _IndependentCamer2AuxProcedureId; }
- set { SetProperty(ref _IndependentCamer2AuxProcedureId, value); }
- }
- private Guid _IndependentCamer3AuxProcedureId;
- /// <summary>
- /// 独立移动模组相机3辅料定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer3AuxProcedureId
- {
- get { return _IndependentCamer3AuxProcedureId; }
- set { SetProperty(ref _IndependentCamer3AuxProcedureId, value); }
- }
- private Guid _IndependentCamer4AuxProcedureId;
- /// <summary>
- /// 独立移动模组相机4辅料定位拍照流程ID
- /// </summary>
- public Guid IndependentCamer4AuxProcedureId
- {
- get { return _IndependentCamer4AuxProcedureId; }
- set { SetProperty(ref _IndependentCamer4AuxProcedureId, value); }
- }
- private Guid _IndependentCamer1CheckProcedureId;
- /// <summary>
- /// 独立移动模组相机1检测任务拍照流程ID
- /// </summary>
- public Guid IndependentCamer1CheckProcedureId
- {
- get { return _IndependentCamer1CheckProcedureId; }
- set { SetProperty(ref _IndependentCamer1CheckProcedureId, value); }
- }
- private Guid _IndependentCamer2CheckProcedureId;
- /// <summary>
- /// 独立移动模组相机2检测任务拍照流程ID
- /// </summary>
- public Guid IndependentCamer2CheckProcedureId
- {
- get { return _IndependentCamer2CheckProcedureId; }
- set { SetProperty(ref _IndependentCamer2CheckProcedureId, value); }
- }
- private Guid _IndependentCamer3CheckProcedureId;
- /// <summary>
- /// 独立移动模组相机3检测任务拍照流程ID
- /// </summary>
- public Guid IndependentCamer3CheckProcedureId
- {
- get { return _IndependentCamer3CheckProcedureId; }
- set { SetProperty(ref _IndependentCamer3CheckProcedureId, value); }
- }
- private Guid _IndependentCamer4CheckProcedureId;
- /// <summary>
- /// 独立移动模组相机4检测任务拍照流程ID
- /// </summary>
- public Guid IndependentCamer4CheckProcedureId
- {
- get { return _IndependentCamer4CheckProcedureId; }
- set { SetProperty(ref _IndependentCamer4CheckProcedureId, value); }
- }
- /// <summary>
- /// 移动向上的相机模板角度
- /// </summary>
- private double _MoveDownCamerTempletAngle;
- public double MoveDownCamerTempletAngle
- {
- get { return _MoveDownCamerTempletAngle; }
- set { SetProperty(ref _MoveDownCamerTempletAngle, value); }
- }
- private ObservableCollection<ProductGlobalParam> _GlobalParamListCollection;
- /// <summary>
- /// 产品全局参数集合
- /// </summary>
- public ObservableCollection<ProductGlobalParam> GlobalParamListCollection
- {
- get { return _GlobalParamListCollection; }
- set { SetProperty(ref _GlobalParamListCollection, value); }
- }
- private ObservableCollection<PlcPoint> _PickCameraPoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 取料拍照点位集合
- /// </summary>
- public ObservableCollection<PlcPoint> PickCameraPoints
- {
- get { return _PickCameraPoints; }
- set { SetProperty(ref _PickCameraPoints, value); }
- }
- private ObservableCollection<PlcPoint> _PickPoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 取料点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> PickPoints
- {
- get { return _PickPoints; }
- set { SetProperty(ref _PickPoints, value); }
- }
- private ObservableCollection<PlcPoint> _SecPosCameraPoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 下相机二次定位点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> SecPosCameraPoints
- {
- get { return _SecPosCameraPoints; }
- set { SetProperty(ref _SecPosCameraPoints, value); }
- }
- private ObservableCollection<PlcPoint> _QrCodePoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 二维码拍照点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> QrCodePoints
- {
- get { return _QrCodePoints; }
- set { SetProperty(ref _QrCodePoints, value); }
- }
- private ObservableCollection<PlcPoint> _ScrewCameraPoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 锁附拍照点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> ScrewCameraPoints
- {
- get { return _ScrewCameraPoints; }
- set { SetProperty(ref _ScrewCameraPoints, value); }
- }
- private PlcPoint _ScrewCameraLocalPos1= new PlcPoint();
- /// <summary>
- /// 锁付拍照点1对应的产品坐标系中的点位
- /// </summary>
- public PlcPoint ScrewCameraLocalPos1
- {
- get { return _ScrewCameraLocalPos1; }
- set { SetProperty(ref _ScrewCameraLocalPos1, value); }
- }
- private PlcPoint _ScrewCameraLocalPos2 = new PlcPoint();
- /// <summary>
- /// 锁付拍照点2对应的产品坐标系中的点位
- /// </summary>
- public PlcPoint ScrewCameraLocalPos2
- {
- get { return _ScrewCameraLocalPos2; }
- set { SetProperty(ref _ScrewCameraLocalPos2, value); }
- }
- private ObservableCollection<PlcPoint> _ScrewPoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 锁附点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> ScrewPoints
- {
- get { return _ScrewPoints; }
- set { SetProperty(ref _ScrewPoints, value); }
- }
- private ObservableCollection<PlcPoint> _CheckCameraPoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 复检点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> CheckCameraPoints
- {
- get { return _CheckCameraPoints; }
- set { SetProperty(ref _CheckCameraPoints, value); }
- }
- private ObservableCollection<PlcPoint> _IndependentCamerPoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 独立移动相机步进坐标系点位
- /// </summary>
- public ObservableCollection<PlcPoint> IndependentCamerPoints
- {
- get { return _IndependentCamerPoints; }
- set { SetProperty(ref _IndependentCamerPoints, value); }
- }
- private ObservableCollection<PlcPoint> _RemovePoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 撕膜点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> RemovePoints
- {
- get { return _RemovePoints; }
- set { SetProperty(ref _RemovePoints, value); }
- }
- private ObservableCollection<PlcPoint> _PressurePlacePoints = new ObservableCollection<PlcPoint>();
- /// <summary>
- /// 压力组装点位参数集合
- /// </summary>
- public ObservableCollection<PlcPoint> PressurePlacePoints
- {
- get { return _PressurePlacePoints; }
- set { SetProperty(ref _PressurePlacePoints, value); }
- }
- private bool _IsLoad;
- /// <summary>
- /// 是否已加载
- /// </summary>
- [JsonIgnore]
- public bool IsLoad
- {
- get { return _IsLoad; }
- set { SetProperty(ref _IsLoad, value); }
- }
- private bool _IsCreate;
- /// <summary>
- /// 正在创建
- /// </summary>
- [JsonIgnore]
- public bool IsCreate
- {
- get { return _IsCreate; }
- set { SetProperty(ref _IsCreate, value); }
- }
- /// <summary>
- /// 增加相机流程
- /// </summary>
- /// <param name="cameraProcedure"></param>
- /// <exception cref="Exception"></exception>
- public void AddCameraProcedure(CameraProcedure cameraProcedure)
- {
- if (CameraProcedures == null)
- {
- CameraProcedures = new ObservableCollection<CameraProcedure>();
- }
- //判断是否已存在相同相机的流程
- if (CameraProcedures.Any(cp => cp.ID == cameraProcedure.ID))
- {
- throw new Exception("已存在相同相机的流程,无法添加重复相机流程!");
- }
- CameraProcedures.Add(cameraProcedure);
- }
- /// <summary>
- /// 移除相机流程
- /// </summary>
- /// <param name="id"></param>
- public void RemoveCameraProcedure(Guid id)
- {
- var procedure = CameraProcedures.FirstOrDefault(cp => cp.ID == id);
- if (procedure != null)
- {
- CameraProcedures.Remove(procedure);
- }
- }
- /// <summary>
- /// 增加全局参数
- /// </summary>
- /// <param name="globalParam"></param>
- public void AddGlobalParam(ProductGlobalParam globalParam)
- {
- if (GlobalParamListCollection == null)
- {
- GlobalParamListCollection = new ObservableCollection<ProductGlobalParam>();
- }
- globalParam.Number= GlobalParamListCollection.Count + 1;
- GlobalParamListCollection.Add(globalParam);
- }
- /// <summary>
- /// 移除全局参数
- /// </summary>
- /// <param name="globalParam"></param>
- public void RemoveGlobalParam(ProductGlobalParam globalParam)
- {
- GlobalParamListCollection.Remove(globalParam);
- //重新编号
- int number = 1;
- //先排序
- var sortedList = GlobalParamListCollection.OrderBy(gp => gp.Number).ToList();
- foreach (var gp in sortedList)
- {
- gp.Number = number;
- number++;
- }
- GlobalParamListCollection=new ObservableCollection<ProductGlobalParam>(sortedList);
- }
- public ProductModel Clone()
- {
- return new ProductModel
- {
- ID = this.ID,
- Name = this.Name,
- NumberCode = this.NumberCode,
- Description = this.Description,
- DateTime = this.DateTime,
- CameraProcedures = new ObservableCollection<CameraProcedure>(this.CameraProcedures.Select(cp => cp.Clone())),
- RobotPoint = this.RobotPoint?.Clone(),
- Speed = this.Speed,
- Accel = this.Accel,
- Speeds = this.Speeds,
- Accels = this.Accels,
- Power = this.Power,
- IsUserUpCamera = this.IsUserUpCamera,
- GlobalParamListCollection = new ObservableCollection<ProductGlobalParam>(this.GlobalParamListCollection.Select(gp => gp.Copy())),
- PickCameraPoints = this.PickCameraPoints,
- PickPoints = this.PickPoints,
- SecPosCameraPoints = this.SecPosCameraPoints,
- ScrewCameraPoints = this.ScrewCameraPoints,
- ScrewPoints = this.ScrewPoints,
- CheckCameraPoints = this.CheckCameraPoints,
- IndependentCamerPoints = this.IndependentCamerPoints,
- RemovePoints = this.RemovePoints,
- PressurePlacePoints = this.PressurePlacePoints,
- IsLoad = this.IsLoad,
- IsCreate = this.IsCreate,
- QrCodePoints = this.QrCodePoints,
- };
- }
- }
- }
|