| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- 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;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- 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
- };
- }
- /// <summary>
- /// 将点位数据写入到PLC地址
- /// </summary>
- /// <param name="plcAddress"></param>
- /// <param name="pLC"></param>
- /// <returns></returns>
- public async Task<bool> WriteToPlcAddress(PlcPointAddress plcAddress, OpcUaClientPLC pLC)
- {
- Dictionary<string, object> nodeValues = new Dictionary<string, object>();
- 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);
- }
- }
- }
|