15 CanEasy Automation COM
15 CanEasy Automation COM
Holger Dahinten
COM - Motivation
▪ OnStarting
function is called when the application is started.
▪ OnStopping
is called when application is stopped.
▪ OnSimulationStarted
is called when simulation was started.
▪ OnSimulationStopped
is called when simulation is stopped.
MultiStudio – Start mode
CanEasyApplication.StartSimulation
StopSimulation
End Sub
COM – Simulation
End Sub
COM – Database
End Sub
COM – Create a database
End Sub
COM – Iterate over database
▪ Use Children to
iterate recursive Private Sub PrintItem(oItem As IDatabaseItem, space As Long)
Dim output As String
–
Sub PrintDatabase()
Children PrintItem Database, 0
End Sub
– Parent
COM – IsValue functions
Sub Test_Example()
End Sub
COM – SetValue and GetValue
▪ Use functions to write/read database values
▪ See:
– SetValue
– GetValueString
– GetValue
Const Sig = "Sig:Signal"
Sub Test_Example()
End Sub
COM – Create sequences using Sleep
▪ Simple sequences can be created by using
CanEasyApplication.Sleep
▪ Displayed speed must always be lower than current speed
Sub TestValue(oSigCurSpd As Signal, oSigDispSpd As Signal, dVal As Double)
oSigCurSpd.ValuePhys = dVal
Sleep 500
If oSigDispSpd.ValuePhys > dVal Then _
MakeReport „Invalid DisplaySpeed detected", ReportTypeError
End Sub
Sub TestSequence_DisplaySpeed()
End Sub
COM – Transmit and Execute
Sub Test_Example()
End Sub
COM – Timer
▪ On signal value
Private WithEvents oSig As Signal
oSig.Send
End Sub
COM – Transmission events
▪ CanEasy supports events for transmitted and
received messages
▪ Transmission events are supported by database,
busses ECUs, messages and signals
▪ It provides various optional filters like message ID
ranges, channel and payload
▪ Events are queued and notified asynchrony
Private WithEvents oMsg As Message
While oIter.Next
Dim oMsgEntry As MsgRecordEntry
Set oMsgEntry = oIter.RecordEntry
Call MakeReport(oMsgEntry.Timestamp & vbTab & _
oMsg.Bus.Name & vbTab & _
"0x" & Hex(oMsg.Id) & vbTab & _
oMsg.DLC & vbTab, ReportTypeInformation)
Wend
End Sub
COM – Workspace module
1. Using the COM interface you can save user data into the CanEasy workspace (csm
file) by creating a global object of WorkspaceModule
2. If the user saves the workspace WorkspaceModule.OnSaveWorkspace will be called
3. Initialize WorkspaceModule.ModuleData with your user data
4. When a new workspace was loaded Simulation.OnWorkspaceLoaded is called
5. There you need to call WorkspaceModule .ReloadModuleData to get event for
6. WorkspaceModule .OnLoadWorkspace. As paramter you get your stored data
Private WithEvents oWorkspaceModule As WorkspaceModule 1.
Private Sub oWorkspaceModule_OnSaveWorkspace(ByVal success As CanEasy.BoolValue) 2.
oWorkspaceModule.ModuleData = Array("Some data", 11) 3.
success = True
End Sub
Sub Example_Integrate_CanEasy()
End Sub
COM – Remote control
End Sub
COM – Test Reports
▪ Use the
Sub TestReport()
reports
oTest.CloseGroup
oTest.CloseTestReport
End Sub
Thank you for your attention!