Пример #1
0
    def LockTrace(self, TraceNumber, Lock):
        '''
        Lock or unlock a trace
        TraceNumber is an integer between 1 and 6
        Lock is a boolean:
            - True: the trace TraceNumber is locked
            - False: the trace TraceNumber is unlocked
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE, APXXXX_ERROR_ARGUMENT_VALUE, APXXXX_ERROR_BAD_FILENAME
        from Hardware.PyApex.Errors import ApexError

        if not isinstance(TraceNumber, int):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "TraceNumber")
            sys.exit()

        if not TraceNumber in self.__Validtracenumbers:
            raise ApexError(APXXXX_ERROR_ARGUMENT_VALUE, "TraceNumber")
            sys.exit()

        if Lock:
            Lock = True
        else:
            Lock = False

        if not self.__Simulation:
            if Lock:
                Command = "SPTRLOCK" + str(TraceNumber) + "\n"
            else:
                Command = "SPTRUNLOCK" + str(TraceNumber) + "\n"
            Send(self.__Connexion, Command)
Пример #2
0
 def DeactivateAutoNPoints(self):
     '''
     Deactivates the automatic number of points for measurements
     '''
     if not self.__Simulation:
         Command = "SPAUTONBPT0\n"
         Send(self.__Connexion, Command)
Пример #3
0
 def Stop(self):
     '''
     Stops a measurement
     '''
     if not self.__Simulation:
         Command = "SPSWP3\n"
         Send(self.__Connexion, Command)
Пример #4
0
 def DeleteAll(self):
     '''
     Clear all traces
     '''
     if not self.__Simulation:
         Command = "SPTRDELAL\n"
         Send(self.__Connexion, Command)
Пример #5
0
    def SetScaleYUnit(self, ScaleYUnit=0):
        '''
        Defines the unit of the Y-Axis
        ScaleXUnit can be a string or an integer
        If ScaleYUnit is :
            - "lin" or 0, Y-Axis unit is in mW (default)
            - "log" or 1, Y-Axis unit is in dBm or dBm
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE, APXXXX_ERROR_ARGUMENT_VALUE
        from Hardware.PyApex.Errors import ApexError

        if isinstance(ScaleYUnit, str):
            if ScaleYUnit.lower() == "log":
                ScaleYUnit = 1
            else:
                ScaleYUnit = 0

        if not isinstance(ScaleYUnit, int):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "ScaleYUnit")
            sys.exit()

        if not ScaleYUnit in self.__ValidScaleUnits:
            raise ApexError(APXXXX_ERROR_ARGUMENT_VALUE, "ScaleYUnit")
            sys.exit()

        if not self.__Simulation:
            Command = "SPLINSC" + str(ScaleYUnit) + "\n"
            Send(self.__Connexion, Command)

        self.__ScaleYUnit = ScaleYUnit
Пример #6
0
 def DeactivateAverageMode(self):
     '''
     Deactivates the average mode
     '''
     if not self.__Simulation:
         Command = "SPAVERAGE0\n"
         Send(self.__Connexion, Command)
Пример #7
0
 def WavelengthCalib(self):
     '''
     Performs a wavelength calibration.
     If a measurement is running, it is previously stopped
     '''
     if not self.__Simulation:
         Command = "SPWLCALM\n"
         Send(self.__Connexion, Command)
Пример #8
0
 def SetAutoPointNumberSelection(self, IsAuto=True):
     '''
     '''
     if not self.__Simulation:
         if IsAuto:
             Command = 'SPAUTONBPT1\n'
         else:
             Command = 'SPAUTONBPT0\n'
         Send(self.__Connexion, Command)
Пример #9
0
    def SetXResolution(self, Resolution):
        '''
        Set the wavelength measurement resolution
        Resolution is expressed in the value of 'ScaleXUnit'
        '''
        if not self.__Simulation:
            Command = "SPSWPRES" + str(Resolution) + "\n"
            Send(self.__Connexion, Command)

        self.__SweepResolution = Resolution
Пример #10
0
    def GetXResolution(self):
        '''
        Get the wavelength measurement resolution
        Resolution is expressed in the value of 'ScaleXUnit'
        '''

        if not self.__Simulation:
            Command = "SPSWPRES?\n"
            Send(self.__Connexion, Command)
            self.__SweepResolution = float(Receive(self.__Connexion)[:-1])
        return self.__SweepResolution
Пример #11
0
    def LineWidth(self, TraceNumber=1, Get="width"):
        '''
        Gets the 3-db line width of the selected trace
        TraceNumber is an integer between 1 (default) and 6
        ThresholdValue is a float expressed in dB
        Get is a string between the following values:
            - Get = "WIDTH" : only the line width is returned (default)
            - Get = "CENTER" : only the line width center is returned
            - Get = "LEVEL" : only the line width peak level is returned
            - Get = "ALL" : all line width values are returned in a list
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE, APXXXX_ERROR_ARGUMENT_VALUE
        from Hardware.PyApex.Errors import ApexError

        if not isinstance(TraceNumber, int):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "TraceNumber")
            sys.exit()

        if not TraceNumber in self.__Validtracenumbers:
            raise ApexError(APXXXX_ERROR_ARGUMENT_VALUE, "TraceNumber")
            sys.exit()

        if not self.__Simulation:
            Command = "SPLWTH" + str(TraceNumber) + "_3.0\n"
            Send(self.__Connexion, Command)
            Str = Receive(self.__Connexion, 64)[:-1]
            Values = []
            Str = Str.split("_")

            for s in Str:
                for v in s.split(" "):
                    if v.lower() not in ["dbm", "mw", "nm", "ghz"]:
                        try:
                            Values.append(float(v))
                        except:
                            pass
            while len(Values) < 3:
                Values.append(0.0)

        else:
            Values = [0.100, 1550.000, 2.25]

        if str(Get).lower() == "all":
            return Values

        elif str(Get).lower() == "center":
            return Values[1]

        elif str(Get).lower() == "level":
            return Values[2]

        else:
            return Values[0]
Пример #12
0
    def GetStartWavelength(self):
        '''
        Get the start wavelength of the measurement span
        Wavelength is expressed in nm
        '''

        if not self.__Simulation:
            Command = "SPSTRTWL?\n"
            Send(self.__Connexion, Command)
            self._StartWavelength = float(Receive(self.__Connexion)[:-1])

        return self._StartWavelength
Пример #13
0
    def GetYResolution(self):
        '''
        Get the Y-axis power per division value
        Resolution is expressed in the value of 'ScaleYUnit'
        '''

        if not self.__Simulation:
            Command = "SPDIVY?\n"
            Send(self.__Connexion, Command)
            Resolution = Receive(self.__Connexion)

        return float(Resolution[:-1])
Пример #14
0
    def GetID(self):
        '''
        Return string ID of AP2XXX equipment
        '''
        from Hardware.PyApex.Constantes import SimuAP2XXX_ID

        if self.__Simulation:
            return SimuAP2XXX_ID
        else:
            Send(self.Connexion, "*IDN?\n")
            ID = Receive(self.Connexion)
            return ID
Пример #15
0
    def GetCenter(self):
        '''
        Get the wavelength measurement center
        Center is expressed in nm
        '''

        if not self.__Simulation:
            Command = "SPCTRWL?\n"
            Send(self.__Connexion, Command)
            self._Center = float(Receive(self.__Connexion)[:-1])

        return self._Center
Пример #16
0
    def GetSpan(self):
        '''
        Get the wavelength measurement span
        Span is expressed in nm
        '''

        if not self.__Simulation:
            Command = "SPSPANWL?\n"
            Send(self.__Connexion, Command)
            self._Span = float(Receive(self.__Connexion)[:-1])

        return self._Span
Пример #17
0
    def GetNPoints(self):
        '''
        Get the number of points for the measurement
        '''

        if not self.__Simulation:

            Command = "SPNBPTSWP?\n"
            Send(self.__Connexion, Command)
            try:
                self.__NPoints = int(Receive(self.__Connexion)[:-1])
            except ValueError:  #this is
                self.Reconnect()
        return self.__NPoints
Пример #18
0
    def DisplayScreen(self, Display):
        '''
        Displays or not the "Remote" window on the AP2XXX equipment.
        Display is a boolean:
            - True: the window is displayed
            - False: the window is hidden
        '''

        if Display == False:
            Display = 0
        else:
            Display = 1

        if not self.__Simulation:
            Send(self.Connexion, "REMSCREEN" + str(Display) + "\n")
Пример #19
0
    def SetScrollMode(self, Enable):
        '''
        Enable or disable the screll mode
        Enable is a boolean:
            - True: the scroll mode is enabled
            - False: the scroll mode is disabled
        '''

        if Enable:
            Enable = 1
        else:
            Enable = 0

        if not self.__Simulation:
            Command = "SPTRSCROLL" + str(Enable) + "\n"
            Send(self.__Connexion, Command)
Пример #20
0
    def ListModes(self):
        '''
        Gets a list of all modes in the AP2XXX equipment.
        These modes are expressed as string. The index of the element in the list
        follows the list in the AP2XXX menu box
        '''

        if self.__Simulation:
            Modes = ["Apex Start", "General Settings", "Powermeter", "T.L.S", "O.S.A."]
        else:
            Send(self.Connexion, "LSMODES?\n")
            Modes = Receive(self.Connexion)[:-1]
            Modes = Modes.split(",")
            for i in range(len(Modes)):
                Modes[i] = Modes[i].strip()

        return Modes
Пример #21
0
    def ListBands(self):
        '''
        Gets a list of all optical bands in the AP2XXX equipment.
        The optical band choice is only available for AP2X8X
        '''

        if self.__Simulation:
            Bands = ["O", "C&L"]
        else:
            Send(self.Connexion, "LSBANDS?\n")
            Bands = Receive(self.Connexion)[:-1]
            Bands = Bands.split(",")
            for i in range(len(Bands)):
                Bands[i] = Bands[i].replace("&&", "&")
                Bands[i] = Bands[i].strip()

        return Bands
Пример #22
0
    def SetNPoints(self, NPoints):
        '''
        Set the number of points for the measurement
        '''

        if not isinstance(NPoints, int):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "NPoints")
            sys.exit()
        if NPoints < AP2XXX_MINNPTS or NPoints > AP2XXX_MAXNPTS:
            raise ApexError(APXXXX_ERROR_ARGUMENT_VALUE, "NPoints")
            sys.exit()

        if not self.__Simulation:
            Command = "SPNBPTSWP" + str(NPoints) + "\n"
            Send(self.__Connexion, Command)

        self.__NPoints = NPoints
Пример #23
0
    def SetNoiseMask(self, NoiseMaskValue):
        '''
        Set the noise mask of the signal (values under this mask are set to this value)
        Noise mask is expressed in the value of 'ScaleYUnit'
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE
        from Hardware.PyApex.Errors import ApexError

        if not isinstance(NoiseMaskValue, (float, int)):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "NoiseMaskValue")
            sys.exit()

        if not self.__Simulation:
            Command = "SPSWPMSK" + str(NoiseMaskValue) + "\n"
            Send(self.__Connexion, Command)

        self.__NoiseMaskValue = NoiseMaskValue
Пример #24
0
    def GetOpticalBand(self):
        '''
        Gets the actual optical band. The band can be:
            - O
            - C&L
        The optical band choice is only available for AP2X8X
        '''
        from random import randint

        if self.__Simulation:
            Bands = ["0", "C&L"]
            Band = Bands[randint(0, 1)]
        else:
            Send(self.Connexion, "CHBAND?\n")
            Band = Receive(self.Connexion)[:-1]
            Band = Band.replace("&&", "&")

        return Band
Пример #25
0
    def SetOpticalBand(self, Band):
        '''
        Sets the optical band. The band can be:
        The available bands can be listed by the 'ListBands' command
        The optical band choice is only available for AP2X8X
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE

        if not isinstance(Band, (str)):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "Band")

        ValidBands = self.ListBands()
        index = -1
        for vb in ValidBands:
            if Band.lower() == vb.lower():
                index = ValidBands.index(vb)

        if not self.__Simulation and index >= 0:
            Send(self.Connexion, "CHBAND" + str(index) + "\n")
Пример #26
0
    def SetCenter(self, Center):
        '''
        Set the wavelength measurement center
        Center is expressed in nm
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE, APXXXX_ERROR_ARGUMENT_VALUE
        from Hardware.PyApex.Errors import ApexError

        if not isinstance(Center, (float, int)):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "Center")
            sys.exit()

        if not self.__Simulation:
            Command = "SPCTRWL" + str(Center) + "\n"
            Send(self.__Connexion, Command)

        self._Center = Center
        self._StopWavelength = self._Center + (self._Span / 2)
        self._StartWavelength = self._Center - (self._Span / 2)
Пример #27
0
    def SetMode(self, Mode):
        '''
        Changes the screen mode of the AP2XXX equipment (Apex Start, O.S.A., Powermeter)
        Mode is an integer representing the index of the mode to display.
        By convention, the "APEX Start" mode is always 0 index. The index follows the
        list in the AP2XXX menu box.
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE

        TimeOut = self.Connexion.gettimeout()
        self.Connexion.settimeout(None)

        if not isinstance(Mode, (int)):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "Mode")

        if not self.__Simulation:
            Send(self.Connexion, "CHMOD" + str(Mode) + "\n")

        self.Connexion.settimeout(TimeOut)
Пример #28
0
    def SetYResolution(self, Resolution):
        '''
        Set the Y-axis power per division value
        Resolution is expressed in the value of 'ScaleYUnit'
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE, APXXXX_ERROR_ARGUMENT_VALUE
        from Hardware.PyApex.Constantes import AP2XXX_MINYRES, AP2XXX_MAXYRES
        from Hardware.PyApex.Errors import ApexError

        if not isinstance(Resolution, (float, int)):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "Resolution")
            sys.exit()
        if Resolution < AP2XXX_MINYRES or Resolution > AP2XXX_MAXYRES:
            raise ApexError(APXXXX_ERROR_ARGUMENT_VALUE, "Resolution")
            sys.exit()

        if not self.__Simulation:
            Command = "SPDIVY" + str(Resolution) + "\n"
            Send(self.__Connexion, Command)
Пример #29
0
    def SetSpan(self, Span):
        '''
        Set the wavelength measurement span
        Span is expressed in nm
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE, APXXXX_ERROR_ARGUMENT_VALUE
        from Hardware.PyApex.Errors import ApexError

        if not isinstance(Span, (float, int)):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "Span")
            sys.exit()

        if not self.__Simulation:
            Command = "SPSPANWL" + str(Span) + "\n"
            Send(self.__Connexion, Command)

        self._Span = Span
        self._StopWavelength = self._Center + (self._Span / 2)
        self._StartWavelength = self._Center - (self._Span / 2)
Пример #30
0
    def SetStartWavelength(self, Wavelength):
        '''
        Set the start wavelength of the measurement span
        Wavelength is expressed in nm
        '''
        from Hardware.PyApex.Constantes import APXXXX_ERROR_ARGUMENT_TYPE, APXXXX_ERROR_ARGUMENT_VALUE
        from Hardware.PyApex.Errors import ApexError

        if not isinstance(Wavelength, (float, int)):
            raise ApexError(APXXXX_ERROR_ARGUMENT_TYPE, "Wavelength")
            sys.exit()

        if not self.__Simulation:
            Command = "SPSTRTWL" + str(Wavelength) + "\n"
            Send(self.__Connexion, Command)

        self._StartWavelength = Wavelength
        self._Span = self._StopWavelength - self._StartWavelength
        self._Center = self._StartWavelength + (self._Span / 2)