commands.py 1.68 KB
Newer Older
Daniel Brown's avatar
Daniel Brown committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 28 11:58:09 2013

@author: Daniel
"""
import numpy
from numpy import min,max
import exceptions
from components import *
from structs import *

class Command:
    def getFinesseText(self):
        """ Base class for individual finesse optical components """    
        raise NotImplementedError("This function is not implemented")
        
class xaxis(Command):
    
    def __init__(self, kat, scale, limits, comp, param, steps):
        
        if scale != Scale.linear and scale != Scale.logarithmic:
            raise exceptions.ValueError("scale is not Scale.linear or Scale.logarithmic")            
            
        self.scale = scale
        
        if numpy.size(limits) != 2 :
            raise exceptions.ValueError("limits input should be a 2x1 vector of limits for the xaxis")
            
        self.limits = limits
        
        if steps <= 0 :
            raise exceptions.ValueError("steps value should be > 0")            
            
        self.steps = steps
        
        if not isinstance(comp, Component):
            raise exceptions.ValueError("comp is not a Component")
            
        self.__comp = comp
        
        if not isinstance(param, Param) :
            raise exceptions.ValueError("param argument is not of type Param")
                
        self._param = param
        
        kat.add(self)
        
    def getFinesseText(self):
        
        return 'xaxis {0} {1} {2} {3} {4} {5}'.format(
                self.__comp.name, self._param.name, self.scale,
                min(self.limits), max(self.limits), self.steps);