struct_base = Struct("base", UBInt8("version"), SizeAdapter(Field("size", 3))) struct_common = Struct("common", Embed(struct_base), UBInt8("msg_type"), UBInt8("device"), UBInt8("command"), Field("data", lambda ctx: ctx.size - 7)) struct_byte = Struct("byte", UBInt8("byte")) struct_batt_connected = Struct( "batt_connected", UBInt8("slots_number"), Array(lambda ctx: ctx.slots_number, UBInt8("slots"))) struct_batt_get_status = Struct( "batt_get_status", UBInt8("batt_number"), Array( lambda ctx: ctx.batt_number, Struct("batt_data", UBInt8("slot_number"), UBInt16("tension"), SBInt16("corriente"), LFloat32("temp"), UBInt16("remaining"), UBInt16("full_charge"), UBInt16("ciclos")))) struct_batt_params = Struct( "batt_params", UBInt8("batt_number"), Array( lambda ctx: ctx.batt_number, Struct("batt_data", UBInt8("slot_number"), UBInt16("design_capacity"), Array(11, UBInt8("manufacturer")), UBInt16("serial_number"), Array(7, UBInt8("model")), Array(4, UBInt8("chem")), UBInt16("date_manuf"), UBInt16("nominal_tension")))) struct_power_check = Struct("power_check", LFloat32("v_24"), LFloat32("v_12"), LFloat32("v_5"), LFloat32("v_3")) struct_batt_level = Struct("batt_level", UBInt8("slot_number"), UBInt8("level_empty"), UBInt8("level_critical"), UBInt8("level_min"), UBInt8("full_charge"),
from empower.persistence.persistence import TblBelongs from empower.persistence.persistence import TblPendingTenant from empower.core.account import Account from empower.core.tenant import Tenant from empower.core.acl import ACL from empower.persistence.persistence import TblAllow from empower.persistence.persistence import TblDeny from empower.persistence.persistence import TblIMSI2MAC import empower.logger DEFAULT_PERIOD = 5000 CTRL_ADV = Struct("ctrl_adv", Bytes("dst", 6), Bytes("src", 6), UBInt16("eth_type"), Bytes("ctrl", 4), UBInt16("port")) def generate_default_accounts(): """Generate default accounts. Three default accounts (one root account and two user accounts are created the first time the controller is started. """ if not Session().query(TblAccount).all(): session = Session() session.add(TblAccount(username="******",
from construct import Array from empower.datatypes.etheraddress import EtherAddress from empower.lvapp.lvappserver import ModuleLVAPPWorker from empower.core.module import Module from empower.core.app import EmpowerApp from empower.core.resourcepool import ResourceBlock from empower.core.resourcepool import ResourcePool from empower.lvapp import PT_VERSION from empower.main import RUNTIME PT_TXP_BIN_COUNTER_REQUEST = 0x34 PT_TXP_BIN_COUNTER_RESPONSE = 0x35 STATS = Sequence("stats", UBInt16("bytes"), UBInt32("count")) TXP_BIN_COUNTER_REQUEST = \ Struct("txp_bin_counter_request", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), Bytes("mcast", 6),) TXP_BIN_COUNTER_RESPONSE = \ Struct("txp_bin_counter_response",
R_EQ = 'EQ' R_GE = 'GE' R_LE = 'LE' RELATIONS = {R_EQ: 0, R_GT: 1, R_LT: 2, R_GE: 3, R_LE: 4} PT_ADD_BUSYNESS = 0x38 PT_BUSYNESS = 0x39 PT_DEL_BUSYNESS = 0x40 ADD_BUSYNESS_TRIGGER = Struct("add_busyness_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), UBInt8("relation"), UBInt32("value"), UBInt16("period")) BUSYNESS_TRIGGER = Struct("busyness_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id"), Bytes("wtp", 6), Bytes("hwaddr", 6), UBInt8("channel"), UBInt8("band"), UBInt32("current")) DEL_BUSYNESS_TRIGGER = Struct("del_busyness_trigger", UBInt8("version"), UBInt8("type"), UBInt32("length"), UBInt32("seq"), UBInt32("module_id")) class BusynessTrigger(ModuleTrigger): """ Busyness trigger object. """