Skip to content

Commit

Permalink
update auto test with bpc, am, vm from last auto tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguez committed Nov 6, 2023
1 parent f4ff7ac commit d1a1baf
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 58 deletions.
3 changes: 3 additions & 0 deletions client/panduza/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def scan_interfaces(self, type_filter="*"):
When both counter are equal, you are sure that you've got all the interfaces
"""

print("!!! DEPRECATED : scan_interfaces()")

# Init
self.__scan_mutex = threading.Lock()
self.__scan_results = {}
Expand Down
6 changes: 3 additions & 3 deletions client/panduza/interfaces/ammeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def __post_init__(self):

# === MEASURE ===
self.add_attribute(
Attribute( name = "measure" )
Attribute( name_ = "measure" )
).add_field(
RoField( name = "value" )
RoField( name_ = "value" )
).add_field(
RwField( name = "polling_cycle" )
RwField( name_ = "polling_cycle" )
)

if self.ensure:
Expand Down
42 changes: 21 additions & 21 deletions client/panduza/interfaces/bpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,59 +24,59 @@ def __post_init__(self):

# === ENABLE ===
self.add_attribute(
Attribute( name = "enable" )
Attribute( name_ = "enable" )
).add_field(
RwField( name = "value" )
RwField( name_ = "value" )
)

# === VOLTAGE ===
self.add_attribute(
Attribute( name = "voltage" )
Attribute( name_ = "voltage" )
).add_field(
RoField( name = "real" )
RoField( name_ = "real" )
).add_field(
RwField( name = "value" )
RwField( name_ = "value" )
).add_field(
RoField( name = "min" )
RoField( name_ = "min" )
).add_field(
RoField( name = "max" )
RoField( name_ = "max" )
).add_field(
RoField( name = "decimals" )
RoField( name_ = "decimals" )
).add_field(
RwField( name = "polling_cycle" )
RwField( name_ = "polling_cycle" )
)

# === CURRENT ===
self.add_attribute(
Attribute( name = "current" )
Attribute( name_ = "current" )
).add_field(
RoField( name = "real" )
RoField( name_ = "real" )
).add_field(
RwField( name = "value" )
RwField( name_ = "value" )
).add_field(
RoField( name = "min" )
RoField( name_ = "min" )
).add_field(
RoField( name = "max" )
RoField( name_ = "max" )
).add_field(
RoField( name = "decimals" )
RoField( name_ = "decimals" )
).add_field(
RwField( name = "polling_cycle" )
RwField( name_ = "polling_cycle" )
)

# === SETTINGS ===
self.add_attribute(
Attribute( name = "settings", bypass_init_ensure = True )
Attribute( name_ = "settings", bypass_init_ensure = True )
).add_field(
RwField( name = "ovp" )
RwField( name_ = "ovp" )
).add_field(
RwField( name = "ocp" )
RwField( name_ = "ocp" )
).add_field(
RwField( name = "silent" )
RwField( name_ = "silent" )
)

# === MISC ===
self.add_attribute(
Attribute( name = "misc", bypass_init_ensure = True )
Attribute( name_ = "misc", bypass_init_ensure = True )
)

if self.ensure:
Expand Down
16 changes: 8 additions & 8 deletions client/panduza/interfaces/dio.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ def __post_init__(self):

# === DIRECTION ===
self.add_attribute(
Attribute( name = "direction" )
Attribute( name_ = "direction" )
).add_field(
RwField( name = "value")
RwField( name_ = "value")
).add_field(
RwField( name = "pull")
RwField( name_ = "pull")
).add_field(
RwField( name = "polling_cycle")
RwField( name_ = "polling_cycle")
)

# === STATE ===
self.add_attribute(
Attribute( name = "state" )
Attribute( name_ = "state" )
).add_field(
RwField( name = "active" )
RwField( name_ = "active" )
).add_field(
RwField( name = "active_low" )
RwField( name_ = "active_low" )
).add_field(
RwField( name = "polling_cycle" )
RwField( name_ = "polling_cycle" )
)

if self.ensure:
Expand Down
3 changes: 3 additions & 0 deletions client/panduza/interfaces/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from .bpc import Bpc
from .ammeter import Ammeter

from .platform import Platform

from .relay import Relay
from .voltmeter import Voltmeter
from ..core.log import create_logger
Expand All @@ -21,6 +23,7 @@ def GenerateAllInterfacesFromAliases(connections):
"dio": Dio,
"bpc": Bpc,
"ammeter": Ammeter,
"platform": Platform,
"relay": Relay,
"voltmeter": Voltmeter
}
Expand Down
4 changes: 2 additions & 2 deletions client/panduza/interfaces/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def __post_init__(self):
# === MEASURE ===

self.add_attribute(
Attribute( name = "state" )
Attribute( name_ = "state" )
).add_field(
# true or false
RwField( name = "open" )
RwField( name_ = "open" )
)


Expand Down
6 changes: 3 additions & 3 deletions client/panduza/interfaces/voltmeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def __post_init__(self):

# === MEASURE ===
self.add_attribute(
Attribute( name = "measure" )
Attribute( name_ = "measure" )
).add_field(
RoField( name = "value" )
RoField( name_ = "value" )
).add_field(
RwField( name = "polling_cycle" )
RwField( name_ = "polling_cycle" )
)

if self.ensure:
Expand Down
2 changes: 2 additions & 0 deletions client/panduza/robof/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .client import KeywordsClient
from .bpc import KeywordsBpc
from .dio import KeywordsDio
from .platform import KeywordsPlatform
from .relay import KeywordsRelay
from .voltmeter import KeywordsVoltmeter

Expand All @@ -23,6 +24,7 @@ def __init__(self):
KeywordsAmmeter(),
KeywordsClient(),
KeywordsDio(),
KeywordsPlatform(),
KeywordsBpc(),
KeywordsRelay(),
KeywordsVoltmeter(),
Expand Down
22 changes: 22 additions & 0 deletions client/panduza/robof/platform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from panduza import Client, Platform

from robotlibcore import keyword
from robot.libraries.BuiltIn import BuiltIn

class KeywordsPlatform(object):

# ---

@keyword
def panduza_platform_load_dtree(self, platform_alias, dtree):
"""
"""
p = Platform(alias=platform_alias)
p.dtree.content.set(dtree)

# ---





16 changes: 14 additions & 2 deletions platform/tests/auto/benches/virtual/bench.resource
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
*** Settings ***

Library Collections
Library libraries.scan_checks
Library panduza.robof.Keywords

Library libraries.bench_helper
Library libraries.scan_checks

Variables bench_data.py

*** Keywords ***
Expand All @@ -12,4 +14,14 @@ Setup Bench Config
Set Log Level DEBUG
Log ${PZA_ALIASES}
Load Pza Interfaces From Aliases ${PZA_ALIASES}


Setup Bench Fake Interfaces
Set Log Level DEBUG
${PLATFORMS} Panduza Scan All Platforms localhost 1883
Log ${PLATFORMS}
Create test platform alias from scan ${PLATFORMS} test_platform
Panduza platform load dtree test_platform ${FAKE_INTERFACES_DTREE}
Sleep 1
Log ${PZA_ALIASES}
Load Pza Interfaces From Aliases ${PZA_ALIASES}

22 changes: 21 additions & 1 deletion platform/tests/auto/benches/virtual/bench_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@


FAKE_INTERFACES_DTREE={
"devices": [
{
"ref": "Panduza.FakeBps",
"settings": {
"number_of_channel": 2
}
}
]
}

PZA_ALIASES={

"local": {
"url": "localhost",
"port": 1883,
"interfaces": {
"fake_ammeter_0": "pza/default/Panduza_FakeBps/:channel_0:_am",
"fake_voltmeter_0": "pza/default/Panduza_FakeBps/:channel_0:_vm",
"fake_bpc_0": "pza/default/Panduza_FakeBps/:channel_0:_ctrl",
}
}
}


10 changes: 0 additions & 10 deletions platform/tests/auto/envs/dtree_fake.json

This file was deleted.

17 changes: 17 additions & 0 deletions platform/tests/auto/libraries/bench_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import json
from panduza import Core
from hamcrest import assert_that, has_length, has_key, equal_to

# ---

def create_test_platform_alias_from_scan(scan_json, alias_name):
topic = next(iter(scan_json.keys()))
platform_alias = {
"test_server": {
"url": "localhost", "port": 1883,
"interfaces": {
alias_name: topic
}
}
}
Core.LoadAliases(platform_alias)
19 changes: 11 additions & 8 deletions platform/tests/auto/tests/fake_interfaces.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ Documentation Tests fake interfaces
Metadata Author "XdoctorwhoZ"

Resource bench.resource
Suite Setup Setup Bench Config
Suite Setup Setup Bench Fake Interfaces




*** Test Cases ***

# Test Fake AmpereMeter interfaces
# Test Basic Access Of Ammeter Interface fake_ammeter_0
Test Fake AmpereMeter interfaces
Test Basic Access Of Ammeter Interface fake_ammeter_0

# Test Fake VoltMeter interfaces
# Test Basic Access Of VoltMeter Interface fake_voltmeter_0
Test Fake VoltMeter interfaces
Test Basic Access Of VoltMeter Interface fake_voltmeter_0

# Test Fake BPC interfaces
# Interface Bpc Basic Controls fake_bpc_0
# Interface Bpc Basic Controls fake_bpc_1
Test Fake BPC interfaces
Log "message"
Interface Bpc Basic Controls fake_bpc_0


0 comments on commit d1a1baf

Please sign in to comment.