| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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
- {
- public int Number { get; set; }
- public float X_Position { get; set; }
- public float X_Velocity { get; set; }
- public float Y_Position { get; set; }
- public float Y_Velocity { get; set; }
- public float Z_Position_Start { get; set; }
- public float Z_Velocity_Start { get; set; }
- public float Z_Position_Stop { get; set; }
- public float Z_Velocity_Stop { get; set; }
- public float U_Position { get; set; }
- public float U_Velocity { get; set; }
- public float R_Position { get; set; }
- public float R_Velocity { get; set; }
- public float Torque { get; set; }
- public Int16 Feeder { get; set; }
- public Int16 ScrewProNum { get; set; }
- public PlcPoint()
- {
- Number = 0;
- X_Position = 0;
- X_Velocity = 0;
- Y_Position = 0;
- Y_Velocity = 0;
- Z_Position_Start = 0;
- Z_Velocity_Start = 0;
- Z_Position_Stop = 0;
- Z_Velocity_Stop = 0;
- U_Position = 0;
- U_Velocity = 0;
- R_Position = 0;
- R_Velocity = 0;
- Torque = 0;
- Feeder = 0;
- ScrewProNum = 0;
- }
- public PlcPoint Clone()
- {
- return new PlcPoint
- {
- Number = this.Number,
- X_Position = this.X_Position,
- X_Velocity = this.X_Velocity,
- Y_Position = this.Y_Position,
- Y_Velocity = this.Y_Velocity,
- 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 = this.U_Position,
- U_Velocity = this.U_Velocity,
- R_Position = this.R_Position,
- R_Velocity = this.R_Velocity,
- Torque = this.Torque,
- Feeder = this.Feeder,
- ScrewProNum = this.ScrewProNum
- };
- }
- /// <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.Address, Number), X_Position);
- nodeValues.Add(string.Format(plcAddress.X_Velocity.Address, Number), X_Velocity);
- nodeValues.Add(string.Format(plcAddress.Y_Position.Address, Number), Y_Position);
- nodeValues.Add(string.Format(plcAddress.Y_Velocity.Address, Number), Y_Velocity);
- 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.Address, Number), U_Position);
- nodeValues.Add(string.Format(plcAddress.U_Velocity.Address, Number), U_Velocity);
- 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);
- }
- }
- }
|