Class EnergyMeter3Module
Class Examples
from emod_controller_python_binding import emeter3_module
import time
import ctypes
################################# TEST BINDINGS #######################################
# Callback function definition
def my_callback(data, datalen, idFunction, ctx):
if idFunction == 1:
print("Power L1 Phase function")
elif idFunction == 2:
print("Power L2 Phase function")
elif idFunction == 3:
print("Power L3 Phase function")
elif idFunction == 5:
print("Energy L1 Phase function")
elif idFunction == 6:
print("Energy L2 Phase function")
elif idFunction == 7:
print("Energy L3 Phase function")
# Context variable initialization
context = ctypes.c_void_p()
# Create an EnergyMeter3Module object
f = emeter3_module.EnergyMeter3Module()
# Init module
if (
f.init_with_callback(
emeter3_module.EM3, emeter3_module.EnergyMeter3ModuleCallback_Type(my_callback)
)
== 0
):
print("Init done properly")
# Config current full scale
if f.config_current_full_scale(1000, 1000, 1000) == 0:
print("Config current fs done properly")
else:
print("Config current fs NOT done properly")
# Config secondary voltage full scale
if f.config_secondary_voltage_full_scale(230, 230, 230) == 0:
print("Config current fs done properly")
else:
print("Config current fs NOT done properly")
# Get current full scale
fs1, fs2, fs3 = f.get_current_full_scale()
print("fc_L1:" + str(fs1) + "/fc_L2:" + str(fs2) + "/fc_L3:" + str(fs3))
# Get secondary voltage full scale
vfs1, vfs2, vfs3 = f.get_secondary_voltage_full_scale()
print("fv_L1:" + str(vfs1) + "/fv_L2:" + str(vfs2) + "/fv_L3:" + str(vfs3))
# Config work mode and metering standard
if f.config_work_mode(2) == 0:
print("Config mode done properly")
if f.config_metering_standard(1):
print("Config standard done properly")
# Get work mode and metering standard
mode = f.get_work_mode()
print("mode:" + str(mode))
standard = f.get_metering_standard()
print("standard:" + str(standard))
# Config event at time interval
if f.config_event_at_time_interval(1000) == 0:
print("Event at time interval properly configured")
while 1:
time.sleep(2)
else:
print("Some error occured during module initialization...")
from emod_controller_python_binding import emeter3_module
import time
################################# TEST BINDINGS #######################################
# Create an EnergyMeter3Module object
f = emeter3_module.EnergyMeter3Module()
# Init module
if f.init(emeter3_module.EM3) == 0:
print("Init done properly")
# Config current full scale
if f.config_current_full_scale(1000, 1000, 1000) == 0:
print("Config current fs done properly")
else:
print("Config current fs NOT done properly")
# Config secondary voltage full scale
if f.config_secondary_voltage_full_scale(230, 230, 230) == 0:
print("Config current fs done properly")
else:
print("Config current fs NOT done properly")
# Get current full scale
fs1, fs2, fs3 = f.get_current_full_scale()
print("fc_L1:" + str(fs1) + "/fc_L2:" + str(fs2) + "/fc_L3:" + str(fs3))
# Get secondary voltage full scale
vfs1, vfs2, vfs3 = f.get_secondary_voltage_full_scale()
print("fv_L1:" + str(vfs1) + "/fv_L2:" + str(vfs2) + "/fv_L3:" + str(vfs3))
# Config work mode and metering standard
if f.config_work_mode(2) == 0:
print("Config mode done properly")
if f.config_metering_standard(1):
print("Config standard done properly")
# Get work mode and metering standard
mode = f.get_work_mode()
print("mode:" + str(mode))
standard = f.get_metering_standard()
print("standard:" + str(standard))
while 1:
# Get power and energy parameters
power_params = f.get_power_parameters(1)
print(
"voltage:"
+ str(power_params.voltage)
+ "/current:"
+ str(power_params.current)
+ "/power_active:"
+ str(power_params.active_power)
)
energy_params = f.get_energy_parameters(2)
print("active_energy:" + str(energy_params.active_energy))
time.sleep(2)
else:
print("Some error occured during module initialization...")
Public Functions
- class emod_controller_python_binding.emeter3_module.EnergyMeter3Module[source]
Bases:
object
- config_current_direction(current_direction_L1, current_direction_L2, current_direction_L3)[source]
Configs the current direction of each phase. The current direction will be reversed if it is set to true.
- Parameters
current_direction_L1 – current direction at L1.
current_direction_L2 – current direction at L2.
current_direction_L3 – current direction at L3.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- config_current_full_scale(full_current_L1, full_current_L2, full_current_L3)[source]
Configs the full scale amperage, 1:N ratio of the current transformer. Secondary full scale is 1 Amper.
- Parameters
full_current_L1 – full scale or ratio of conversion of the transformer (clamp, tiroidal, …) at L1.
full_current_L2 – full scale or ratio of conversion of the transformer (clamp, tiroidal, …) at L2.
full_current_L3 – full scale or ratio of conversion of the transformer (clamp, tiroidal, …) at L3.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- config_event_at_time_interval(time_interval)[source]
Configures module for calling init callback_func at specified period.
- Parameters
time_interval – period in milliseconds. Minimum value is 500ms.
event_mask – bit mask representing inputs that must trigger the event.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- config_metering_standard(standard)[source]
Configs the metering standard.
- Parameters
standard – 0 (Circutor), 1 (IEC62053-23), 2 (IEEE 1459-2000).
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- config_secondary_voltage_full_scale(full_voltage_L1, full_voltage_L2, full_voltage_L3)[source]
Configs the full scale of the secondary voltage of the transformer. In most scenarios this value is 230V.
- Parameters
full_voltage_L1 – full scale of the transformer’s secondary at L1.
full_voltage_L2 – full scale of the transformer’s secondary at L2.
full_voltage_L3 – full scale of the transformer’s secondary at L3.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- config_voltage_full_scale(full_voltage_L1, full_voltage_L2, full_voltage_L3)[source]
- Configs the full scale of the primary voltage of the transformer. If no
transformer is present, this value should be the means voltage, ex. 230V.
- Parameters
full_voltage_L1 – full scale of the transformer’s primary at L1.
full_voltage_L2 – full scale of the transformer’s primary at L2.
full_voltage_L3 – full scale of the transformer’s primary at L3.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- config_work_mode(mode)[source]
Configs the work mode as explained in SEM Three manual.
- Parameters
mode – Mode 0 (All L1, L2 & L3 are single phased), Mode 1 (L2 & L3 are single phased, L1 isequilibrated three phased), Mode 2 (L3 is single phased, L1 & L2 are equilibrated three phased), Mode 3 (All L1, L2 & L3 are equilibrated three phased).
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- get_current_direction()[source]
Gets the current direction of each phase. The current direction is reversed if set to true..
- Returns
It returns the current direction of each phase [L1,L2,L3].
- get_current_full_scale()[source]
Gets the full scale amperage, 1:N ratio of the current transformer..
- Returns
It returns the full scale amperage for each phase [L1, L2, L3].
- get_energy_parameters(phase)[source]
Gets all the energy parameters for a given phase.
- Parameters
phase – integer corresponding to phases L1 L2 L3.
- Returns
It returns a structured list of parameters.
- get_energy_parameters_combined()[source]
Gets all the power parameters for the combination of the three phases.
- Returns
It returns a structured list of parameters.
- get_metering_standard()[source]
Gets the metering standard.
- Returns
It returns the metering standard configured.
- get_power_parameters(phase)[source]
Gets all the power parameters for a given phase.
- Parameters
phase – integer corresponding to phases L1 L2 L3.
- Returns
It returns a structured list of parameters.
- get_secondary_voltage_full_scale()[source]
Gets the full scale of the secondary voltage of the transformer.
- Returns
It returns the full scale of the secondary voltage [L1, L2, L3].
- get_voltage_full_scale()[source]
Gets the full scale of the primary voltage of the transformer.
- Returns
It returns the full scale of the primary voltage [L1, L2, L3].
- get_work_mode()[source]
Gets the work mode as explained in SEM Three manual.
- Returns
It returns the work mode configured.
- init(em3_type)[source]
Initialize module. It is important to emphasize that init() method is mandatory to call it and must be called always after instantiating the module. It can be called several times, each of which the module is initialized again.
- Parameters
em3_type – it indicates if the 1A module or the 250mA module is used.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- init_v(callback, variant)[source]
Initialize module. It is important to emphasize that this method is mandatory to call it. It can be called several times, each of which the module is initialized again.
- Parameters
em3_type – it indicates if the 1A module or the 250mA module is used.
callback – function that will be called when a configured event occurs.
variant – identifies the module in case more than one module of the same type are present.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- init_with_callback(em3_type, callback)[source]
Initialize module. It is important to emphasize that this method is mandatory to call it. It can be called several times, each of which the module is initialized again.
- Parameters
em3_type – it indicates if the 1A module or the 250mA module is used.
callback – function that will be called when a configured event occurs.
- Returns
It returns if the initialization was successfull (0) or not (!=0).
- class emod_controller_python_binding.emeter3_module.PhaseEnergyParameters[source]
Bases:
_ctypes.Structure
- active_energy
Structure/Union member
- aparent_energy
Structure/Union member
- capacitive_energy
Structure/Union member
- exported_active_energy
Structure/Union member
- exported_aparent_energy
Structure/Union member
- exported_capacitive_energy
Structure/Union member
- exported_inductive_energy
Structure/Union member
- imported_active_energy
Structure/Union member
- imported_aparent_energy
Structure/Union member
- imported_capacitive_energy
Structure/Union member
- imported_inductive_energy
Structure/Union member
- inductive_energy
Structure/Union member
- class emod_controller_python_binding.emeter3_module.PhasePowerParameters[source]
Bases:
_ctypes.Structure
- active_power
Structure/Union member
- angle
Structure/Union member
- aparent_power
Structure/Union member
- cosine
Structure/Union member
- current
Structure/Union member
- exported_active_power
Structure/Union member
- exported_aparent_power
Structure/Union member
- exported_capacitive_power
Structure/Union member
- exported_inductive_power
Structure/Union member
- frequency
Structure/Union member
- imported_active_power
Structure/Union member
- imported_aparent_power
Structure/Union member
- imported_capacitive_power
Structure/Union member
- imported_inductive_power
Structure/Union member
- maximeter
Structure/Union member
- reactive_power
Structure/Union member
- voltage
Structure/Union member