-
Notifications
You must be signed in to change notification settings - Fork 346
Index out of bounds. #1184
Comments
This is in iron Python. |
It would help if you had a minimal script that could reproduce it. Without that it's hard to track anything down. |
Well, I am new to github. I don't know how (yet) to attach a file so that people could view my code. Here is the bad file: # boilerplate to get access to the C# code
import clr
import time
import Debug_function
clr.AddReference("TestSequencer")
clr.AddReference("IronPython")
clr.AddReference("IronPython.Modules")
clr.AddReference("System.Windows.Forms")
from System import NullReferenceException
from System import Array
from thread import start_new_thread
from System.Windows.Forms import *
from System.Windows.Forms import Application, Button, Form
from TestSequencer.TestInterfaces import SLEValvePackTestInterface
vp = SLEValvePackTestInterface()
check_tester_is_busy = Debug_function.check_tester_busy
check_tester_is_ready = Debug_function.check_tester_ready
tell_tester_next_test = Debug_function.tell_tester_next_test
tell_test_your_testing = Debug_function.tell_test_your_testing
delay = Debug_function.delay
t_delay = Debug_function.t_delay
try:
#------------------------------------------------------------------------------------------------------------------------------
#---------------------------- Initial Setup ----------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------
vp = SLEValvePackTestInterface()
vp.Connect('172.16.201.201')
#--- Check to see if we can even communicate. ---------------------------------------------
print "Communications test"
try:
for num in range(100):
vp.ReadReg(0xF100)
delay(1)
except NullReferenceException:
print "Failed the comms test at the water detect test"
TestResults.Add("FAILED Communications test at water detect test", 1, "[X]<0")
print "Passed the comms test"
TestResults.Add("PASSED Communications test at water detect test", 1, "[X]>0")
start_new_thread(t_delay,()) # t_delay will run in the background, keeping the watchdog timer from resetting in the UUT.
# during periods of delay.
#---------------------------------------- Ask User if the power supply is already set up for external control. -------------------------------------
Power_supply_set = 0
yesNo = OperatorIO.GetYesNo("Power Supply Config", "Is the power supply configured for external operation")
if(yesNo):
Power_supply_set = 1
else:
Power_supply_set = 0
#*************************************** Power supply Set up starts here *********************************************
if(Power_supply_set < 1):
#Power Supply PREPARATION
print("Test External Control")
OperatorIO.ShowMessage("Power External Control", "Turn on the main power supply first.")
OperatorIO.ShowMessage("Power External Control", "On the main power supply, Press the 'Shift' button.")
OperatorIO.ShowMessage("Power External Control", "Then press the 'Menu' button.")
OperatorIO.ShowMessage("Power External Control", "Use the arrow key to select 'Config'. Then press 'OK'")
OperatorIO.ShowMessage("Power External Control", "Use the arrow button to select 'EXT-Ctrl'. Then press 'OK'.")
OperatorIO.ShowMessage("Power External Control", "Verify the following:")
OperatorIO.ShowMessage("Power External Control", " First parameter, '5v-M' is selected")
OperatorIO.ShowMessage("Power External Control", "Second parameter, '10v/10K-P' is selected.")
OperatorIO.ShowMessage("Power External Control", "Third parameter, 'V-P' is selected.")
OperatorIO.ShowMessage("Power External Control", "Fourth parameter, 'On' is selected.")
OperatorIO.ShowMessage("Power External Control", "When the parameters have been properly altered, press the 'Enter' key.")
OperatorIO.ShowMessage("Power External Control", "Press the 'Esc' button twice to get back to the main menu.")
OperatorIO.ShowMessage("Power External Control", "Plug in tester.")
OperatorIO.ShowMessage("Power External Control", "Set tester to troubleshoot.")
OperatorIO.ShowMessage("Power External Control", "Turn on the tester.")
try:
#-------------------- Tester Setup ---------------------------------------------------------------------------------------
print("Power On")
OperatorIO.ShowMessage("Test Preparation", "View the display on the of the tester.")
OperatorIO.ShowMessage("Test Preparation", "Use the tester dial and select 'Other'.")
OperatorIO.ShowMessage("Test Preparation", "Install UUT when asked to by the tester.")
OperatorIO.ShowMessage("Test Preparation", "Wait for the power LED to come on.")
OperatorIO.ShowMessage("Test Preparation", "Is the Error LED off?")
OperatorIO.ShowMessage("Test Preparation", "Does the tester say 'Finished'?")
#---------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------ Water detect Testing -----------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------------------
yesNo = 1
while(yesNo == 1):
vp.WriteReg(0x3003,0)
delay(20)
print("Starting water detect test")
print("Water Detect 0 Average", vp.ReadReg(0x3000))
print("Water Detect 0 Minimum", vp.ReadReg(0x3002))
print("Water Detect 0 Maximum", vp.ReadReg(0x3001))
print("Water Detect 0 Status = 0?", vp.ReadReg(0x3003))
OperatorIO.ShowMessage("WaterDetect: Depress button", "Press and hold Water Detect Button")
delay(10)
print("Water Detect 0 Status = 3?", vp.ReadReg(0x3003))
print("Water Detect 0 Average", vp.ReadReg(0x3000))
print("Water Detect 0 Minimum", vp.ReadReg(0x3002))
print("Water Detect 0 Maximum", vp.ReadReg(0x3001))
OperatorIO.ShowMessage("WaterDetect: Release button", "Release Water Detect Button")
print("Water Detect 0 Status = 2?", vp.ReadReg(0x3003))
yesNo = OperatorIO.GetYesNo("Test Water control", "Test again?")
#-----------------------------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------- Clean Up & End of story --------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------------------------
finally:
print "done"
finally:
# Cleanup code goes here... turn off power, disable valves, etc.
# This will be executed if there is an error or you Abort the script.
try:
#vp.WriteReg(0x1000, 0)
print("Done")
except NullReferenceException:
print "End of test Clean up"
#TestResults.Add("End of test.", 1, "[X]<0")
print "done" ********************************************************************************************************************Here is the good file: # boilerplate to get access to the C# code
import clr
import time
import Debug_function
clr.AddReference("TestSequencer")
clr.AddReference("IronPython")
clr.AddReference("IronPython.Modules")
clr.AddReference("System.Windows.Forms")
from System import NullReferenceException
from System import Array
from thread import start_new_thread
from System.Windows.Forms import *
from System.Windows.Forms import Application, Button, Form
from TestSequencer.TestInterfaces import SLEValvePackTestInterface
vp = SLEValvePackTestInterface()
check_tester_is_busy = Debug_function.check_tester_busy
check_tester_is_ready = Debug_function.check_tester_ready
tell_tester_next_test = Debug_function.tell_tester_next_test
tell_test_your_testing = Debug_function.tell_test_your_testing
delay = Debug_function.delay
t_delay = Debug_function.t_delay
try:
#------------------------------------------------------------------------------------------------------------------------------
#---------------------------- Initial Setup ----------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------
vp = SLEValvePackTestInterface()
vp.Connect('172.16.201.201')
#--- Check to see if we can even communicate. ---------------------------------------------
print "Communications test"
try:
for num in range(100):
vp.ReadReg(0xF100)
delay(1)
except NullReferenceException:
print "Failed the comms test at the water detect test"
TestResults.Add("FAILED Communications test at water detect test", 1, "[X]<0")
print "Passed the comms test"
TestResults.Add("PASSED Communications test at water detect test", 1, "[X]>0")
start_new_thread(t_delay,()) # t_delay will run in the background, keeping the watchdog timer from resetting in the UUT.
# during periods of delay.
#---------------------------------------- Ask User if the power supply is already set up for external control. -------------------------------------
Power_supply_set = 0
yesNo = OperatorIO.GetYesNo("Power Supply Config", "Is the power supply configured for external operation")
if(yesNo):
Power_supply_set = 1
else:
Power_supply_set = 0
#*************************************** Power supply Set up starts here *********************************************
if(Power_supply_set < 1):
#Power Supply PREPARATION
print("Test External Control")
OperatorIO.ShowMessage("Power External Control", "Turn on the main power supply first.")
OperatorIO.ShowMessage("Power External Control", "On the main power supply, Press the 'Shift' button.")
OperatorIO.ShowMessage("Power External Control", "Then press the 'Menu' button.")
OperatorIO.ShowMessage("Power External Control", "Use the arrow key to select 'Config'. Then press 'OK'")
OperatorIO.ShowMessage("Power External Control", "Use the arrow button to select 'EXT-Ctrl'. Then press 'OK'.")
OperatorIO.ShowMessage("Power External Control", "Verify the following:")
OperatorIO.ShowMessage("Power External Control", " First parameter, '5v-M' is selected")
OperatorIO.ShowMessage("Power External Control", "Second parameter, '10v/10K-P' is selected.")
OperatorIO.ShowMessage("Power External Control", "Third parameter, 'V-P' is selected.")
OperatorIO.ShowMessage("Power External Control", "Fourth parameter, 'On' is selected.")
OperatorIO.ShowMessage("Power External Control", "When the parameters have been properly altered, press the 'Enter' key.")
OperatorIO.ShowMessage("Power External Control", "Press the 'Esc' button twice to get back to the main menu.")
OperatorIO.ShowMessage("Power External Control", "Plug in tester.")
OperatorIO.ShowMessage("Power External Control", "Set tester to troubleshoot.")
OperatorIO.ShowMessage("Power External Control", "Turn on the tester.")
try:
#-------------------- Tester Setup ---------------------------------------------------------------------------------------
print("Power On")
OperatorIO.ShowMessage("Test Preparation", "View the display on the of the tester.")
OperatorIO.ShowMessage("Test Preparation", "Use the tester dial and select 'Other'.")
OperatorIO.ShowMessage("Test Preparation", "Install UUT when asked to by the tester.")
OperatorIO.ShowMessage("Test Preparation", "Wait for the power LED to come on.")
OperatorIO.ShowMessage("Test Preparation", "Is the Error LED off?")
OperatorIO.ShowMessage("Test Preparation", "Does the tester say 'Finished'?")
#---------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------ Water detect Testing -----------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------------------
yesNo = 1
while(yesNo == 1):
vp.WriteReg(0x3003,0)
delay(20)
print("Starting water detect test")
print("Water Detect 0 Average", vp.ReadReg(0x3000))
print("Water Detect 0 Minimum", vp.ReadReg(0x3002))
print("Water Detect 0 Maximum", vp.ReadReg(0x3001))
print("Water Detect 0 Status = 0?", vp.ReadReg(0x3003))
OperatorIO.ShowMessage("WaterDetect: Depress button", "Press and hold Water Detect Button")
delay(10)
print("Water Detect 0 Status = 3?", vp.ReadReg(0x3003))
print("Water Detect 0 Average", vp.ReadReg(0x3000))
print("Water Detect 0 Minimum", vp.ReadReg(0x3002))
print("Water Detect 0 Maximum", vp.ReadReg(0x3001))
OperatorIO.ShowMessage("WaterDetect: Release button", "Release Water Detect Button")
print("Water Detect 0 Status = 2?", vp.ReadReg(0x3003))
yesNo = OperatorIO.GetYesNo("Test Water control", "Test again?")
#-----------------------------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------- Clean Up & End of story --------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------------------------
finally:
print "done"
finally:
# Cleanup code goes here... turn off power, disable valves, etc.
# This will be executed if there is an error or you Abort the script.
try:
#vp.WriteReg(0x1000, 0)
print("Done")
except NullReferenceException:
print "End of test Clean up"
#TestResults.Add("End of test.", 1, "[X]<0")
print "done"
#
#class UUT_shut_down_error(Exception):
# """UUT would not shut down
# msg -- UUT would not shut down
# def _init_(self,msg);
# self.msg = msg
# """
#
#
#try:
#
##------------------------------------------ Ask User if the power supply is already set up for external control. -------------------------------------
# Power_supply_set = 0
#
# yesNo = OperatorIO.GetYesNo("Power Supply Config", "Is the power supply configured for external operation")
#
# if(yesNo):
# Power_supply_set = 1
# else:
# Power_supply_set = 0
#
#
#
## **************************************** Power supply Set up starts here *********************************************
#
# if(Power_supply_set < 1):
#
# #Power Supply PREPARATION
# print("Test External Control")
# OperatorIO.ShowMessage("Power External Control", "Turn on the main power supply first.")
# OperatorIO.ShowMessage("Power External Control", "On the main power supply, Press the 'Shift' button.")
# OperatorIO.ShowMessage("Power External Control", "Then press the 'Menu' button.")
# OperatorIO.ShowMessage("Power External Control", "Use the arrow key to select 'Config'. Then press 'OK'")
# OperatorIO.ShowMessage("Power External Control", "Use the arrow button to select 'EXT-Ctrl'. Then press 'OK'.")
# OperatorIO.ShowMessage("Power External Control", "Verify the following:")
# OperatorIO.ShowMessage("Power External Control", " First parameter, '5v-M' is selected")
# OperatorIO.ShowMessage("Power External Control", "Second parameter, '10v/10K-P' is selected.")
# OperatorIO.ShowMessage("Power External Control", "Third parameter, 'V-P' is selected.")
# OperatorIO.ShowMessage("Power External Control", "Fourth parameter, 'On' is selected.")
# OperatorIO.ShowMessage("Power External Control", "When the parameters have been properly altered, press the 'Enter' key.")
# OperatorIO.ShowMessage("Power External Control", "Press the 'Esc' button twice to get back to the main menu.")
# OperatorIO.ShowMessage("Power External Control", "Plug in tester.")
# OperatorIO.ShowMessage("Power External Control", "Turn on the tester.")
#
#
#
#
# #------------------------------------------------------------------------------------------------------------------------------
# #---------------------------- Initial Setup ----------------------------------------------------------------------------------
# #------------------------------------------------------------------------------------------------------------------------------
# |
The common way is to create a gist and link to that from the issue. (I tidied up your formatting anyway.) |
Is it only your script that causes issues? I won't be able to run it without the TestSequencer and other things. Can you reproduce it without reference to anything but IronPython and the .NET framework? |
You could also run with -X:ExceptionDetail which would output the full .NET stack trace of where the exception is coming from. |
I can zip it up and put it in a drop box or something. I'll try and create a "gist" and see how that works out. |
Jeff, I have put the files in a drop box and sent you a link. Yes this issue is only with the script. Glenn Varnon [Twitter]http://twitter.com/FMC_Tech [Facebook] https://www.facebook.com/FMCTI [YouTube] http://www.youtube.com/fmctechnologies [LinkedIn] http://www.linkedin.com/company/fmc-technologies [RightNow] http://www.careers.fmctechnologies.com/ From: Jeff Hardy [mailto:[email protected]] Is it only your script that causes issues? I won't be able to run it without the TestSequencer and other things. Can you reproduce it without reference to anything but IronPython and the .NET framework? — |
Please create a gist with the scripts to reproduce this issue and paste the links here. |
I keep getting this script runtime error that says: Index Error: Index was outside the bounds of the array. I have had some success at fixing it, but do not understand why the thing I do works.
Basically, I take a copy of working code and copy it to the dysfunctional code. I them comment all the functional code out using the "#" symbol. Usually when I do this, it will work. I then delete the commented code out until it becomes dysfunctional. I then add that commented code back in and verify it works.
Usually, I only get three or four extra lines of the commented code back into the original dysfunctional code (that is now functional). So what I do is retype the commented area to fit my design.
It is like Python need to have that space taken up by something. Usually before I do all this, I check all my tabbing first and get rid of all the extra spacing on each line. Sometimes that helps if I have some weird spacing issue.
The text was updated successfully, but these errors were encountered: