public void setMUInt16(UInt16 offset, UInt16 val) { lsqElement el = new lsqElement(); el.offset = offset; el.type = S7Consts.S7AreaMK; var tmp = BitConverter.GetBytes(val); el.data[0] = BitConverter.GetBytes(val)[1]; el.data[1] = BitConverter.GetBytes(val)[0]; el.len = 2; cq.Enqueue(el); }
public void setMBit(UInt16 offset, UInt16 bitOffset, bool val) { lsqElement el = new lsqElement(); el.offset = offset; el.type = S7Consts.S7AreaMK; var tmp = BitConverter.GetBytes(val); el.data[0] = val ? (byte)(m_mRegion[offset] | ((1 << bitOffset))) : (byte)(m_mRegion[offset] & ~(1 << bitOffset)); el.len = 1; cq.Enqueue(el); }
private void plcStep() { int res = 0; lsqElement el = new lsqElement(); while (Thread.VolatileRead(ref isThereadActive) != 0) { if (isConnect) { res = client.ReadArea(S7Consts.S7AreaMK, 0, 0, 800, S7Consts.S7WLByte, m_mem.m_mRegion); if (m_mem.getStoreElement(ref el)) { client.WriteArea(el.type, el.DBnum, el.offset, el.len, S7Consts.S7WLByte, el.data); } } Thread.Sleep(100); } }
public bool getStoreElement(ref lsqElement el) { return(cq.TryDequeue(out el)); }