Commit 4a40809c authored by Noto Operator's avatar Noto Operator
Browse files

No commit message

No commit message
parent 20ccac22
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@
	xmlns:baci="urn:schemas-cosylab-com:BACI:1.0"
	xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	maxAzimuth="439.3"
	minAzimuth="-97.7"
	maxAzimuth="457.7"
	minAzimuth="-70.7"
	maxElevation="90.0"
	minElevation="5.0"
	diameter="32.0"
+8 −8
Original line number Diff line number Diff line
@@ -10,15 +10,15 @@
<Receiver>
	<receiverCode>SEC</receiverCode>
        <phi>90.0</phi>
        <coefficientNum00> 1 </coefficientNum00> <coefficientVal00> 0.0049250331 </coefficientVal00>
        <coefficientNum00> 1 </coefficientNum00> <coefficientVal00> 0.0219204295 </coefficientVal00>
        <coefficientNum01> 0 </coefficientNum01> <coefficientVal01> 0 </coefficientVal01>
        <coefficientNum02> 1 </coefficientNum02> <coefficientVal02> -0.0139756389 </coefficientVal02>
        <coefficientNum03> 1 </coefficientNum03> <coefficientVal03> 0.0083448673 </coefficientVal03>
        <coefficientNum04> 1 </coefficientNum04> <coefficientVal04> -0.0047017052 </coefficientVal04>
        <coefficientNum05> 1 </coefficientNum05> <coefficientVal05> 0.0030396502 </coefficientVal05>
        <coefficientNum06> 1 </coefficientNum06> <coefficientVal06> -0.0707245991 </coefficientVal06>
        <coefficientNum07> 1 </coefficientNum07> <coefficientVal07> 0.0138153592 </coefficientVal07>
        <coefficientNum08> 0 </coefficientNum08> <coefficientVal08> 0 </coefficientVal08>
        <coefficientNum02> 1 </coefficientNum02> <coefficientVal02> -0.0001390366 </coefficientVal02>
        <coefficientNum03> 1 </coefficientNum03> <coefficientVal03> 0.0267782640 </coefficientVal03>
        <coefficientNum04> 1 </coefficientNum04> <coefficientVal04> -0.0027674760 </coefficientVal04>
        <coefficientNum05> 1 </coefficientNum05> <coefficientVal05> 0.0045442590 </coefficientVal05>
        <coefficientNum06> 1 </coefficientNum06> <coefficientVal06> -0.1957215369 </coefficientVal06>
        <coefficientNum07> 1 </coefficientNum07> <coefficientVal07> 0.1461050361 </coefficientVal07>
        <coefficientNum08> 1 </coefficientNum08> <coefficientVal08> 0.0735574737 </coefficientVal08>
        <coefficientNum09> 0 </coefficientNum09> <coefficientVal09> 0 </coefficientVal09>
        <coefficientNum10> 0 </coefficientNum10> <coefficientVal10> 0 </coefficientVal10>
        <coefficientNum11> 0 </coefficientNum11> <coefficientVal11> 0 </coefficientVal11>
+6 −6
Original line number Diff line number Diff line
@@ -123,27 +123,27 @@ def main():
		maxX=85
		minX=-85

		polY[0]=8.3689e-4
		polY[1]=0.152495
		polY[2]=-11.7
		polY[0]=0.0069654
		polY[1]=-0.3007735
		polY[2]=-10.6464206
		maxY=85
		minY=-85

		polZ1[0]=0.00168640  
		polZ1[1]=-0.271430
		polZ1[2]=17.3
		polZ1[2]=7.3
		maxZ1=85
		minZ1=-85

		polZ2[0]=0.00168640
		polZ2[1]=-0.271430
		polZ2[2]=9.8
		polZ2[2]=-0.2
		maxZ2=85
		minZ2=-85

		polZ3[0]=0.00168640
		polZ3[1]=-0.271430
		polZ3[2]=12.6
		polZ3[2]=2.6
		maxZ3=85
		minZ3=-85

+113 −58
Original line number Diff line number Diff line
@@ -32,36 +32,15 @@ __copyright__ = "Andrea Orlati <a.orlati@ira.inaf.it>"


class MinorServoImpl(POA, charcomponent, services, lcycle):
	"""

	commands = {
   	# command_name: (method_name, (type_of_arg1, ..., type_of_argN))
        'derotatorSetup': ('setup', (str,)), 
        'derotatorGetActualSetup': ('getActualSetup', ()),
        'derotatorIsReady': ('isReady', ()), 
        'derotatorSetConfiguration': ('setConfiguration', (str,)),
        'derotatorGetConfiguration': ('getConfiguration', ()), 
        'derotatorPark': ('park', ()),
        'derotatorSetOffset': ('setOffset', (float,)),
        'derotatorGetOffset': ('getOffset', ()),
        'derotatorClearOffset': ('clearOffset', ()),
        'derotatorSetRewindingMode': ('setRewindingMode', (str,)),
        'derotatorGetRewindingMode': ('getRewindingMode', ()),
        'derotatorSetAutoRewindingSteps': ('setAutoRewindingSteps', (int,)),
        'derotatorGetAutoRewindingSteps': ('getAutoRewindingSteps', ()),
        'derotatorClearAutoRewindingSteps': ('clearAutoRewindingSteps', ()),
        'derotatorIsUpdating': ('isUpdating', ()),
        'derotatorIsRewinding': ('isRewinding', ()), 
        'derotatorIsRewindingRequired': ('isRewindingRequired', ()), 
        'derotatorRewind': ('rewind', (int,)),
        'derotatorSetPosition': ('_setPositionCmd', (str,)),
        'derotatorGetPosition': ('_getPositionCmd', ()), 
        'derotatorGetCmdPosition': ('_getCmdPositionCmd', ()), 
        'derotatorGetRewindingStep': ('_getRewindingStepCmd', ()),
        'derotatorGetScanInfo': ('_getScanInfoCmd', ()),
        'derotatorGetMaxLimit': ('_getMaxLimitCmd', ()),
        'derotatorGetMinLimit': ('_getMinLimitCmd', ()),
    }
	"""
        'servoSetup': ('setup', (str,)),  
        'setServoElevationTracking': ('setElevationTracking', (str,)),
	'setServoASConfiguration': ('setASConfiguration', (str,)),
        'servoPark': ('park', ()),
        'setServoOffset': ('setUserOffset', (str,float,)),
        'clearServoOffsets': ('clearUserOffset', (str,)),}

	def __init__(self):
		charcomponent.__init__(self)
@@ -132,9 +111,9 @@ class MinorServoImpl(POA, charcomponent, services, lcycle):
	def setElevationTracking(self,value):
		cmd=value.upper()
		if cmd=="ON":
			pass
			self.minorServo.trackingEnabled=True
		elif cmd=="OFF":
			pass
			self.minorServo.trackingEnabled=False
		else:
			exc=MinorServoErrors.ConfigurationError()
			raise exc.getMinorServoErrorsEx()
@@ -145,20 +124,19 @@ class MinorServoImpl(POA, charcomponent, services, lcycle):
	def setASConfiguration(self,value):
		pass


	"""
	Should the minor servo position change with the antenna elevation?
	:return true if the elevation tracking is enabled
	"""
	def isElevationTrackingEn(self):
		pass
		return self.trackingEnabled
	
	"""
	Is the minor servo position following the antenna elevation?
	:return true if the minor servo position is following the antenna elevation
	"""
	def isElevationTracking():
		pass
		return self.minorServo.trackingEnabled
	
	"""
	Is the system on focus?
@@ -249,8 +227,9 @@ class MinorServoImpl(POA, charcomponent, services, lcycle):
	:raises (MinorServoErrors::MinorServoErrorsEx,ComponentErrors::ComponentErrorsEx);
 	"""
	def startScan(self,starting_time,scan,antennaInfo):
		#TO be implemented
		pass
		#nothing to do here, scans are not supported....
		if not starting_time==0:
			starting_time=getTimeStamp().value

	"""
	Closes the current scan and force the minor servo system to its normal behaviour
@@ -258,8 +237,8 @@ class MinorServoImpl(POA, charcomponent, services, lcycle):
	:raises (ComponentErrors::ComponentErrorsEx, ReceiversErrors::ReceiversErrorsEx)
	"""
	def closeScan(timeToStop):
		#To be implemented
		pass
		#nothing to do here, scans are not supported....
		timeToStop=0

	"""
	Check if it is possible to execute a scan along a given axis
@@ -270,8 +249,11 @@ class MinorServoImpl(POA, charcomponent, services, lcycle):
	:raises ((MinorServoErrors::MinorServoErrorsEx,ComponentErrors::ComponentErrorsEx)
	"""
	def checkScan(self,starting_time,scan,antennaInfo,runtime):
		#to be implemented
		return False
		#scan not supported, we just fill in some salinet parameters required by the scheduler
		runtime.startEpoch=0
		runtime.onTheFly=False
		runtime.scanAxis=""
		return True

	"""
	Clear the user offset of a servo (or all servos)
@@ -347,8 +329,8 @@ class MinorServoImpl(POA, charcomponent, services, lcycle):
	Return the code of the axis involved in the scan (string)
	"""
	def getScanAxis(self):
		#to be implemented
		pass
		#scan not supported yet so return empty string
		return ""
 
	"""
	Return the positions of the active axes (ACS::doubleSeq)
@@ -1002,6 +984,79 @@ class MinorServoImpl(POA, charcomponent, services, lcycle):
        logger.logInfo('command %s executed' %cmd)
        return (success, answer)
"""

	"""
        This method returns a tuple (success, answer), where success is a boolean
        that indicates the command is executed correctly (success = True) or not
        (success = False). The argument answer is a string that represents the
        error message in case of error, the value returned from the method in
        case it returns a non Null object, an empty string in case it returns None.
	"""
	def command(self, cmd):
        
	        try:
			command, args_str = cmd.split('=') if '=' in cmd else (cmd, '')
            		command = command.strip()
            		args = [item.strip() for item in args_str.split(',')]
        	except ValueError:
            		success = False 
            		answer = 'Error - invalid command: maybe there are too many symbols of ='
	        except Exception, ex:
            		success = False 
            		answer = ex.message
        	else:
            		success = True

        	if not success:
			logger.logError(answer)
			return (success, answer)
		if command not in MinorServoImpl.commands:
			success = False
            		answer = 'Error - command %s does not exist' %command
            		ger.logError(answer)
            		return (success, answer)
        	else:
            		method_name, types = MinorServoImpl.commands[command]
            		# If we expect some arguments but there is not
            		if types and not any(args):
                		success = False
                		answer = 'Error - missing arguments, type help(%s) for details' %command
                		logger.logError(answer)
                		return (success, answer)

            		try:
               			method = getattr(self, method_name)
			except AttributeError, ex:
				success = False
				answer = "Error - %s has no attribute %s" %(self, method_name)
				logger.logError(answer)
				return (success, answer)
			try:
				result = method(*[type_(arg) for (arg, type_) in zip(args, types)])
				answer = '' if result is None else str(result)
				success = True
			except (ValueError, TypeError), ex:
				success = False
				answer = 'Error - wrong parameter usage.\nType help(%s) for details' %command
				logger.logError('%s\n%s' %(ex.message, answer))
				return (success, answer)
			except ComponentErrors.ComponentErrorsEx, ex:
				success = False
				data_list = ex.errorTrace.data # A list
				reason = data_list[0].value if data_list else 'component error'
				answer = 'Error - %s' %reason
				logger.logError(answer)
				return (success, answer)
			except Exception, ex:
				success = False
				msg = ex.message if ex.message else 'unexpected exception'
				answer = 'Error - %s' %(ex.getReason() if hasattr(ex, 'getReason') else msg)
				logger.logError(answer)
                		return (success, answer)

		logger.logInfo('command %s executed' %cmd)
	        return (success, answer)

	@staticmethod
	def worker(servo, control, sleep_time=1):
		while True:
+4 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import ACSLog
from Acspy.Servants import ContainerServices
from Acspy.Common.TimeHelper import getTimeStamp
from IRAPy import logger
from maciErrType import CannotGetComponentEx
from math import *


@@ -50,6 +51,7 @@ class Servo(object):
		""" Bussiness logic parameters """
		self.configured=False
		self.connected=False;
		self.trackingEnabled=False

	def __del__(self):
		self.disconnect()
@@ -91,7 +93,7 @@ class Servo(object):
		
	def updatePosition(self):
		print "Updating position......."
		if (self.configured) and (self.currentConf!="") and (self.antennaBoss!=None):
		if (self.configured) and (self.currentConf!="") and (self.antennaBoss!=None) and (self.trackingEnabled):
			ctime=getTimeStamp().value
			try:
				az,el=self.antennaBoss.getRawCoordinates(ctime)
@@ -183,6 +185,7 @@ class Servo(object):
			it should be set when the migration /primary/secondary is completed
			"""
			self.configured=True
			self.trackingEnabled=True
		finally:
			Servo.classLock.release()