plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Modify Start and End time Trending in Wicc

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> SIEMENS SIMATIC HMI- Reg. U
View previous topic :: View next topic  
Author Message
rvillanuevarios
Junior
Junior


Joined: 14 Jul 2013
Posts: 7

PostPosted: 01/10/2014 06:12    Post subject: Modify Start and End time Trending in Wicc Reply with quote

Hi i need to read from a DB (start and end time) and modify those parameters in a trending.

Any idea ? ,i really appreciate any help

Regards

Ricardo
Back to top
View user's profile Send private message
bilbo_321
Junior
Junior


Joined: 11 Jan 2013
Posts: 3

PostPosted: 01/10/2014 10:22    Post subject: Reply with quote

use TimeAxisIndex, TimeAxisBeginTime, TimeAxisEndTime and TimeAxisTimeRangeFactor properties of TrendControl.
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 03/10/2014 19:38    Post subject: Re: Modify Start and End time Trending in Wicc Reply with quote

rvillanuevarios wrote:
Hi i need to read from a DB (start and end time) and modify those parameters in a trending.

Any idea ? ,i really appreciate any help

Regards

Ricardo


You can use Epoch & Unix Timestamp Conversion Tools
http://www.epochconverter.com/
TimeAxisBeginTime and TimeAxisEndTime needs a value of Epoch Time ( time in number of seconds)

TimeAxisBeginTime= Epoch Time ( Current Date + fixed time ( 6:00 AM)
TimeAxisEndTime = Epoch Time( Current Date + fixed time ( 6:00 PM)

If you want different dates convert them and put in a DB and when you call object trend read from DB the Begin and the End and add to the property ..with bold letters...
Code:
'VBS363

Sub OnClick(ByVal Item)
Dim objFXControl
Dim objTrendWindow
Dim objTrend
Dim objXAxis
Dim objYAxis
Dim startID
Dim FXServerDataX(3)
Dim FXServerDataY(3)

' realizate reference to FXControl
Set objFXControl = ScreenItems("Control1")

' confecționate reference to new window, x and y axis
Set objTrendWindow = objFXControl.GetTrendWindowCollection.AddItem("myWindow")
Set objXAxis = objFXControl.GetXAxisCollection.AddItem("myXAxis")
Set objYAxis = objFXControl.GetYAxisCollection.AddItem("myYAxis")

' assign x and y axis to the window
objXAxis.TrendWindow = objTrendWindow.Name
objYAxis.TrendWindow = objTrendWindow.Name

' add new trend
Set objTrend = objFXControl.GetTrendCollection.AddItem("myTrend1")

' configure trend data connection (UserArchive)
objTrend.Provider = 3
startID = CLng(4)
FXServerDataX(0) = "Setpoint"
FXServerDataX(1) = "ParabelX"
FXServerDataX(3) = startID
FXServerDataY(0) = "Setpoint"
FXServerDataY(1) = "ParabelY"
FXServerDataY(3) = startID
objTrend.MeasurePoints = 50
objTrend.SetTagName "Setpoint\ParabelX", "Setpoint\ParabelY", FXServerDataX, FXServerDataY

' [b]assign trend properties
objTrend.Color = RGB(255,0,0)
objTrend.PointStyle = 1
objTrend.TrendWindow = objTrendWindow.Name
objTrend.XAxis = objXAxis.Name
objTrend.YAxis = objYAxis.Name[/b]
End Sub

and adapts this code to your needs...
Code:
'VBS303
Dim obj
Set obj = Parent.Parent.ScreenItems("Control1")
'choose time axis, stop update, set begin time and time range
obj.TimeAxisName = "Time axis 1"
obj.TimeAxisActualize = False
obj.TimeAxisBeginTime = CStr(Date & " 4:00:00")
obj.TimeAxisTimeRangeBase = 3600000
obj.TimeAxisTimeRangeFactor = 8
'close the selection window
Parent.Visible = False



Code:

'VBS304
Dim obj
Set obj = Parent.Parent.ScreenItems("Control1")
'choose time axis, stop update, set begin time and time range
obj.TimeAxisName = "Time axis 1"
obj.TimeAxisActualize = False
obj.TimeAxisBeginTime = CStr(Date & " 12:00:00 PM")
obj.TimeAxisTimeRangeBase = 3600000
obj.TimeAxisTimeRangeFactor = 8
'close the selection window
Parent.Visible = False
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 03/10/2014 19:45    Post subject: Re: Modify Start and End time Trending in Wicc Reply with quote

rvillanuevarios wrote:
Hi i need to read from a DB (start and end time) and modify those parameters in a trending.

Any idea ? ,i really appreciate any help

Regards

Ricardo


I found also this example code which you have to adapt as I said with time converted to double:
WinCC FunctionTrendControl with value supply via array (before WinCC V7)

In this example, a Function Trend Control called "Control1" is supplied with 100 value pairs. In order that the value pair can be transferred correctly, the transfer e.g. in "dblAxisXY" must not occur directly but via an intermediate tag, e.g. "varTemp".
Code:
'VBS152
Dim lngIndex
Dim dblXY(1)
Dim dblAxisXY(100)
Dim varTemp
Dim objTrendControl
Set objTrendControl = ScreenItems("Control1")
For lngIndex = 0 To 100
 dblXY(0) = CDbl(lngIndex * 0.8)
 dblXY(1) = CDbl(lngIndex)
 dblAxisXY(lngIndex) = dblXY
Next
varTemp = (dblAxisXY)
objTrendControl.DataXY = varTemp
objTrendControl.InsertData = True


Procedure, Example 1
Realizate the Access database with the WINCC_DATA table and columns (ID, TagValue) with the ID as the Auto Value.
Set up the ODBC data source with the name "SampleDSN", reference to the above Access database.
Programming.
Code:
'VBS108
Dim objConnection
Dim strConnectionString
Dim lngValue
Dim strSQL
Dim objCommand
strConnectionString = "Provider=MSDASQL;DSN=SampleDSN;UID=;PWD=;"
lngValue = HMIRuntime.Tags("Tag1").Read
strSQL = "INSERT INTO WINCC_DATA (TagValue) VALUES (" & lngValue & ");" 
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objCommand = CreateObject("ADODB.Command")
With objCommand
    .ActiveConnection = objConnection
    .CommandText = strSQL
End With
objCommand.Execute
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing


Procedure, Example 2

Create the WinCC tag with the name dbValue.
Lucrate Access database with WINCC_DATA table and ID, TagValue columns: ID, create TagValue (ID as auto value).
Set up the ODBC data source with the name "SampleDSN", reference to the above Access database.
Programming.

Code:
'VBS108a
Dim objConnection
Dim objCommand
Dim objRecordset
Dim strConnectionString
Dim strSQL
Dim lngValue
Dim lngCount
strConnectionString = "Provider=MSDASQL;DSN=SampleDSN;UID=;PWD=;"
strSQL = "select TagValue from WINCC_DATA where ID = 1"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnectionString
objConnection.Open
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strSQL
Set objRecordset = objCommand.Execute
lngCount = objRecordset.Fields.Count
If (lngCount>0) Then
objRecordset.movefirst
lngValue = objRecordset.Fields(0).Value
HMIRuntime.Tags("dbValue").Write lngValue
Else
HMIRuntime.Trace "Selection returned no fields" & vbNewLine
End If
Set objCommand = Nothing
objConnection.Close
Set objRecordset = Nothing
Set objConnection = Nothing
Back to top
View user's profile Send private message
maersk
Member 3
Member 3
maersk

Joined: 17 Aug 2014
Posts: 891

PostPosted: 03/10/2014 19:51    Post subject: Reply with quote

Inserting and configuring WinCC OnlineTrendControl

Create a new process picture in the Graphics Designer.
Insert a WinCC OnlineTrendControl into the process picture.
Select "Configuration dialog..." from the shortcut menu of the control.

The "Properties of WinCC OnlineTrendControl" dialog opens.
In the "Trends" area of the "Trends" tab delete the default trend window "Trend 1".
Click on "Accept" to save the changes.
Click "OK" to close the dialog box.
Select "Properties" from the shortcut menu of the control.

The "Object properties" dialog box opens.
Enter "Control1" as the object name for the control.
Close the "Object properties" dialog box.

Inserting and configuring a button

Insert a "Button" object into the process picture.
Enter "Paste elements" as text for the button.
Select "Properties" from the shortcut menu of the button.

The "Object properties" dialog box opens.
In the Object Properties of the button select the "Event" tab.
On the "Mouse-click" event configure the VB script "Create VBS action on "Mouse-click" event of button (VBS305)".
Close the "Object properties" dialog box.

Create VBS action on "Mouse-click" event of button (VBS305)

Code:
'VBS305
Dim objTrendControl
Dim objTrendWindow
Dim objTimeAxis
Dim objValueAxis
Dim objTrend
'create reference to TrendControl
Set objTrendControl = ScreenItems("Control1")
'create reference to new window, time and value axis
Set objTrendWindow = objTrendControl.GetTrendWindowCollection.AddItem("myWindow")
Set objTimeAxis = objTrendControl.GetTimeAxisCollection.AddItem("myTimeAxis")
Set objValueAxis = objTrendControl.GetValueAxisCollection.AddItem("myValueAxis")
'assign time and value axis to the window
objTimeAxis.TrendWindow = objTrendWindow.Name
objValueAxis.TrendWindow = objTrendWindow.Name
'add new trend and assign properties
Set objTrend = objTrendControl.GetTrendCollection.AddItem("myTrend1")
objTrend.Provider = 1
objTrend.TagName = "TestArchive\ArchivTag1"
objTrend.Color = RGB(255,0,0)
objTrend.TrendWindow = objTrendWindow.Name
objTrend.TimeAxis = objTimeAxis.Name
objTrend.ValueAxis = objValueAxis.Name
'add new trend and assign properties
Set objTrend = objTrendControl.GetTrendCollection.AddItem("myTrend2")
objTrend.Provider = 1
objTrend.TagName = "TestArchive\ArchivTag2"
objTrend.Color = RGB(0,255,0)
objTrend.TrendWindow = objTrendWindow.Name
objTrend.TimeAxis = objTimeAxis.Name
objTrend.ValueAxis = objValueAxis.Name
'add new trend and assign properties
Set objTrend = objTrendControl.GetTrendCollection.AddItem("myTrend3")
objTrend.Provider = 1
objTrend.TagName = "TestArchive\ArchivTag3"
objTrend.Color = RGB(0,0,255)
objTrend.TrendWindow = objTrendWindow.Name
objTrend.TimeAxis = objTimeAxis.Name
objTrend.ValueAxis = objValueAxis.Name
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> SIEMENS SIMATIC HMI- Reg. U All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro