Skip to content

Commit

Permalink
BPS => BPC
Browse files Browse the repository at this point in the history
  • Loading branch information
XdoctorwhoZ committed Aug 26, 2023
1 parent ad0040e commit a67e95f
Show file tree
Hide file tree
Showing 35 changed files with 240 additions and 240 deletions.
2 changes: 1 addition & 1 deletion client/panduza/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from .core import EnsureError

from .interfaces import Dio
from .interfaces import Bps
from .interfaces import Bpc
from .interfaces import Ammeter

4 changes: 2 additions & 2 deletions client/panduza/admin/writer_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def write(self):
"port": 1883,
"interfaces": [
{
"name": "fake_bps",
"driver": "py.bps.fake"
"name": "fake_bpc",
"driver": "py.bpc.fake"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion client/panduza/interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .dio import Dio
from .bps import Bps
from .bpc import Bpc
from .relay import Relay
from .ammeter import Ammeter
# from .serial_ import Serial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..core import Interface, Attribute, RoField, RwField

@dataclass
class Bps(Interface):
class Bpc(Interface):
"""Interface to manage power supplies
"""

Expand Down
6 changes: 3 additions & 3 deletions client/panduza/interfaces/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ..core.interface import Interface

from .dio import Dio
from .bps import Bps
from .bpc import Bpc
from .ammeter import Ammeter

from .relay import Relay
Expand All @@ -19,7 +19,7 @@ def GenerateAllInterfacesFromAliases(connections):
#
type_gen = {
"dio": Dio,
"bps": Bps,
"bpc": Bpc,
"ammeter": Ammeter,
"relay": Relay,
"voltmeter": Voltmeter
Expand Down Expand Up @@ -51,7 +51,7 @@ def GenerateAllInterfacesFromAliases(connections):
assert t != "unknown", f"Error > {name} interface does not respond"
assert t in type_gen, f"Unmanaged interface type {t} by panduza robotF plugin for {name}"
typed_interfaces[name] = type_gen[t](interface=itf)
# typed_interfaces[name] = Bps(interface=itf)
# typed_interfaces[name] = Bpc(interface=itf)


return typed_interfaces
Expand Down
4 changes: 2 additions & 2 deletions client/panduza/robof/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .ammeter import KeywordsAmmeter
from .client import KeywordsClient
from .bps import KeywordsBps
from .bpc import KeywordsBpc
from .dio import KeywordsDio
from .relay import KeywordsRelay
from .voltmeter import KeywordsVoltmeter
Expand All @@ -23,7 +23,7 @@ def __init__(self):
KeywordsAmmeter(),
KeywordsClient(),
KeywordsDio(),
KeywordsBps(),
KeywordsBpc(),
KeywordsRelay(),
KeywordsVoltmeter(),

Expand Down
90 changes: 45 additions & 45 deletions client/panduza/robof/bps.py → client/panduza/robof/bpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,159 +3,159 @@
from hamcrest import assert_that, equal_to, any_of
from .utils import boolean_str_to_boolean

class KeywordsBps(object):
class KeywordsBpc(object):

###########################################################################
# STATE
###########################################################################

@keyword
def turn_power_supply(self, bps_alias, state, ensure=True):
"""Turn the bps on the given state
def turn_power_supply(self, bpc_alias, state, ensure=True):
"""Turn the bpc on the given state
"""
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].enable.value.set(boolean_str_to_boolean(state), ensure)
pza[bpc_alias].enable.value.set(boolean_str_to_boolean(state), ensure)

# ---

@keyword
def turn_on_power_supply(self, bps_alias, ensure=True):
"""Turn on the bps
def turn_on_power_supply(self, bpc_alias, ensure=True):
"""Turn on the bpc
"""
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].enable.value.set(boolean_str_to_boolean("on"), ensure)
pza[bpc_alias].enable.value.set(boolean_str_to_boolean("on"), ensure)

# ---

@keyword
def turn_off_power_supply(self, bps_alias, ensure=True, teardown=False):
"""Turn off the bps
def turn_off_power_supply(self, bpc_alias, ensure=True, teardown=False):
"""Turn off the bpc
"""
pza = BuiltIn().get_variable_value("${__pza__}")

if pza == None:
# It is ok if panduza is not initialized, only if in the teardown process
assert not teardown
else:
pza[bps_alias].enable.value.set(boolean_str_to_boolean("off"), ensure)
pza[bpc_alias].enable.value.set(boolean_str_to_boolean("off"), ensure)

# ---

@keyword
def power_supply_should_be(self, bps_alias, state):
def power_supply_should_be(self, bpc_alias, state):
"""Check power supply state
"""
expected_state_bool = boolean_str_to_boolean(state)
pza = BuiltIn().get_variable_value("${__pza__}")
read_state = pza[bps_alias].enable.value.get()
read_state = pza[bpc_alias].enable.value.get()
assert_that(read_state, equal_to(expected_state_bool))

###########################################################################
# VOLTS
###########################################################################

@keyword
def set_power_supply_voltage_goal(self, bps_alias, voltage, ensure=True):
def set_power_supply_voltage_goal(self, bpc_alias, voltage, ensure=True):
"""Set the power supply voltage goal
"""
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].volts.goal.set(float(voltage), ensure)
pza[bpc_alias].volts.goal.set(float(voltage), ensure)

@keyword
def set_power_supply_voltage_polling_cycle(self, bps_alias:str, cycle:float, ensure=True):
def set_power_supply_voltage_polling_cycle(self, bpc_alias:str, cycle:float, ensure=True):
"""Set the power supply voltage goal
"""
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].volts.polling_cycle.set(float(cycle), ensure)
pza[bpc_alias].volts.polling_cycle.set(float(cycle), ensure)

###########################################################################
# AMPS
###########################################################################

@keyword
def set_power_supply_current_goal(self, bps_alias, current, ensure=True):
def set_power_supply_current_goal(self, bpc_alias, current, ensure=True):
"""Set the power supply amps goal
"""
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].amps.goal.set(float(current), ensure)
pza[bpc_alias].amps.goal.set(float(current), ensure)

@keyword
def set_power_supply_current_polling_cycle(self, bps_alias:str, cycle:float, ensure=True):
def set_power_supply_current_polling_cycle(self, bpc_alias:str, cycle:float, ensure=True):
"""Set the power supply voltage goal
"""
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].amps.polling_cycle.set(float(cycle), ensure)
pza[bpc_alias].amps.polling_cycle.set(float(cycle), ensure)

###########################################################################
# SETTINGS
###########################################################################

@keyword
def turn_power_supply_ovp_setting(self, bps_alias, value, ensure=True):
"""Turn bps setting ovp to the given state
def turn_power_supply_ovp_setting(self, bpc_alias, value, ensure=True):
"""Turn bpc setting ovp to the given state
"""
bool_val = boolean_str_to_boolean(value)
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].settings.ovp.set(bool_val, ensure)
pza[bpc_alias].settings.ovp.set(bool_val, ensure)

# ---

@keyword
def turn_power_supply_ocp_setting(self, bps_alias, value, ensure=True):
"""Turn bps setting ocp to the given state
def turn_power_supply_ocp_setting(self, bpc_alias, value, ensure=True):
"""Turn bpc setting ocp to the given state
"""
bool_val = boolean_str_to_boolean(value)
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].settings.ocp.set(bool_val, ensure)
pza[bpc_alias].settings.ocp.set(bool_val, ensure)

# ---

@keyword
def turn_power_supply_silent_setting(self, bps_alias, value, ensure=True):
"""Turn bps setting silent to the given state
def turn_power_supply_silent_setting(self, bpc_alias, value, ensure=True):
"""Turn bpc setting silent to the given state
"""
bool_val = boolean_str_to_boolean(value)
pza = BuiltIn().get_variable_value("${__pza__}")
pza[bps_alias].settings.silent.set(bool_val, ensure)
pza[bpc_alias].settings.silent.set(bool_val, ensure)

###########################################################################
# MISC
###########################################################################

@keyword
def read_power_supply_misc(self, bps_alias, misc_field, ensure=True):
def read_power_supply_misc(self, bpc_alias, misc_field, ensure=True):
"""Return the given misc_field
"""
# assert_that(value, any_of(equal_to(True), equal_to(False)))
pza = BuiltIn().get_variable_value("${__pza__}")
return pza[bps_alias].misc.get(misc_field)
return pza[bpc_alias].misc.get(misc_field)

###########################################################################
# FULL STANDART TESTS
###########################################################################

@keyword
def interface_bps_basic_controls(self, bps_alias):
def interface_bpc_basic_controls(self, bpc_alias):
"""Just test basic commands of a Power SUpply interface
Warning this test
"""
# Test voltage goal
BuiltIn().run_keyword("Set Power Supply Voltage Goal", bps_alias, 10)
BuiltIn().run_keyword("Set Power Supply Voltage Goal", bps_alias, 3.3)
BuiltIn().run_keyword("Set Power Supply Voltage Goal", bpc_alias, 10)
BuiltIn().run_keyword("Set Power Supply Voltage Goal", bpc_alias, 3.3)

# Test current limit
BuiltIn().run_keyword("Set Power Supply Current Goal", bps_alias, 2)
BuiltIn().run_keyword("Set Power Supply Current Goal", bps_alias, 0.1)
BuiltIn().run_keyword("Set Power Supply Current Goal", bpc_alias, 2)
BuiltIn().run_keyword("Set Power Supply Current Goal", bpc_alias, 0.1)

# Try to turn on and off
BuiltIn().run_keyword("Turn On Power Supply", bps_alias)
BuiltIn().run_keyword("Power Supply Should Be", bps_alias, "on")
BuiltIn().run_keyword("Turn Off Power Supply", bps_alias)
BuiltIn().run_keyword("Power Supply Should Be", bps_alias, "off")

BuiltIn().run_keyword("Turn Power Supply", bps_alias, "on")
BuiltIn().run_keyword("Power Supply Should Be", bps_alias, "on")
BuiltIn().run_keyword("Turn Power Supply", bps_alias, "off")
BuiltIn().run_keyword("Power Supply Should Be", bps_alias, "off")
BuiltIn().run_keyword("Turn On Power Supply", bpc_alias)
BuiltIn().run_keyword("Power Supply Should Be", bpc_alias, "on")
BuiltIn().run_keyword("Turn Off Power Supply", bpc_alias)
BuiltIn().run_keyword("Power Supply Should Be", bpc_alias, "off")

BuiltIn().run_keyword("Turn Power Supply", bpc_alias, "on")
BuiltIn().run_keyword("Power Supply Should Be", bpc_alias, "on")
BuiltIn().run_keyword("Turn Power Supply", bpc_alias, "off")
BuiltIn().run_keyword("Power Supply Should Be", bpc_alias, "off")

2 changes: 1 addition & 1 deletion client/tools/modbus_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Script to test bps on the given broker
"""Script to test bpc on the given broker
WARNING : !!! Make sur your Power Supply are not connected to any board !!!
"""
Expand Down
36 changes: 18 additions & 18 deletions client/tools/psu_tester.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Script to test bps on the given broker
"""Script to test bpc on the given broker
WARNING : !!! Make sur your Power Supply are not connected to any board !!!
"""
Expand All @@ -7,7 +7,7 @@
import time
import logging
import argparse
from panduza import Core, Client, Bps
from panduza import Core, Client, Bpc

# Main Variables
BROKER_ADDR="localhost"
Expand All @@ -18,35 +18,35 @@
# logging.basicConfig(encoding='utf-8', level=logging.DEBUG)


def step_set_state(bps, state, wait_s=3):
def step_set_state(bpc, state, wait_s=3):
"""Step to set the state
"""
print(f"- set state to {state}")
bps.state.value.set(state)
bpc.state.value.set(state)
if CHECK_USER_INPUT:
in_data = input("Ok or Ko ? [O/k] ")
else:
time.sleep(wait_s)



def step_set_volts(bps, value, wait_s=3):
def step_set_volts(bpc, value, wait_s=3):
"""Step to set the voltage
"""
print(f"- set volts to {value}")
bps.volts.value.set(value)
bpc.volts.value.set(value)
if CHECK_USER_INPUT:
in_data = input("Ok or Ko ? [O/k] ")
else:
time.sleep(wait_s)



def step_set_amps(bps, value, wait_s=3):
def step_set_amps(bpc, value, wait_s=3):
"""Step to set the amps
"""
print(f"- set amps to {value}")
bps.amps.value.set(value)
bpc.amps.value.set(value)
if CHECK_USER_INPUT:
in_data = input("Ok or Ko ? [O/k] ")
else:
Expand All @@ -60,20 +60,20 @@ def run_test_on_interface(client, topic):
print(f"### Test : ({topic}) ###")

# Create interface
bps = Bps(topic=topic, client=client)
bpc = Bpc(topic=topic, client=client)

# ===
step_set_volts(bps, 5)
step_set_volts(bps, 10)
step_set_volts(bps, 3.3)
step_set_volts(bpc, 5)
step_set_volts(bpc, 10)
step_set_volts(bpc, 3.3)

# ===
step_set_amps(bps, 0.5)
step_set_amps(bps, 3)
step_set_amps(bpc, 0.5)
step_set_amps(bpc, 3)

# ===
step_set_state(bps, "on")
step_set_state(bps, "off")
step_set_state(bpc, "on")
step_set_state(bpc, "off")



Expand All @@ -83,7 +83,7 @@ def run_test_on_interface(client, topic):
# Arguments
parser = argparse.ArgumentParser(
prog = 'Pza Power Supply Tester',
description = 'Perform test configuration on BPS connected to the broker')
description = 'Perform test configuration on BPC connected to the broker')
parser.add_argument('-a', '--broker-address')
parser.add_argument('-p', '--broker-port')
# parser.add_argument('-m', '--max')
Expand Down Expand Up @@ -125,7 +125,7 @@ def run_test_on_interface(client, topic):
interfaces = client.scan_interfaces()
for iface in interfaces:
iface_type = interfaces[iface]["type"]
if iface_type == "bps":
if iface_type == "bpc":
iface_state = interfaces[iface]["state"]
if iface_state == "run":
run_test_on_interface(client, iface)
Expand Down
Loading

0 comments on commit a67e95f

Please sign in to comment.