Hi all
Not sure if this is the right forum, but I ask my question anyway. I would like to use IronPython for creating a hardware testing environment, consisting of a "Device Under Test" and some measurement equipment like a lab power supply and voltage meter and things like that. These instruments come with a library which enables communication via USB or GPIB. I have been using them in VBA for Excel, C# and VB.Net. Now when I try to do the same in IronPython, I do not seem to get it to work. I have copied the Interop assembly dll's from my example C# program into a separate directory, and then try to do the same steps as I do in the example. Here's the C# example : using System; using Agilent.AgilentU2741A.Interop; namespace Example1 { /// <summary> /// Agilent IVI-COM Driver Example Program /// /// Creates a driver object, reads a few Identity interface /// properties, and checks the instrument error queue. /// May include additional instrument specific functionality. /// /// Runs in simulation mode without an instrument. /// /// Requires a COM reference to the driver's type library. /// /// </summary> public class App { [STAThread] public static void Main(string[] args) { Agilent.AgilentU2741A.Interop.AgilentU2741A driver = null; try { // Create driver instance driver = new Agilent.AgilentU2741A.Interop.AgilentU2741AClass(); // Setup VISA resource descriptor. Ignored if Simulate=true string resourceDesc = "USB0::2391::18712::SN-4567890::0::INSTR"; // Setup IVI-defined initialization options string standardInitOptions = "QueryInstrStatus=true, Simulate=true"; // Setup driver-specific initialization options string driverSetupOptions = "DriverSetup= Model=, Trace=false"; driver.Initialize(resourceDesc, false, true, standardInitOptions + "," + driverSetupOptions); Console.WriteLine(" Driver Initialized"); // IIviDriverIdentity properties - Initialize required string instModel = driver.Identity.InstrumentModel; Console.WriteLine("InstrumentModel: {0}", instModel); string instFirmwareRevision = driver.Identity.InstrumentFirmwareRevision; Console.WriteLine("InstrumentFirmwareRevision: {0}", instFirmwareRevision); string instManufacturer = driver.Identity.InstrumentManufacturer; Console.WriteLine("InstrumentManufacturer: {0}\n", instManufacturer); // TODO: Exercise driver methods and properties // Check instrument for errors int errorNum = -1; string errorMsg = null; Console.WriteLine(""); while (errorNum != 0) { driver.Utility.ErrorQuery(ref errorNum, ref errorMsg); Console.WriteLine("ErrorQuery: {0}, {1}", errorNum, errorMsg); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (driver != null && driver.Initialized) { // Close driver driver.Close(); Console.WriteLine(" Driver Closed"); } } Console.WriteLine("\nDone - Press Enter to Exit"); Console.ReadLine(); } } } Here is what I try to do in Ironpython : >>> import sys >>> import clr >>> clr.AddReferenceToFile("Agilent.AgilentU2741A.Interop.dll") >>> from Agilent.AgilentU2741A.Interop import * >>> a = AgilentU2741AClass() >>> a <Agilent.AgilentU2741A.Interop.AgilentU2741AClass object at 0x000000000000002B> >>> dir(a) ['AC', 'ACCurrent', 'ACVoltage', 'Abort', 'ActualRange', 'Advanced', 'Alpha', 'A pertureTime', 'ApertureTimeUnits', 'AutoRange', 'AutoZero', 'Cache', 'Calibratio n', 'Clear', 'ClearInterchangeWarnings', 'Close', 'Code', 'Configure', 'Configur eBandwidth', 'ConfigureServiceRequest', 'ConfigureSynchronization', 'Continuity' , 'Count', 'CreateObjRef', 'DCCurrent', 'DCVoltage', 'Delay', 'Description', 'Di ode', 'DirectIO', 'Disable', 'DriverOperation', 'DriverSetup', 'Equals', 'ErrorQ uery', 'FResistance', 'Fetch', 'FetchMultiPoint', 'FixedRefJunction', 'Frequency ', 'FrequencyMax', 'FrequencyMin', 'Function', 'GeographicalAddress', 'GetHashCo de', 'GetLifetimeService', 'GetNextCoercionRecord', 'GetNextInterchangeWarning', 'GetType', 'GroupCapabilities', 'IAgilentU2741AACVoltage_AutoRange', 'IAgilentU 2741AACVoltage_Configure', 'IAgilentU2741AACVoltage_Measure', 'IAgilentU2741AACV oltage_Range', 'IAgilentU2741AContinuity_Configure', 'IAgilentU2741AContinuity_M easure', 'IAgilentU2741ADCCurrent_AutoRange', 'IAgilentU2741ADCCurrent_AutoZero' , 'IAgilentU2741ADCCurrent_Range', 'IAgilentU2741ADCVoltage_AutoRange', 'IAgilen tU2741ADCVoltage_AutoZero', 'IAgilentU2741ADCVoltage_Configure', 'IAgilentU2741A DCVoltage_Measure', 'IAgilentU2741ADCVoltage_NPLC', 'IAgilentU2741ADCVoltage_Ran ge', 'IAgilentU2741ADCVoltage_Resolution', 'IAgilentU2741ADiode_Configure', 'IAg ilentU2741ADiode_Measure', 'IAgilentU2741AFResistance_AutoRange', 'IAgilentU2741 AFResistance_AutoZero', 'IAgilentU2741AFResistance_Configure', 'IAgilentU2741AFR esistance_Measure', 'IAgilentU2741AFResistance_NPLC', 'IAgilentU2741AFResistance _Range', 'IAgilentU2741AFResistance_Resolution', 'IAgilentU2741AFrequency_Config ure', 'IAgilentU2741AFrequency_Measure', 'IAgilentU2741AResistance_AutoRange', ' IAgilentU2741AResistance_AutoZero', 'IAgilentU2741AResistance_Configure', 'IAgil entU2741AResistance_Measure', 'IAgilentU2741AResistance_NPLC', 'IAgilentU2741ARe sistance_Range', 'IAgilentU2741AResistance_Resolution', 'IIviComponentIdentity_D escription', 'IIviComponentIdentity_Revision', 'IIviComponentIdentity_Vendor', ' IIviDmmAdvanced_ActualRange', 'IIviDmmAdvanced_ApertureTime', 'IIviDmmAdvanced_A pertureTimeUnits', 'IIviDmmAdvanced_AutoZero', 'IIviDmmAdvanced_PowerlineFrequen cy', 'IIviDmmMeasurement_Abort', 'IIviDmmMeasurement_Fetch', 'IIviDmmMeasurement _Initiate', 'IIviDmmMeasurement_IsOverRange', 'IIviDmmMeasurement_Read', 'IIviDm mMeasurement_SendSoftwareTrigger', 'IIviDmmMultiPoint_Count', 'IIviDmmRTD_Config ure', 'IIviDmmRTD_Resistance', 'IIviDmmThermistor_Resistance', 'IIviDmmTrigger_S lope', 'IIviDmmTrigger_Source', 'IIviDmm_Advanced', 'IIviDmm_Close', 'IIviDmm_Dr iverOperation', 'IIviDmm_Frequency', 'IIviDmm_Function', 'IIviDmm_Identity', 'II viDmm_Initialize', 'IIviDmm_Initialized', 'IIviDmm_Measurement', 'IIviDmm_Range' , 'IIviDmm_Resolution', 'IIviDmm_Temperature', 'IIviDmm_Trigger', 'IIviDmm_Utili ty', 'IIviDriver_Close', 'IIviDriver_DriverOperation', 'IIviDriver_Identity', 'I IviDriver_Initialize', 'IIviDriver_Initialized', 'IIviDriver_Utility', 'Identifi er', 'Identity', 'Initialize', 'InitializeLifetimeService', 'Initialized', 'Init iate', 'InstrumentFirmwareRevision', 'InstrumentManufacturer', 'InstrumentModel' , 'InterchangeCheck', 'InvalidateAllAttributes', 'IoResourceDescriptor', 'IsOver Range', 'LockObject', 'LogicalName', 'Measure', 'Measurement', 'MeasurementCompl ete', 'MemberwiseClone', 'Message', 'MultiPoint', 'NPLC', 'PerformADCCalibration ', 'PerformCalibration', 'PowerlineFrequency', 'Preset', 'QueryInstrumentStatus' , 'RTD', 'Range', 'RangeCheck', 'Read', 'ReadMultiPoint', 'ReadingUnits', 'Recor dCoercions', 'RefJunctionType', 'ReferenceEquals', 'Register', 'Reset', 'ResetCa librationCode', 'ResetInterchangeCheck', 'ResetWithDefaults', 'Resistance', 'Res olution', 'Revision', 'SampleCount', 'SampleInterval', 'SampleTrigger', 'Securit yEnable', 'SecurityState', 'SelfTest', 'SendSoftwareTrigger', 'SerialNumber', 'S erialPoll', 'Simulate', 'Slope', 'Source', 'SpecificationMajorVersion', 'Specifi cationMinorVersion', 'Status', 'StoreCalibrationConstants', 'SupportedInstrument Models', 'SynchronizationBusLine', 'SynchronizationState', 'System', 'Temperatur e', 'Thermistor', 'Thermocouple', 'TimeoutMilliseconds', 'ToString', 'Transducer Type', 'Trigger', 'Type', 'UnitTemperature', 'UnlockObject', 'Utility', 'Value', 'Vendor', 'VoltageRange', 'WaitForOperationComplete', '__class__', '__delattr__ ', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__ ', '__reduce_ex__', '__repr__', '__setattr__', '__str__'] ' object has no attribute 'Load' >>> a.Initialized() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'GenericComObject' object has no attribute 'Initialized' >>> At this point I was expected to just get : FALSE. Also when I try to call the Initialize method (which seems to be imported correctly), I get the same error : unknown attribute. When I try to step through the available methods, I do not get any of the interesting ones, only the 'generic' ones. Also I have checked the Interop assembly using IL DASM, and there also I get the full list, so I think the interop assembly is ok. What do I do wrong? Is this because it is a COM object ? The IronPython tutorial is not very elaborate on what is actually happening during the exercice, so I am running a bit out of ideas here. Thanks wim
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com