Example #1
0
        public void Read()
        {
            string str;

            for (int i = 0; i < instLength; i++)
            {
                str = string.Format("{0}[{1}]", name, i);
                client.Read(str, DoReadTcInstructions, UlTcInstruction.ParamLength);

                if (inst.Handle > -1)
                {
                    client.Read(str + ".args", DoReadTcArgs, UlTcInstruction.ArgsLength);

                    ContainsHandle(inst.Handle);

                    lock (dataLock)
                    {
                        instructs[inst.Handle].Index  = inst.Index;
                        instructs[inst.Handle].Step   = inst.Step;
                        instructs[inst.Handle].Active = inst.Active;
                        instructs[inst.Handle].State  = inst.State;

                        for (int j = 0; j < 8; j++)
                        {
                            instructs[inst.Handle].Args.Bools[j]   = inst.Args.Bools[j];
                            instructs[inst.Handle].Args.Bytes[j]   = inst.Args.Bytes[j];
                            instructs[inst.Handle].Args.Int16s[j]  = inst.Args.Int16s[j];
                            instructs[inst.Handle].Args.Int32s[j]  = inst.Args.Int32s[j];
                            instructs[inst.Handle].Args.Floats[j]  = inst.Args.Floats[j];
                            instructs[inst.Handle].Args.Doubles[j] = inst.Args.Doubles[j];
                        }
                    }
                }
            }
        }
Example #2
0
        protected override void Execute()
        {
            int position;

            tcLength     = client.ReadInt16(tagLength);
            tcHalfLength = tcLength / 2;

            while (Terminated == false)
            {
                // Is a half of DAQ storage full?
                if (client.ReadBoolean(tagActive) == true)
                {
                    int tcIndex = client.ReadInt16(tagIndex);

                    lock (dataLock)
                    {
                        errorCode = client.ReadInt16(tagErrorCode);

                        if (tcIndex < tcHalfLength)
                        {
                            position = valueLength * tcHalfLength;
                        }
                        else
                        {
                            position = 0;
                        }

                        client.Read(tagValues, ReadValues, valueLength * tcLength, position);

                        index = (index + tcHalfLength) % values.Length;
                    }

                    client.WriteBoolean(tagActive, false);
                }

                Thread.Sleep(1);
            }
        }