Showing results 1 to 9 of 9

Thread: Create a function for a trend picture

  1. #1
    robertf Gast

    Default Create a function for a trend picture

    Here is a basic sample how to create a function for an extended trend picture...

    [highlight=vb]
    'Create Function for TREND - PICTURE
    Sub CreateTrendFunction()
    Dim zPIC As DynPicture
    Dim zFCT As RtFunction
    Dim i As Integer

    Set zPIC = MyWorkspace.ActiveDocument.DynPictures.Item("TREND")
    'Create new function
    Set zFCT = MyWorkspace.ActiveDocument.RtFunctions.Create("picTREND", tpPicture)
    'function settings...
    With zFCT
    .DynProperties("Picture") = zPIC.Name
    i = .DynProperties("PictFilter[-1]")
    If i = 0 Then .CreateDynProperty "PictFilter"
    .DynProperties("PictFilter[0].RefreshRate") = 1
    .DynProperties("PictFilter[0].Name") = "WIZARD TREND"
    .DynProperties("PictFilter[0].IsArchive") = False
    .DynProperties("PictFilter[0].IsXAxis") = False
    'Add 3 CURVES
    For i = 0 To 2
    n = .DynProperties("PictFilter[0].Curve[-1]")
    If n <= i Then
    'create CURVE SubItem if needed
    .CreateDynProperty ("PictFilter[0].Curve")
    .CreateDynProperty ("PictFilter[0].Curve[" & i & "].VarInfo")
    .CreateDynProperty ("PictFilter[0].Curve[" & i & "].YAxe")
    .CreateDynProperty ("PictFilter[0].Curve[" & i & "].YAxe[0].Scale")
    End If
    'change curve settings
    .DynProperties("PictFilter[0].Curve[" & i & "].GraphName") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].HasYAxis") = True
    .DynProperties("PictFilter[0].Curve[" & i & "].IsShow") = True
    .DynProperties("PictFilter[0].Curve[" & i & "].IsInterpolation") = True
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.VarName") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.Channel") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.Variable") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.VarMaxValue") = 1000
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.VarMinValue") = 0
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.IsAutoScale") = False
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.Color") = vbBlack
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.Scale.ScaleTop") = 1000
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.Scale.ScaleBotton") = 0
    Next i
    'filter settings (relative time 5 minutes)
    .CreateDynProperty ("PictFilter[0].TimeAxe")
    .DynProperties("PictFilter[0].TimeAxe.OldDiff") = 3600
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.Options") = 65535
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime1") = CDate(25569.0451388889) '("01.01.1970 01:05:00")
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime2") = CDate(25569.0416666667) '("01.01.1970 01:00:00")
    End With
    End Sub
    [highlight]

  2. #2
    tskotvig Gast

    Default Re: Create a function for a trend picture

    Hello,

    Zenon Vs. 6.22 SP1 Build 5
    I have a dynamic trend much like this one, but with a possibility of absolute time and relative.
    it works on my pc with no complaints (XP proffesional 32bit),
    But when installing it on a customers pc (same OS) (Status via remote transport: Compability guaranteed), the time settings from the ARV Function diagram settings is present no matter what in relative time....

    Any idea what this might be?

    Code:
    'Absolute time (works)
    If nRelTime = 0 Then
    dStart = CDate(dtSTART_DATE_TIME)
    dStop = CDate(dtEND_DATE_TIME)
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime1") = dStart '("01.01.1970 01:05:00")
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime2") = dStop '("01.01.1970 01:00:00")
    'Stop
    Else
    'relative time (does not work)
    If nRelTime = 1 Then
    dStop = CDate(DateSerial(1970, 1, 1) + TimeSerial(1, 0, 0))
    dStart = DateAdd("s", DateDiff("s", dtSTART_DATE_TIME, dtEND_DATE_TIME), dStop)
    Stop
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime1") = dStart
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime2") = dStop

    End If
    Last edited by tskotvig : 9th November 2010 at 15:33

  3. #3

    Default Re: Create a function for a trend picture

    maybe the other PC is using a different time zone? (GMT +2 or higher)

    There may be issues when using a constant datetime like "01.01.1970 01:05:00", when converting or working with the datetime type.

    The system may assume this is UTC, tries to convert it to local time (which could result in 31.12.1969 ... , when you are GMT+2 or higher) which is not valid.

  4. #4
    tskotvig Gast

    Default Re: Create a function for a trend picture

    Hello,

    Thanks for the quick reply.
    I am in South Korea right now and i do have set the korea timezone, and my PC is on gmt+1.
    I will to change the timezonetry as soon as i get to the factory today.

    Once again thank you very much!

  5. #5
    Join Date
    05.03.2010
    Posts
    3

    Default Re: Create a function for a trend picture

    Quote Originally Posted by robertf View Post
    Here is a basic sample how to create a function for an extended trend picture...

    [highlight=vb]
    'Create Function for TREND - PICTURE
    Sub CreateTrendFunction()
    Dim zPIC As DynPicture
    Dim zFCT As RtFunction
    Dim i As Integer

    Set zPIC = MyWorkspace.ActiveDocument.DynPictures.Item("TREND")
    'Create new function
    Set zFCT = MyWorkspace.ActiveDocument.RtFunctions.Create("picTREND", tpPicture)
    'function settings...
    With zFCT
    .DynProperties("Picture") = zPIC.Name
    i = .DynProperties("PictFilter[-1]")
    If i = 0 Then .CreateDynProperty "PictFilter"
    .DynProperties("PictFilter[0].RefreshRate") = 1
    .DynProperties("PictFilter[0].Name") = "WIZARD TREND"
    .DynProperties("PictFilter[0].IsArchive") = False
    .DynProperties("PictFilter[0].IsXAxis") = False
    'Add 3 CURVES
    For i = 0 To 2
    n = .DynProperties("PictFilter[0].Curve[-1]")
    If n <= i Then
    'create CURVE SubItem if needed
    .CreateDynProperty ("PictFilter[0].Curve")
    .CreateDynProperty ("PictFilter[0].Curve[" & i & "].VarInfo")
    .CreateDynProperty ("PictFilter[0].Curve[" & i & "].YAxe")
    .CreateDynProperty ("PictFilter[0].Curve[" & i & "].YAxe[0].Scale")
    End If
    'change curve settings
    .DynProperties("PictFilter[0].Curve[" & i & "].GraphName") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].HasYAxis") = True
    .DynProperties("PictFilter[0].Curve[" & i & "].IsShow") = True
    .DynProperties("PictFilter[0].Curve[" & i & "].IsInterpolation") = True
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.VarName") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.Channel") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.Variable") = "MyVariable_" & i
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.VarMaxValue") = 1000
    .DynProperties("PictFilter[0].Curve[" & i & "].VarInfo.VarMinValue") = 0
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.IsAutoScale") = False
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.Color") = vbBlack
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.Scale.ScaleTop") = 1000
    .DynProperties("PictFilter[0].Curve[" & i & "].YAxe.Scale.ScaleBotton") = 0
    Next i
    'filter settings (relative time 5 minutes)
    .CreateDynProperty ("PictFilter[0].TimeAxe")
    .DynProperties("PictFilter[0].TimeAxe.OldDiff") = 3600
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.Options") = 65535
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime1") = CDate(25569.0451388889) '("01.01.1970 01:05:00")
    .DynProperties("PictFilter[0].TimeAxe.TimeFilter.ARVTime2") = CDate(25569.0416666667) '("01.01.1970 01:00:00")
    End With
    End Sub
    [highlight]
    Sor but i couldnt understand what thıs gunctıon does and how i can use it. Can u explain it? thank you

  6. #6
    Join Date
    30.05.2007
    Location
    Salzburg
    Posts
    879

    Default Re: Create a function for a trend picture

    Here is a basic sample how to create a function for an extended trend picture...
    Of course this only works in the zenon editor (not in the runtime)
    -> a picture of the type "Extended Trend" with the name "TREND" has to be created before
    -> the variables MyVariable_1, MyVariable_2, MyVariable_3 have to be created before

    Regards,
    Herbert

  7. #7
    Join Date
    21.02.2018
    Posts
    3

    Default AW: Create a function for a trend picture

    Hallo zusammen,

    ich habe versucht den Code in VSTA umzusetzen.

    Leider funktioniert der VBA Code in VSTA nicht.

    .DynProperties("PictFilter[0].Curve[-1]")

    Wie kann ich die Anzahl der Kurve in VSTA ermitteln?

    Gre
    iconix

  8. #8
    Join Date
    31.03.2008
    Posts
    3

    Default Re: Create a function for a trend picture

    i have zenOn 7.60 and i also want to create a function to a extendet Trend Picture.

    I can create the function and die pictfilter

    but wenn i want to create a curve (.CreateDynProperty ("PictFilter[0].Curve")) i get the VBA error:

    Runtimeerror: 1005
    Given property doesnt' exist ... TREND_PIC::PictFilter[0].Curve

  9. #9
    Join Date
    03.11.2015
    Posts
    36

    Default Re: Create a function for a trend picture

    Quote Originally Posted by daniel.lackner View Post
    i have zenOn 7.60 and i also want to create a function to a extendet Trend Picture.



    I can create the function and die pictfilter



    but wenn i want to create a curve (.CreateDynProperty ("PictFilter[0].Curve")) i get the VBA error:



    Runtimeerror: 1005

    Given property doesnt' exist ... TREND_PIC::PictFilter[0].Curve

    Hi,
    Are you sure the PictFilter[0] has properties available and the object exists?


    BR,
    Joris

Similar Threads

  1. Display trend on Windows CE devices
    By sebastiank in forum zenon Operator
    Replies: 0
    Last Post: 27th August 2007, 08:57

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •