Ejemplo n.º 1
0
        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);
                    isConnect = res == 0;
                    while (isConnect && m_mem.getStoreElement(ref el))
                    {
                        client.WriteArea(el.type, el.DBnum, el.offset, el.len, S7Consts.S7WLByte, el.data);
                    }
                }
                else
                {
                    disconnect();
                    Thread.Sleep(300);
                    connect();
                }

                Thread.Sleep(100);
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 public bool  getStoreElement(ref lsqElement el)
 {
     return(cq.TryDequeue(out el));
 }