Esempio n. 1
0
 def testHBTFile(self):
     mc = Session((StorageServiceTest.addr, StorageServiceTest.port), None)
     mc.start()
     service = StorageService(mc)
     hbtFile = service.getElement(StorageServiceTest.testSpacePath).resolve(
         'HBTFileTest.hbt').toHBTFileElement()
     hbtFile.initialize([["Column 1", HBTFileElement.BYTE],
                         ["Column 2", HBTFileElement.SHORT],
                         ["Column 3", HBTFileElement.INT],
                         ["Column 4", HBTFileElement.LONG],
                         ["Column 5", HBTFileElement.FLOAT],
                         ["Column 6", HBTFileElement.DOUBLE]])
     hbtFile.appendRow([1, 2, 3, 4, 5, 6])
     hbtFile.appendRows([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6],
                         [1, 2, 3, 4, 5, 6], [1.1, 2.2, 3.3, 4.4, 5.5, 6.6],
                         [1.1, 2.2, 3.3, 4.4, 5.5, 6.6]])
     self.assertEqual(hbtFile.readRows(0, 1)[0], [1, 2, 3, 4, 5, 6])
     self.assertEqual(hbtFile.readRow(1), [1, 2, 3, 4, 5, 6])
     self.assertEqual(hbtFile.readRow(2), [1, 2, 3, 4, 5, 6])
     self.assertEqual(hbtFile.readRow(3), [1, 2, 3, 4, 5, 6])
     self.assertEqual(hbtFile.readRow(4), [1, 2, 3, 4, 5.5, 6.6])
     self.assertEqual(hbtFile.readRow(5), [1, 2, 3, 4, 5.5, 6.6])
     self.assertEqual(hbtFile.getColumnCount(), 6)
     self.assertEqual(hbtFile.getRowCount(), 6)
     self.assertEqual(hbtFile.getHeadNames(), [
         'Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5',
         'Column 6'
     ])
     mc.stop()
Esempio n. 2
0
 def testElementList(self):
     mc = Session((StorageServiceTest.addr, StorageServiceTest.port), None)
     mc.start()
     service = StorageService(mc)
     element = service.getElement(StorageServiceTest.testSpacePath)
     a = element.listElements()
     self.assertEqual(a, ["_A1", "_A2", "a1", "a2", "a3", "a4", "a5"])
     mc.stop()
Esempio n. 3
0
__author__ = 'Hwaipy'

import sys
from Pydra import Message, ProtocolException, Session
import socket
import threading
import time
from Services.Storage import StorageService, HBTFileElement
import random
import math

if __name__ == '__main__':
    mc = Session(("192.168.25.27", 20102), None)
    mc.start()
    service = StorageService(mc)
    hbtFile = service.getElement('HBTChartTest.hbt').toHBTFileElement()
    hbtFile.initialize([["Column 1", HBTFileElement.BYTE],
                        ["Column 2", HBTFileElement.SHORT],
                        ["Column 3", HBTFileElement.INT],
                        ["Column 4", HBTFileElement.LONG],
                        ["Column 5", HBTFileElement.FLOAT],
                        ["Column 6", HBTFileElement.DOUBLE]])
    for i in range(0, 10):
        d1 = i
        d2 = i * i
        d3 = -i
        d4 = i * i * i
        d5 = math.sin(i)
        d6 = math.exp(i)
        hbtFile.appendRow([d1, d2, d3, d4, d5, d6])
    mc.stop()