problem in event handling on change of variable value.

S

sirjee

hello;

i m facing a problem in handling events on change of value of
environment variable in a tool CANoe.

class CANoeEvents:
def OnChange(self,value):
print "value of environment variable has changed"
def OnOpen(self,App):
print "opening Application"

App_Event = DispatchWithEvents('CANoe.Application',CANoeEvents)
time.sleep(2)
App_Event.Open("C:\projectConfig.cfg") # printd "opening Application"
and event handled properly.
........(now a code file runs in the canoe in which value of
environment variable called dummy is changed during execution. Just
like OnOpen; OnChange is defined in specification which should be
called on change of environment variable.But it is not happening.)
while (<some condition>):
myenvVar = App_Event.Environment.GetVariable("dummy")

The VB does it very easily and defines a subroutine called :
Sub myenvVar _OnChange(value)
print "value of environment variable has changed"
End Sub
//////////////////////////////////////////////////however the
alternative for subroutine for OnOpen in VB (defined below) works fine
as shown above in python.
Sub AppEvent_OnOpen(App)
print "opening Application"
End Sub

for VB; all this stuff is cake work.... object_eventname subroutine
and done.....what in python?
 
S

sirjee

hello;

i m facing a problem in handling events on change of value of
environment variable in a toolCANoe.

class CANoeEvents:
    def OnChange(self,value):
        print "value of environment variable has changed"
    def OnOpen(self,App):
        print "opening Application"

App_Event = DispatchWithEvents('CANoe.Application',CANoeEvents)
time.sleep(2)
App_Event.Open("C:\projectConfig.cfg")  # printd "opening Application"
and event handled properly.
.......(now a code file runs in thecanoein which value of
environment variable called dummy is changed during execution. Just
like OnOpen; OnChange is defined in specification which should be
called on change of environment variable.But it is not happening.)
while (<some condition>):
                myenvVar = App_Event.Environment.GetVariable("dummy")

The VB does it very easily and defines a subroutine called :
Sub myenvVar _OnChange(value)
   print "value of environment variable has changed"
End Sub
//////////////////////////////////////////////////however the
alternative for subroutine for OnOpen in VB (defined below) works fine
as shown above in python.
Sub AppEvent_OnOpen(App)
        print "opening Application"
End Sub

for VB; all this stuff is cake work.... object_eventname subroutine
and done.....what in python?

hi all;

strange !!!!
i got answer to the problem posted by me only.
now I have very good control of CANoe tool from python....
if anybody faces any problem wrt automation of CANoe tool using
python; do contact me.
here actual problem lied in analysing and implementing com heirarchy.
( which is really bit cumbersome)
onChange event is associated with App_Event.Environment.GetVariable
("dummy") object.
So we need to associate separate class with this object and then write
onChange function:


class evtClass:
def __init__(self):
print "initializing event class"
def OnChange(self,value):
print "value of environment variable changing"

print "changed value of environment variable is"
print value


see = App_Event.Environment.GetVariable("dummy")
see_temp=DispatchWithEvents(see,evtClass)

this will solve problem.
So we need to create separate classes for events associated with
separate objects.

regards
sirjee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top