123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Runtime.InteropServices;
- using Aitex.Core.RT.IOCore;
- using Aitex.Core.RT.PLC;
- namespace Aitex.Triton160.RT.PLC
- {
- public class CPLCBuffer : IDataBuffer<PLC_INPUT_DATA, PLC_OUTPUT_DATA>
- {
- private PLC_INPUT_DATA input;
- private PLC_OUTPUT_DATA output;
-
- public PLC_INPUT_DATA Input
- {
- get
- {
- return input;
- }
- set
- {
- input = value;
- }
- }
- public PLC_OUTPUT_DATA Output
- {
- get
- {
- return output;
- }
- set
- {
- output = value;
- }
- }
- public void UpdateDI(bool[] values)
- {
- for (int i = 0; i < input.DI.Length && i < values.Length; i++)
- {
- values[i] = input.DI[i] != 0 ? true : false;;
- }
- }
- public void UpdateAI(float[] values)
- {
- for (int i = 0; i < input.AI.Length && i < values.Length; i++)
- {
- values[i] = input.AI[i];
- }
- }
- public void UpdateDO(bool[] values)
- {
- for (int i = 0; i < output.DO.Length && i < values.Length; i++)
- {
- output.DO[i] = values[i] ? (byte)1 : (byte)0;
- //System.Diagnostics.Debug.Assert(!values[i]);
- }
- }
- public void UpdateAO(float[] values)
- {
- for (int i = 0; i < output.AO.Length && i < values.Length; i++)
- {
- output.AO[i] = values[i];
- }
- }
- public CPLCBuffer()
- {
- input = new PLC_INPUT_DATA();
- input.DI = new Byte[IOGroupManager.DioBlockLength];
- input.AI = new float[IOGroupManager.AioBlockLength];
-
- output = new PLC_OUTPUT_DATA();
- output.DO = new Byte[IOGroupManager.DioBlockLength];
- output.AO = new float[IOGroupManager.AioBlockLength];
- }
-
- }
- }
|