using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TeamAAS_VP.Core.PLCs;
using TeamAAS_VP.Interfaces;
namespace TeamAAS_VP.Models.PLC
{
public class PlcPoint : BindableBase
{
private int _Number;
public int Number
{
get { return _Number; }
set { SetProperty(ref _Number, value); }
}
private string _Label;
public string Label
{
get { return _Label; }
set { SetProperty(ref _Label, value); }
}
private float _X_Position_Start;
public float X_Position_Start
{
get { return _X_Position_Start; }
set { SetProperty(ref _X_Position_Start, value); }
}
private float _X_Velocity_Start;
public float X_Velocity_Start
{
get { return _X_Velocity_Start; }
set { SetProperty(ref _X_Velocity_Start, value); }
}
private float _X_Position_Stop;
public float X_Position_Stop
{
get { return _X_Position_Stop; }
set { SetProperty(ref _X_Position_Stop, value); }
}
private float _X_Velocity_Stop;
public float X_Velocity_Stop
{
get { return _X_Velocity_Stop; }
set { SetProperty(ref _X_Velocity_Stop, value); }
}
private float _Y_Position_Start;
public float Y_Position_Start
{
get { return _Y_Position_Start; }
set { SetProperty(ref _Y_Position_Start, value); }
}
private float _Y_Velocity_Start;
public float Y_Velocity_Start
{
get { return _Y_Velocity_Start; }
set { SetProperty(ref _Y_Velocity_Start, value); }
}
private float _Y_Position_Stop;
public float Y_Position_Stop
{
get { return _Y_Position_Stop; }
set { SetProperty(ref _Y_Position_Stop, value); }
}
private float _Y_Velocity_Stop;
public float Y_Velocity_Stop
{
get { return _Y_Velocity_Stop; }
set { SetProperty(ref _Y_Velocity_Stop, value); }
}
private float _Z_Position_Start;
public float Z_Position_Start
{
get { return _Z_Position_Start; }
set { SetProperty(ref _Z_Position_Start, value); }
}
private float _Z_Velocity_Start;
public float Z_Velocity_Start
{
get { return _Z_Velocity_Start; }
set { SetProperty(ref _Z_Velocity_Start, value); }
}
private float _Z_Position_Stop;
public float Z_Position_Stop
{
get { return _Z_Position_Stop; }
set { SetProperty(ref _Z_Position_Stop, value); }
}
private float _Z_Velocity_Stop;
public float Z_Velocity_Stop
{
get { return _Z_Velocity_Stop; }
set { SetProperty(ref _Z_Velocity_Stop, value); }
}
private float _U_Position_Start;
public float U_Position_Start
{
get { return _U_Position_Start; }
set { SetProperty(ref _U_Position_Start, value); }
}
private float _U_Velocity_Start;
public float U_Velocity_Start
{
get { return _U_Velocity_Start; }
set { SetProperty(ref _U_Velocity_Start, value); }
}
private float _U_Position_Stop;
public float U_Position_Stop
{
get { return _U_Position_Stop; }
set { SetProperty(ref _U_Position_Stop, value); }
}
private float _U_Velocity_Stop;
public float U_Velocity_Stop
{
get { return _U_Velocity_Stop; }
set { SetProperty(ref _U_Velocity_Stop, value); }
}
private Int16 _Enable_Start_Node;
public Int16 Enable_Start_Node
{
get { return _Enable_Start_Node; }
set { SetProperty(ref _Enable_Start_Node, value); }
}
private Int16 _Enable_Pulse;
public Int16 Enable_Pulse
{
get { return _Enable_Pulse; }
set { SetProperty(ref _Enable_Pulse, value); }
}
private Int16 _Enable_3D;
public Int16 Enable_3D
{
get { return _Enable_3D; }
set { SetProperty(ref _Enable_3D, value); }
}
private Int16 _Enable_Wait_Finish;
public Int16 Enable_Wait_Finish
{
get { return _Enable_Wait_Finish; }
set { SetProperty(ref _Enable_Wait_Finish, value); }
}
private Int16 _Enable_Light1;
public Int16 Enable_Light1
{
get { return _Enable_Light1; }
set { SetProperty(ref _Enable_Light1, value); }
}
private Int16 _Enable_Light2;
public Int16 Enable_Light2
{
get { return _Enable_Light2; }
set { SetProperty(ref _Enable_Light2, value); }
}
private Int16 _Enable_Light3;
public Int16 Enable_Light3
{
get { return _Enable_Light3; }
set { SetProperty(ref _Enable_Light3, value); }
}
private Int16 _Enable_Light4;
public Int16 Enable_Light4
{
get { return _Enable_Light4; }
set { SetProperty(ref _Enable_Light4, value); }
}
private Guid _CameraProcedureId = Guid.Empty;
///
/// Camera 对应的视觉流程 Id
///
public Guid CameraProcedureId
{
get { return _CameraProcedureId; }
set { SetProperty(ref _CameraProcedureId, value); }
}
private float _R_Position;
public float R_Position
{
get { return _R_Position; }
set { SetProperty(ref _R_Position, value); }
}
private float _R_Velocity;
public float R_Velocity
{
get { return _R_Velocity; }
set { SetProperty(ref _R_Velocity, value); }
}
private float _Torque;
public float Torque
{
get { return _Torque; }
set { SetProperty(ref _Torque, value); }
}
private Int16 _Feeder;
public Int16 Feeder
{
get { return _Feeder; }
set { SetProperty(ref _Feeder, value); }
}
private Int16 _ScrewProNum;
public Int16 ScrewProNum
{
get { return _ScrewProNum; }
set { SetProperty(ref _ScrewProNum, value); }
}
//描述
private string _Description;
public string Description
{
get { return _Description; }
set { SetProperty(ref _Description, value); }
}
public PlcPoint()
{
Number = 0;
X_Position_Start = 0;
X_Velocity_Start = 0;
X_Position_Stop = 0;
X_Velocity_Stop = 0;
Y_Position_Start = 0;
Y_Velocity_Start = 0;
Y_Position_Stop = 0;
Y_Velocity_Stop = 0;
Z_Position_Start = 0;
Z_Velocity_Start = 0;
Z_Position_Stop = 0;
Z_Velocity_Stop = 0;
U_Position_Start = 0;
U_Velocity_Start = 0;
U_Position_Stop = 0;
U_Velocity_Stop = 0;
Enable_Start_Node = 0;
Enable_Pulse = 0;
Enable_3D = 0;
Enable_Wait_Finish = 0;
Enable_Light1 = 0;
Enable_Light2 = 0;
Enable_Light3 = 0;
Enable_Light4 = 0;
//R_Position = 0;
//R_Velocity = 0;
//Torque = 0;
//Feeder = 0;
//ScrewProNum = 0;
}
public PlcPoint Clone()
{
return new PlcPoint
{
Number = this.Number,
Label = this.Label,
X_Position_Start = this.X_Position_Start,
X_Velocity_Start= this.X_Velocity_Start,
X_Position_Stop = this.X_Position_Stop,
X_Velocity_Stop = this.X_Velocity_Stop,
Y_Position_Start = this.Y_Position_Start,
Y_Velocity_Start = this.Y_Velocity_Start,
Y_Position_Stop = this.Y_Position_Stop,
Y_Velocity_Stop = this.Y_Velocity_Stop,
Z_Position_Start = this.Z_Position_Start,
Z_Velocity_Start = this.Z_Velocity_Start,
Z_Position_Stop = this.Z_Position_Stop,
Z_Velocity_Stop = this.Z_Velocity_Stop,
U_Position_Start = this.U_Position_Start,
U_Velocity_Start = this.U_Velocity_Start,
U_Position_Stop = this.U_Position_Stop,
U_Velocity_Stop = this.U_Velocity_Stop,
Enable_Start_Node = this.Enable_Start_Node,
Enable_Pulse = this.Enable_Pulse,
Enable_3D = this.Enable_3D,
Enable_Wait_Finish = this.Enable_Wait_Finish,
Enable_Light1 = this.Enable_Light1,
Enable_Light2 = this.Enable_Light2,
Enable_Light3 = this.Enable_Light3,
Enable_Light4 = this.Enable_Light4,
CameraProcedureId = this.CameraProcedureId,
//R_Position = this.R_Position,
//R_Velocity = this.R_Velocity,
//Torque = this.Torque,
//Feeder = this.Feeder,
//ScrewProNum = this.ScrewProNum,
//Description = this.Description
};
}
///
/// 将点位数据写入到PLC地址
///
///
///
///
public async Task WriteToPlcAddress(PlcPointAddress plcAddress, OpcUaClientPLC pLC)
{
Dictionary nodeValues = new Dictionary();
nodeValues.Add(string.Format(plcAddress.X_Position_Start.Address, Number), X_Position_Start);
nodeValues.Add(string.Format(plcAddress.X_Velocity_Start.Address, Number), X_Velocity_Start);
nodeValues.Add(string.Format(plcAddress.X_Position_Stop.Address, Number), X_Position_Stop);
nodeValues.Add(string.Format(plcAddress.X_Velocity_Stop.Address, Number), X_Velocity_Stop);
nodeValues.Add(string.Format(plcAddress.Y_Position_Start.Address, Number), Y_Position_Start);
nodeValues.Add(string.Format(plcAddress.Y_Velocity_Start.Address, Number), Y_Velocity_Start);
nodeValues.Add(string.Format(plcAddress.Y_Position_Stop.Address, Number), Y_Position_Stop);
nodeValues.Add(string.Format(plcAddress.Y_Velocity_Stop.Address, Number), Y_Velocity_Stop);
nodeValues.Add(string.Format(plcAddress.Z_Position_Start.Address, Number), Z_Position_Start);
nodeValues.Add(string.Format(plcAddress.Z_Velocity_Start.Address, Number), Z_Velocity_Start);
nodeValues.Add(string.Format(plcAddress.Z_Position_Stop.Address, Number), Z_Position_Stop);
nodeValues.Add(string.Format(plcAddress.Z_Velocity_Stop.Address, Number), Z_Velocity_Stop);
nodeValues.Add(string.Format(plcAddress.U_Position_Start.Address, Number), U_Position_Start);
nodeValues.Add(string.Format(plcAddress.U_Velocity_Start.Address, Number), U_Velocity_Start);
nodeValues.Add(string.Format(plcAddress.U_Position_Stop.Address, Number), U_Position_Stop);
nodeValues.Add(string.Format(plcAddress.U_Velocity_Stop.Address, Number), U_Velocity_Stop);
nodeValues.Add(string.Format(plcAddress.Enable_Start_Node.Address, Number), Enable_Start_Node);
nodeValues.Add(string.Format(plcAddress.Enable_Pulse.Address, Number), Enable_Pulse);
nodeValues.Add(string.Format(plcAddress.Enable_3D.Address, Number), Enable_3D);
nodeValues.Add(string.Format(plcAddress.Enable_Wait_Finish.Address, Number), Enable_Wait_Finish);
nodeValues.Add(string.Format(plcAddress.Enable_Light1.Address, Number), Enable_Light1);
nodeValues.Add(string.Format(plcAddress.Enable_Light2.Address, Number), Enable_Light2);
nodeValues.Add(string.Format(plcAddress.Enable_Light3.Address, Number), Enable_Light3);
nodeValues.Add(string.Format(plcAddress.Enable_Light4.Address, Number), Enable_Light4);
//nodeValues.Add(string.Format(plcAddress.R_Position.Address, Number), R_Position);
//nodeValues.Add(string.Format(plcAddress.R_Velocity.Address, Number), R_Velocity);
//nodeValues.Add(string.Format(plcAddress.Torque.Address, Number), Torque);
//nodeValues.Add(string.Format(plcAddress.Feeder.Address, Number), Feeder);
//nodeValues.Add(string.Format(plcAddress.ScrewProNum.Address, Number), ScrewProNum);
return await pLC.WriteNodesAsync(nodeValues);
}
}
}