예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
파일: plc.cs 프로젝트: TenYearsADream/east
        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);
            }
        }
예제 #4
0
 public bool  getStoreElement(ref lsqElement el)
 {
     return(cq.TryDequeue(out el));
 }