Exemple #1
0
    def testRecorder(self):
        self._resetE517ToSafe()
        print("%s" % self._gcs.getAllDataRecorderOptions())
        originalCfg= self._gcs.getDataRecorderConfiguration()

        nRecorders= self._gcs.getNumberOfRecorderTables()
        self.assertEqual(8, nRecorders)

        dataRecorderCfg= DataRecorderConfiguration()
        dataRecorderCfg.setTable(1, "A", RecordOption.REAL_POSITION_OF_AXIS)
        dataRecorderCfg.setTable(2, "B", RecordOption.REAL_POSITION_OF_AXIS)
        dataRecorderCfg.setTable(3, "1", RecordOption.VOLTAGE_OF_PIEZO_CHANNEL)
        self._gcs.setDataRecorderConfiguration(dataRecorderCfg)
        retrievedCfg= self._gcs.getDataRecorderConfiguration()
        self.assertEqual(RecordOption.REAL_POSITION_OF_AXIS,
                         retrievedCfg.getRecordOption(1))
        self.assertEqual(RecordOption.REAL_POSITION_OF_AXIS,
                         retrievedCfg.getRecordOption(2))
        self.assertEqual(RecordOption.VOLTAGE_OF_PIEZO_CHANNEL,
                         retrievedCfg.getRecordOption(3))
        self.assertEqual("A", retrievedCfg.getRecordSource(1))
        self.assertEqual("B", retrievedCfg.getRecordSource(2))
        self.assertEqual("1", retrievedCfg.getRecordSource(3))


        startFromPoint= 1
        howMany= 10
        self._gcs.startRecordingInSyncWithWaveGenerator()
        record= self._gcs.getRecordedDataValues(howMany, startFromPoint)
        self.assertEqual((nRecorders, howMany), record.shape)

        self._gcs.setDataRecorderConfiguration(originalCfg)
        self._resetE517ToSafe()
 def testSetAndGet(self):
     cfg = DataRecorderConfiguration()
     cfg.setTable(42, "foo", RecordOption.CONTROL_OUTPUT_OF_AXIS)
     cfg.setTable(3.14, 111, RecordOption.VOLTAGE_OF_PIEZO_CHANNEL)
     self.assertEqual("foo", cfg.getRecordSource(42))
     self.assertEqual(RecordOption.CONTROL_OUTPUT_OF_AXIS,
                      cfg.getRecordOption(42))
     self.assertEqual(111, cfg.getRecordSource(3.14))
     self.assertRaises(KeyError, cfg.getRecordSource, 43)
     self.assertEqual([42, 3.14], cfg.getTableIds())
 def testSetAndGet(self):
     cfg= DataRecorderConfiguration()
     cfg.setTable(42, "foo", RecordOption.CONTROL_OUTPUT_OF_AXIS)
     cfg.setTable(3.14, 111, RecordOption.VOLTAGE_OF_PIEZO_CHANNEL)
     self.assertEqual("foo", cfg.getRecordSource(42))
     self.assertEqual(RecordOption.CONTROL_OUTPUT_OF_AXIS,
                      cfg.getRecordOption(42))
     self.assertEqual(111, cfg.getRecordSource(3.14))
     self.assertRaises(KeyError, cfg.getRecordSource, 43)
     self.assertEqual([42, 3.14], cfg.getTableIds())
Exemple #4
0
 def _defaultDataRecorderConfiguration(self):
     dataRecorderCfg = DataRecorderConfiguration()
     dataRecorderCfg.setTable(1, "A", RecordOption.REAL_POSITION_OF_AXIS)
     dataRecorderCfg.setTable(2, "B", RecordOption.REAL_POSITION_OF_AXIS)
     dataRecorderCfg.setTable(3, "A", RecordOption.POSITION_ERROR_OF_AXIS)
     dataRecorderCfg.setTable(4, "B", RecordOption.POSITION_ERROR_OF_AXIS)
     dataRecorderCfg.setTable(5, "A", RecordOption.TARGET_POSITION_OF_AXIS)
     dataRecorderCfg.setTable(6, "B", RecordOption.TARGET_POSITION_OF_AXIS)
     return dataRecorderCfg
Exemple #5
0
 def _defaultDataRecorderConfiguration(self):
     dataRecorderCfg= DataRecorderConfiguration()
     dataRecorderCfg.setTable(1, "A", RecordOption.REAL_POSITION_OF_AXIS)
     dataRecorderCfg.setTable(2, "B", RecordOption.REAL_POSITION_OF_AXIS)
     dataRecorderCfg.setTable(3, "A", RecordOption.POSITION_ERROR_OF_AXIS)
     dataRecorderCfg.setTable(4, "B", RecordOption.POSITION_ERROR_OF_AXIS)
     dataRecorderCfg.setTable(5, "A", RecordOption.TARGET_POSITION_OF_AXIS)
     dataRecorderCfg.setTable(6, "B", RecordOption.TARGET_POSITION_OF_AXIS)
     return dataRecorderCfg
Exemple #6
0
    def getDataRecorderConfiguration(self):
        nRecorders = self.getNumberOfRecorderTables()
        sourceBufSize = 256
        source = ctypes.create_string_buffer('\000', sourceBufSize)
        option = CIntArray(np.zeros(nRecorders, dtype=np.int32))
        table = CIntArray(np.arange(1, nRecorders + 1))

        self._lib.PI_qDRC.argtypes = [
            c_int, CIntArray, c_char_p, CIntArray, c_int, c_int
        ]

        self._convertErrorToException(
            self._lib.PI_qDRC(self._id, table, source, option, sourceBufSize,
                              nRecorders))

        sources = [x.strip() for x in source.value.split('\n')]
        cfg = DataRecorderConfiguration()
        for i in range(nRecorders):
            cfg.setTable(table.toNumpyArray()[i], sources[i],
                         option.toNumpyArray()[i])
        return cfg
Exemple #7
0
    def getDataRecorderConfiguration(self):
        nRecorders= self.getNumberOfRecorderTables()
        sourceBufSize= 256
        source= ctypes.create_string_buffer(b'\000', sourceBufSize)
        option= CIntArray(np.zeros(nRecorders, dtype=np.int32))
        table=CIntArray(np.arange(1, nRecorders + 1))

        self._lib.PI_qDRC.argtypes= [c_int, CIntArray, c_char_p,
                                     CIntArray, c_int, c_int]

        self._convertErrorToException(
            self._lib.PI_qDRC(self._id, table, source,
                              option, sourceBufSize, nRecorders))

        sources= [x.strip() for x in source.value.decode().split('\n')]
        cfg= DataRecorderConfiguration()
        for i in range(nRecorders):
            cfg.setTable(table.toNumpyArray()[i],
                         sources[i],
                         option.toNumpyArray()[i])
        return cfg
Exemple #8
0
    def testRecorder(self):
        self._resetE517ToSafe()
        print("%s" % self._gcs.getAllDataRecorderOptions())
        originalCfg = self._gcs.getDataRecorderConfiguration()

        nRecorders = self._gcs.getNumberOfRecorderTables()
        self.assertEqual(8, nRecorders)

        dataRecorderCfg = DataRecorderConfiguration()
        dataRecorderCfg.setTable(1, "A", RecordOption.REAL_POSITION_OF_AXIS)
        dataRecorderCfg.setTable(2, "B", RecordOption.REAL_POSITION_OF_AXIS)
        dataRecorderCfg.setTable(3, "1", RecordOption.VOLTAGE_OF_PIEZO_CHANNEL)
        self._gcs.setDataRecorderConfiguration(dataRecorderCfg)
        retrievedCfg = self._gcs.getDataRecorderConfiguration()
        self.assertEqual(RecordOption.REAL_POSITION_OF_AXIS,
                         retrievedCfg.getRecordOption(1))
        self.assertEqual(RecordOption.REAL_POSITION_OF_AXIS,
                         retrievedCfg.getRecordOption(2))
        self.assertEqual(RecordOption.VOLTAGE_OF_PIEZO_CHANNEL,
                         retrievedCfg.getRecordOption(3))
        self.assertEqual("A", retrievedCfg.getRecordSource(1))
        self.assertEqual("B", retrievedCfg.getRecordSource(2))
        self.assertEqual("1", retrievedCfg.getRecordSource(3))

        startFromPoint = 1
        howMany = 10
        self._gcs.startRecordingInSyncWithWaveGenerator()
        record = self._gcs.getRecordedDataValues(howMany, startFromPoint)
        self.assertEqual((nRecorders, howMany), record.shape)

        self._gcs.setDataRecorderConfiguration(originalCfg)
        self._resetE517ToSafe()
 def testRaiseIfUnknownOption(self):
     cfg = DataRecorderConfiguration()
     self.assertRaises(Exception, cfg.setTable, 0, "bar", "UNKNOWN_OPTION")