}//Tag

    internal virtual void UpdateAllTags(IReadValue val)
    {
      for (ushort idx = 0; (idx < mylength); idx++)
      {
        try
        {
          tagHendlers[idx].UpdateTag(val.ReadValue(idx, tagHendlers[idx].TagCanonicalType));
        }
        catch (Exception ex)
        {
          tagHendlers[idx].MarkTagQuality(Opc.Da.qualityBits.badCommFailure);
          CommServerComponent.Tracer.TraceWarning(187, "DataBlock.UpdateAllTags",
            "An exception was thrown during data read:  " + ex.Message);
        }
      }
    }
Beispiel #2
0
        public override void Read(ReadArgs args)
        {
            IReadValue  rv = args.Read.GetReadValue();
            ValueRecord vr = args.ValueRec;

            int readChar = args.ReadOne();

            switch (readChar)
            {
            case iBoolTrue:
                args.AddValue(true);
                rv.ReadValue(vr, args.valPos, true);
                break;

            case iBoolFalse:
                args.AddValue(false);
                rv.ReadValue(vr, args.valPos, false);
                break;

            case iStringEncl:
                String str = base.ReadStringStrict(args, false);
                args.AddValue(str);
                rv.ReadValue(vr, args.valPos, str);
                break;

            case iRefPrefix:
                Record rc = base.ReadRef(args, false);
                if (rc.RecType != RecordType.Instance && rc.RecType != RecordType.Array)
                {
                    throw Error.UnexpectedRecordType(RecordType.Instance, rc.RecType);
                }
                args.AddValue(rc);
                rv.ReadValue(vr, args.valPos, rc);
                return;

            case iDateTimePrefix:
                DateTime dt = new DateTime(
                    ReadDateTimeDigits(args, 4),
                    ReadDateTimeDigits(args, 2),
                    ReadDateTimeDigits(args, 2),
                    ReadSkipOne(args, iDateTimeT).ReadDateTimeDigits(args, 2),
                    ReadDateTimeDigits(args, 2),
                    ReadDateTimeDigits(args, 2),
                    ReadDateTimeDigits(args, 3)
                    );
                args.AddValue(dt);
                rv.ReadValue(vr, args.valPos, dt);
                break;

            case iFieldSep:
                args.AddValue(null);
                rv.ReadValueNull(vr, args.valPos);
                return;

            case iRecordSep:
                args.AddValue(null);
                rv.ReadValueNull(vr, args.valPos);
                args.State = ReaderNewRecord.Singleton;
                return;

            case -1:
                args.AddValue(null);
                rv.ReadValueNull(vr, args.valPos);
                args.State = ReaderEnd.Singleton;
                return;

            default:
                ReadNumber(args, readChar);
                return;
            }

            // fixed width values (bool, datetime) or values with delimiter (string)
            // still have one extra character to read in order to determine next step
            readChar = args.ReadOne();
            if (readChar == iFieldSep)
            {
                args.State = ReaderField.Singleton;
            }
            else if (readChar == iRecordSep)
            {
                args.State = ReaderNewRecord.Singleton;
            }
            else if (readChar == -1)
            {
                args.State = ReaderEnd.Singleton;
            }
            else
            {
                throw Error.UnexpectedChars(Constants.FieldSeparator, (char)readChar);
            }
        }