| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596 |
- 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;
- using TeamAAS_VP.Services;
- 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 float _V_Position_Start;
- public float V_Position_Start
- {
- get { return _V_Position_Start; }
- set { SetProperty(ref _V_Position_Start, value); }
- }
- private float _V_Velocity_Start;
- public float V_Velocity_Start
- {
- get { return _V_Velocity_Start; }
- set { SetProperty(ref _V_Velocity_Start, value); }
- }
- private float _V_Position_Stop;
- public float V_Position_Stop
- {
- get { return _V_Position_Stop; }
- set { SetProperty(ref _V_Position_Stop, value); }
- }
- private float _V_Velocity_Stop;
- public float V_Velocity_Stop
- {
- get { return _V_Velocity_Stop; }
- set { SetProperty(ref _V_Velocity_Stop, value); }
- }
- private float _W_Position_Start;
- public float W_Position_Start
- {
- get { return _W_Position_Start; }
- set { SetProperty(ref _W_Position_Start, value); }
- }
- private float _W_Velocity_Start;
- public float W_Velocity_Start
- {
- get { return _W_Velocity_Start; }
- set { SetProperty(ref _W_Velocity_Start, value); }
- }
- private float _W_Position_Stop;
- public float W_Position_Stop
- {
- get { return _W_Position_Stop; }
- set { SetProperty(ref _W_Position_Stop, value); }
- }
- private float _W_Velocity_Stop;
- public float W_Velocity_Stop
- {
- get { return _W_Velocity_Stop; }
- set { SetProperty(ref _W_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 _CameraProcedureId1 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId1
- {
- get { return _CameraProcedureId1; }
- set { SetProperty(ref _CameraProcedureId1, value); }
- }
- private Guid _CameraProcedureId2 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId2
- {
- get { return _CameraProcedureId2; }
- set { SetProperty(ref _CameraProcedureId2, value); }
- }
- private Guid _CameraProcedureId3 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId3
- {
- get { return _CameraProcedureId3; }
- set { SetProperty(ref _CameraProcedureId3, value); }
- }
- private Guid _CameraProcedureId4 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId4
- {
- get { return _CameraProcedureId4; }
- set { SetProperty(ref _CameraProcedureId4, value); }
- }
- private Guid _CameraProcedureId5 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId5
- {
- get { return _CameraProcedureId5; }
- set { SetProperty(ref _CameraProcedureId5, value); }
- }
- private Guid _CameraProcedureId6 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId6
- {
- get { return _CameraProcedureId6; }
- set { SetProperty(ref _CameraProcedureId6, value); }
- }
- private Guid _CameraProcedureId7 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId7
- {
- get { return _CameraProcedureId7; }
- set { SetProperty(ref _CameraProcedureId7, value); }
- }
- private Guid _CameraProcedureId8 = Guid.Empty;
- /// <summary>
- /// Camera 对应的视觉流程 Id
- /// </summary>
- public Guid CameraProcedureId8
- {
- get { return _CameraProcedureId8; }
- set { SetProperty(ref _CameraProcedureId8, value); }
- }
- private Int16 _Camera_Data1;
- public Int16 Camera_Data1
- {
- get { return _Camera_Data1; }
- set { SetProperty(ref _Camera_Data1, value); }
- }
- private Int16 _Camera_Data2;
- public Int16 Camera_Data2
- {
- get { return _Camera_Data2; }
- set { SetProperty(ref _Camera_Data2, value); }
- }
- private Int16 _Camera_Data3;
- public Int16 Camera_Data3
- {
- get { return _Camera_Data3; }
- set { SetProperty(ref _Camera_Data3, value); }
- }
- private Int16 _Camera_Data4;
- public Int16 Camera_Data4
- {
- get { return _Camera_Data4; }
- set { SetProperty(ref _Camera_Data4, value); }
- }
- private Int16 _Camera_Product1;
- public Int16 Camera_Product1
- {
- get { return _Camera_Product1; }
- set { SetProperty(ref _Camera_Product1, value); }
- }
- private Int16 _Camera_Product2;
- public Int16 Camera_Product2
- {
- get { return _Camera_Product2; }
- set { SetProperty(ref _Camera_Product2, value); }
- }
- private Int16 _Camera_Product3;
- public Int16 Camera_Product3
- {
- get { return _Camera_Product3; }
- set { SetProperty(ref _Camera_Product3, value); }
- }
- private Int16 _Camera_Product4;
- public Int16 Camera_Product4
- {
- get { return _Camera_Product4; }
- set { SetProperty(ref _Camera_Product4, 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); }
- }
- private Int16 _AiVision;
- public Int16 AiVision
- {
- get { return _AiVision; }
- set { SetProperty(ref _AiVision, 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;
- V_Position_Start = 0;
- V_Velocity_Start = 0;
- V_Position_Stop = 0;
- V_Velocity_Stop = 0;
- W_Position_Start = 0;
- W_Velocity_Start = 0;
- W_Position_Stop = 0;
- W_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;
- AiVision = 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,
- AiVision = this.AiVision,
- 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,
- V_Position_Start = this.V_Position_Start,
- V_Velocity_Start = this.V_Velocity_Start,
- V_Position_Stop = this.V_Position_Stop,
- V_Velocity_Stop = this.V_Velocity_Stop,
- W_Position_Start = this.W_Position_Start,
- W_Velocity_Start = this.W_Velocity_Start,
- W_Position_Stop = this.W_Position_Stop,
- W_Velocity_Stop = this.W_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,
- CameraProcedureId1 = this.CameraProcedureId1,
- CameraProcedureId2 = this.CameraProcedureId2,
- CameraProcedureId3 = this.CameraProcedureId3,
- CameraProcedureId4 = this.CameraProcedureId4,
- CameraProcedureId5 = this.CameraProcedureId5,
- CameraProcedureId6 = this.CameraProcedureId6,
- CameraProcedureId7 = this.CameraProcedureId7,
- CameraProcedureId8 = this.CameraProcedureId8,
- Camera_Data1 = this.Camera_Data1,
- Camera_Data2 = this.Camera_Data2,
- Camera_Data3 = this.Camera_Data3,
- Camera_Data4 = this.Camera_Data4,
- Camera_Product1 = this.Camera_Product1,
- Camera_Product2 = this.Camera_Product2,
- Camera_Product3 = this.Camera_Product3,
- Camera_Product4 = this.Camera_Product4,
- //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.V_Position_Start.Address, Number), V_Position_Start);
- nodeValues.Add(string.Format(plcAddress.V_Velocity_Start.Address, Number), V_Velocity_Start);
- nodeValues.Add(string.Format(plcAddress.V_Position_Stop.Address, Number), V_Position_Stop);
- nodeValues.Add(string.Format(plcAddress.V_Velocity_Stop.Address, Number), V_Velocity_Stop);
- nodeValues.Add(string.Format(plcAddress.W_Position_Start.Address, Number), W_Position_Start);
- nodeValues.Add(string.Format(plcAddress.W_Velocity_Start.Address, Number), W_Velocity_Start);
- nodeValues.Add(string.Format(plcAddress.W_Position_Stop.Address, Number), W_Position_Stop);
- nodeValues.Add(string.Format(plcAddress.W_Velocity_Stop.Address, Number), W_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);
- }
- }
- }
|