WinIdea/TestIdea, changing the value of a variable with a python script does not work

351 Views Asked by At

I don't know if you hear about isystems tools but I'm working with these, TestIdea/WinIdea. I wrote a scripts in Python, to change the value of a sensor ( 30 times ) and I need to monitor how it is his behavior. I put a test point, with the execution of my function on the line that I need. But the value of that variable still remain 0 if I only use the script but If I assign a value manually of that variable it's working. So I think the function and the line of his are good but I don't know what it's wrong. This is the code and is good because I have output:

def SawTooth(self):

    Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement = 0
    for i in range(31):
        if Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement < 4.5:
            Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement = Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement + 0.5
        else:
            Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement = 0.5


        print(i,Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement)

https://i.stack.imgur.com/sB45U.png

And if I put the same line in which to execute the test point and finish the test, it enters a fine loop and the program goes continuously without stopping.

I don't know If anybody can help me without the source code but I said to try my luck :)

1

There are 1 best solutions below

1
PG_root On

If I understand correctly, you would like to change the value of a variable that resides in your target application. These target variables can be accessed with an instance of isystem.connect class CTestCaseController. Use modify() to assign new values and evaluate() to read the current value of your variable.

Assuming that your target variable is named identical to the one in your script:

    def SawTooth(self):
    if self.testCtrl == None:
        self.testCtrl = ic.CTestCaseController(self.connectionMgr, self._isys_testCaseHandle)
        
    Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement = 0
    for i in range(31):
        if Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement < 4.5:
            Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement = Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement + 0.5
        else:
            Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement = 0.5
            
        self.testCtrl.modify('Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement', str(Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement))
        
        eval_value = self.testCtrl.evaluate("Rte_IoHwAb_IoHwAbSRSendSpoolSenseADCPort_IoHwAbDataElement,d")
        print(f"{i},{eval_value}")

I hope this will help you further. Best regards, Pim (iSystem Support)