Пример #1
0
 def add_group(self):
     print "Adding group"
     self.group1 = Group(name="group")
     self.group1.save()
     self.group2 = Group(name="group2")
     self.group2.save()
     self.area = AreaInfo(areaid="TEST000000",
                          areanm="TEST",
                          groupid=self.group1)
     self.area.save()
     self.place = PlaceInfo(placeid="TEST000000",
                            placenm="TEST",
                            areaid=self.area,
                            groupid=self.group2)
     self.place.save()
     self.devicetype = DeviceTypeInfo(typeid="0",
                                      devicetype=1,
                                      typenm="Controller")
     self.devicetype.save()
     print "Enter controller id from 0 to 19, please enter a single digit.\n"
     for ev in range(14):
         id1 = raw_input()
         test_ev = "0000-0000-0000" + id1
         self.con = ControllerInfo(controllerid=test_ev,
                                   placeid=self.place,
                                   controllernm="TEST cont",
                                   type=self.devicetype)
         self.con.save()
Пример #2
0
 def setUp(self):
     self.group1 = Group(name="group")
     self.group1.save()
     self.group2 = Group(name="group2")
     self.group2.save()
     self.area = AreaInfo(areaid="TEST000000",areanm="TEST",groupid = self.group1)
     self.area.save()
     self.place = PlaceInfo(placeid="TEST000000",placenm="TEST",areaid=self.area,groupid = self.group2)
     self.place.save()
     self.devicetype = DeviceTypeInfo(typeid="0",devicetype=1,typenm="Controller")
     self.devicetype.save()
     self.con = ControllerInfo(controllerid = "TEST-0000-000000",placeid=self.place,controllernm="TEST cont",type=self.devicetype)
     self.con.save()
Пример #3
0
 def setUp(self):
     self.group = Group(name="group")
     self.group.save()
     self.area = AreaInfo(areaid="TEST000000",areanm="TEST",groupid = self.group)
     self.area.save()
     self.place = PlaceInfo(placeid="TEST000000",placenm="TEST",areaid=self.area,groupid = self.group)
     self.place.save()
     self.devicetype = DeviceTypeInfo(typeid="0",devicetype=1,typenm="Controller")
     self.devicetype.save()
     self.con = ControllerInfo(controllerid = "TEST-0000-000000",placeid=self.place,controllernm="TEST cont",type=self.devicetype)
     self.con.save()
     
     self.req = ControlResult(requestid=1,controllerid=self.con,controltype=80,devicetype=1,deviceindex=0)
     self.req.save()
Пример #4
0
    def setUp(self):
        self.group = Group(name="group")
        self.group.save()
        self.area = AreaInfo(areaid="TEST000000",
                             areanm="TEST",
                             groupid=self.group)
        self.area.save()
        self.place = PlaceInfo(placeid="TEST000000",
                               placenm="TEST",
                               areaid=self.area,
                               groupid=self.group)
        self.place.save()
        self.devicetype = DeviceTypeInfo(typeid="0",
                                         devicetype=1,
                                         typenm="Controller")
        self.devicetype.save()
        self.con = ControllerInfo(controllerid="0000-0000-000000",
                                  placeid=self.place,
                                  controllernm="TEST cont",
                                  type=self.devicetype)
        self.con.save()

        self.senddate = "2013-07-08 11:11:11"
        self.alermtype = "0"

        self.bttrtype = DeviceTypeInfo(typeid="1",
                                       devicetype=2,
                                       typenm="Battery")
        self.bttrtype.save()

        self.sb = SettingBattery(type=self.bttrtype)
        self.sb.controllerid = self.con
        self.sb.deviceindex = 0
        self.sb.mode = 1
        self.sb.soc_max = 80
        self.sb.soc_min = 0
        self.sb.energy = 1800
        self.sb.shipping_energy = 1800
        self.sb.chargepower_max = 2000
        self.sb.dischargepower_max = 1000
        self.sb.bms_cnt = 1
        self.sb.voltage_max = 100
        self.sb.voltage_min = 50
        self.sb.peak_shaving_limit = 10000
        self.sb.save()
Пример #5
0
def ControlResultSetup(obj):
    obj.group = Group(name="group")
    obj.group.save()
    obj.area = AreaInfo(areaid="TEST000000",areanm="TEST",groupid = obj.group)
    obj.area.save()
    obj.place = PlaceInfo(placeid="TEST000000",placenm="TEST",areaid=obj.area,groupid = obj.group)
    obj.place.save()
    obj.devicetype = DeviceTypeInfo(typeid="0",devicetype=1,typenm="Controller")
    obj.devicetype.save()
    obj.devicetypeb = DeviceTypeInfo(typeid="1",devicetype=2,typenm="Battery")
    obj.devicetypeb.save()
    obj.con = ControllerInfo(controllerid = "TEST-0000-000000",placeid=obj.place,controllernm="TEST cont",type=obj.devicetype)
    obj.con.save()
        
    for i in range(0,100):
        res = ControlResult(requestid=i+100, controllerid=obj.con, deviceindex=0, controltype=10, devicetype=1)
        if i < 60:
            res.result = 1
        res.save()
        
        res.updatedate = (dt.utcnow() - timedelta(days=100-i,hours=-1))
        cursor = connection.cursor()
        cursor.execute("update emscontrol_controlresult set updatedate=%s where requestid=%s",[res.updatedate.strftime('%Y-%m-%d %H:%M:%S'),str(res.requestid)])
        transaction.commit_unless_managed()
Пример #6
0
    def setUp(self):
        self.group = Group(name="group")
        self.group.save()
        self.area = AreaInfo(areaid="TEST000000",
                             areanm="TEST",
                             groupid=self.group)
        self.area.save()
        self.place = PlaceInfo(placeid="TEST000000",
                               placenm="TEST",
                               areaid=self.area,
                               groupid=self.group)
        self.place.save()
        self.devicetype = DeviceTypeInfo(typeid="0",
                                         devicetype=1,
                                         typenm="Controller")
        self.devicetype.save()
        self.con = ControllerInfo(controllerid="0000-0000-000000",
                                  placeid=self.place,
                                  controllernm="TEST cont",
                                  type=self.devicetype)
        self.con.save()

        self.senddate = "2013-07-08 11:11:11"
        self.alermtype = "0"