예제 #1
0
 def testGetAlarm(self):
     test_alarm = Alarm()
     test_message = "test message"
     test_alarm.setMessage(test_message)
     test_ntscalar = NTScalar("double")
     test_ntscalar.getAlarm(test_alarm)
     self.assertEqual(test_alarm.getMessage(), test_message)
     self.assertEqual(test_alarm.getSeverity(), "NONE")
     self.assertEqual(test_alarm.getStatus(), "NONE")
예제 #2
0
 def testGetAlarm(self):
     test_alarm = Alarm()
     test_message = "test message"
     test_alarm.setMessage(test_message)
     test_ntscalar = NTScalar("double")
     test_ntscalar.getAlarm(test_alarm)
     self.assertEqual(test_alarm.getMessage(), test_message)
     self.assertEqual(test_alarm.getSeverity(), "NONE")
     self.assertEqual(test_alarm.getStatus(), "NONE")
예제 #3
0
 def testGetControl(self):
     test_min_step = 1  # these are the same default values used in the Control.py test
     test_limit_high = 10.0
     test_limit_low = -10.0
     test_control = Control(test_limit_low, test_limit_high, test_min_step)
     test_ntscalar = NTScalar("double")
     test_ntscalar.getControl(test_control)
     self.assertEqual(test_control.getMinStep(), test_min_step)
     self.assertEqual(test_control.getLimitLow(), test_limit_low)
     self.assertEqual(test_control.getLimitHigh(), test_limit_high)
예제 #4
0
 def testGetControl(self):
     test_min_step = 1  # these are the same default values used in the Control.py test
     test_limit_high = 10.0
     test_limit_low = -10.0
     test_control = Control(test_limit_low,
                            test_limit_high,
                            test_min_step)
     test_ntscalar = NTScalar("double")
     test_ntscalar.getControl(test_control)
     self.assertEqual(test_control.getMinStep(), test_min_step)
     self.assertEqual(test_control.getLimitLow(), test_limit_low)
     self.assertEqual(test_control.getLimitHigh(), test_limit_high)
예제 #5
0
 def testGetDisplay(self):
     test_description = "test description"  # these are the same default values used in the Display.py test
     test_limit_high = 10.0
     test_limit_low = -10.0
     test_format = "%f"
     test_units = "voltage"
     test_display = Display(test_limit_low, test_limit_high,
                            test_description, test_format, test_units)
     test_ntscalar = NTScalar("double")
     test_ntscalar.getDisplay(test_display)
     self.assertEqual(test_display.getDescription(), test_description)
     self.assertEqual(test_display.getLimitLow(), test_limit_low)
     self.assertEqual(test_display.getLimitHigh(), test_limit_high)
     self.assertEqual(test_display.getFormat(), test_format)
     self.assertEqual(test_display.getUnits(), test_units)
예제 #6
0
 def testGetDisplay(self):
     test_description = "test description"  # these are the same default values used in the Display.py test
     test_limit_high = 10.0
     test_limit_low = -10.0
     test_format = "%f"
     test_units = "voltage"
     test_display = Display(test_limit_low,
                            test_limit_high,
                            test_description,
                            test_format,
                            test_units)
     test_ntscalar = NTScalar("double")
     test_ntscalar.getDisplay(test_display)
     self.assertEqual(test_display.getDescription(), test_description)
     self.assertEqual(test_display.getLimitLow(), test_limit_low)
     self.assertEqual(test_display.getLimitHigh(), test_limit_high)
     self.assertEqual(test_display.getFormat(), test_format)
     self.assertEqual(test_display.getUnits(), test_units)
예제 #7
0
def __clientRPC(function, params):
    alarm = Alarm()
    timeStamp = TimeStamp()

    ntnv = NTNameValue(function, params)

    # now do issue + wait
    channelRPC = ChannelRPC("masarService")
    channelRPC.issueConnect()
    if not channelRPC.waitConnect(1.0):
        print "error when waiting connection.", channelRPC.getMessage()
        exit(1)
    channelRPC.issueRequest(ntnv.getNTNameValue(), False)
    result = channelRPC.waitResponse()
    if result is None:
        print channelRPC.getMessage()
        exit(1)
#    print "problem to get nttable using getNTTable()"
    if function in ["retrieveSnapshot", "getLiveMachine", "saveSnapshot"]:
        result = NTMultiChannel(result)
    elif function in [
            "retrieveServiceEvents", "retrieveServiceConfigs",
            "retrieveServiceConfigProps"
    ]:
        result = NTTable(result)
        label = result.getLabels()
        print "label", label
        print result.getPVStructure()
    elif function == "updateSnapshotEvent":
        result = NTScalar(result)


#    print "Problem above"
#     print result

    result.getAlarm(alarm)
    # print alarm

    result.getTimeStamp(timeStamp)
    # print timeStamp

    # numberValues = result.getNumberValues()
    # print "numberValues", numberValues

    #
    #    i = 0
    #    while i < numberValues :
    #        value = nttable.getValue(i)
    #        print "value",label[i],value
    #        i += 1
    return result
예제 #8
0
#

import time

from masarclient.ntscalar import NTScalar as NTScalar
from masarclient.alarm import Alarm as Alarm
from masarclient.timeStamp import TimeStamp as TimeStamp
from masarclient.control import Control as Control
from masarclient.display import Display as Display

timeStamp = TimeStamp()
alarm = Alarm()
control = Control()
display = Display()

scalar = NTScalar("double")
print scalar

newscalar = scalar.getNTScalar()
print newscalar
print "getTimeStamp"
scalar.getTimeStamp(timeStamp)
print timeStamp
print "getAlarm"
scalar.getAlarm(alarm)
print alarm
print "getControl"
scalar.getControl(control)
print control
print "getDisplay"
scalar.getDisplay(display)
예제 #9
0
 def testGetValue(self):
     test_ntscalar = NTScalar("double")
     self.assertEqual(test_ntscalar.getValue(), 0.0)
예제 #10
0
 def testGetTimeStamp(self):
     test_timestamp = TimeStamp()
     test_ntscalar = NTScalar("double")
     test_ntscalar.getTimeStamp(test_timestamp)
     self.assertEqual(3, len(
         str(test_timestamp).split(":")))  # Timestamp string format test
예제 #11
0
 def testGetNTScalar(self):
     scalar = NTScalar("double")
     newscalar = scalar.getNTScalar()
     self.assertNotEqual(newscalar, None)
예제 #12
0
 def testGetDescriptor(self):
     test_ntscalar = NTScalar("double")
     self.assertEqual(test_ntscalar.getDescriptor(), "")
예제 #13
0
 def testGetValue(self):
     test_ntscalar = NTScalar("double")
     self.assertEqual(test_ntscalar.getValue(), 0.0)
예제 #14
0
 def testGetTimeStamp(self):
     test_timestamp = TimeStamp()
     test_ntscalar = NTScalar("double")
     test_ntscalar.getTimeStamp(test_timestamp)
     self.assertEqual(3, len(str(test_timestamp).split(":")))  # Timestamp string format test
예제 #15
0
 def testGetNTScalar(self):
     scalar = NTScalar("double")
     newscalar = scalar.getNTScalar()
     self.assertNotEqual(newscalar, None)
예제 #16
0
 def testGetDescriptor(self):
     test_ntscalar = NTScalar("double")
     self.assertEqual(test_ntscalar.getDescriptor(), "")