engycz / propc

OPC Server/Client Delphi library
50 stars 17 forks source link

How to add tag quality and timestamp #7

Closed baur closed 7 years ago

baur commented 7 years ago

Hi, @engycz Please, review my code at OPC306, I wonder, how to set tag quality and timestamp? By default tag_quality is OPC_QUALITY_GOOD and tag_timestamp is just current system time. But, I'd like to:

  1. set tag dateTime from DBF file dateTime field
  2. set tag quality as OPC_QUALITY_NOT_CONNECTED if DBF server is not pings
  3. set tag quality as OPC_QUALITY_BAD bad if difference of DBF dateTime and system dateTime 3 or 5 min
  4. and optimize code as
type
  TTag = class
    Value: variant;
    Quality: word;
    dateTime: TDateTime;
  end;
...
 Tag: TTag;the dictionary. }
  TagList := TDictionary<String, TTag>.Create;
  Tag := TTag.Create;
  { Add some key-value pairs to the dictionary. }
  Tag.Quality := OPC_QUALITY_BAD;
  Tag.Value := 0;
  Tag.dateTime := now();
  Dictionary.Add('FSO.Drum.Drum1.T_Burner', Tag);

but I can not init tags and so on ...

engycz commented 7 years ago

Use TOPCDataItem and TOPCDataItemServer classes

baur commented 7 years ago

Use TOPCDataItem and TOPCDataItemServer classes

I'm sorry, at my project OPC306 I'm using prDemo16 and there is a function GetItemValue and how to place SetItemQuality(ItemHandle, $08) here? and I have no idea how to organize it, pls, help

engycz commented 7 years ago

Set Quality variable in your function TOPC306.GetItemValue(ItemHandle: TItemHandle; var Quality: word)