mirror of
https://github.com/naruxde/revpimodio2.git
synced 2026-09-30 23:04:29 +02:00
test: Test replace_io file
This commit is contained in:
1 parent
24b50c2973
commit
d2d37f4972
10 files changed
+179
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
{"App":{"name": "PiCtory", "version": "1.2.3","saveTS": "20170826120906","language": "en","layout": {"north":{"size":70,"initClosed":false,"initHidden":false},"south":{"size":480,"initClosed":false,"initHidden":false,"children":{"layout1":{"east":{"size":500,"initClosed":false,"initHidden":false}}}},"east":{"size":70,"initClosed":true,"initHidden":false,"children":{"layout1":{"north":{"size":100,"initClosed":false,"initHidden":false},"south":{"size":98,"initClosed":false,"initHidden":false}}}},"west":{"size":200,"initClosed":false,"initHidden":false,"children":{"layout1":{}}}}},"Summary":{"inpTotal": 338,"outTotal": 113},"Devices":[{"catalogNr": "RevPiCore","GUID": "4ebb85e8-92ea-415d-b191-cc58c2857c0a","id": "device_RevPiCore_20170404_1_2_001","type": "BASE","productType": "95","position": "0","name": "picore01","bmk": "RevPi Core V1.2","inpVariant": 0,"outVariant": 0,"comment": "This is a RevPiCore Device","offset": 0,"inp": {"0": ["RevPiStatus","0","8","0",true,"0000", "",""],"1": ["RevPiIOCycle","0","8","1",true,"0001", "",""],"2": ["RS485ErrorCnt","0","16","2",false,"0002", "",""],"3": ["Core_Temperatur","0","8","4",false,"0003", "",""],"4": ["Core_Frequency","0","8","5",false,"0004", "",""]},"out": {"0": ["RevPiLED","0","8","6",true,"0005", "",""],"1": ["RS485ErrorLimit1","10","16","7",false,"0006", "",""],"2": ["RS485ErrorLimit2","1000","16","9",false,"0007", "",""]},"mem": {},"extend": {}},{"catalogNr": "RevPiDI","GUID": "2e2c089e-6bef-14c0-852b-41b7cf48d846","id": "device_RevPiDI_20160818_1_0_001","type": "LEFT_RIGHT","productType": "97","position": "32","name": "di01","bmk": "RevPi DI","inpVariant": 0,"outVariant": 0,"comment": "","offset": 11,"inp": {"0": ["notaus_ok","0","1","0",true,"0000", "","0"],"1": ["motorschutz_ok","0","1","0",true,"0001", "","1"],"2": ["fu_ok","0","1","0",true,"0002", "","2"],"3": ["fu_motoran","0","1","0",true,"0003", "","3"],"4": ["I_5","0","1","0",true,"0004", "","4"],"5": ["I_6","0","1","0",true,"0005", "","5"],"6": ["I_7","0","1","0",true,"0006", "","6"],"7": ["I_8","0","1","0",true,"0007", "","7"],"8": ["t_automatik","0","1","0",true,"0008", "","8"],"9": ["t_start","0","1","0",true,"0009", "","9"],"10": ["t_stop","0","1","0",true,"0010", "","10"],"11": ["t_quit","0","1","0",true,"0011", "","11"],"12": ["t_notaus","0","1","0",true,"0012", "","12"],"13": ["I_14","0","1","0",true,"0013", "","13"],"14": ["I_15","0","1","0",true,"0014", "","14"],"15": ["I_16","0","1","0",true,"0015", "","15"],"16": ["Status","0","16","4",false,"0016", "",""],"17": ["Counter_1","0","32","6",false,"0017", "",""],"18": ["Counter_2","0","32","10",false,"0018", "",""],"19": ["Counter_3","0","32","14",false,"0019", "",""],"20": ["Counter_4","0","32","18",false,"0020", "",""],"21": ["Counter_5","0","32","22",false,"0021", "",""],"22": ["Counter_6","0","32","26",false,"0022", "",""],"23": ["Counter_7","0","32","30",false,"0023", "",""],"24": ["Counter_8","0","32","34",false,"0024", "",""],"25": ["Counter_9","0","32","38",false,"0025", "",""],"26": ["Counter_10","0","32","42",false,"0026", "",""],"27": ["Counter_11","0","32","46",false,"0027", "",""],"28": ["Counter_12","0","32","50",false,"0028", "",""],"29": ["Counter_13","0","32","54",false,"0029", "",""],"30": ["Counter_14","0","32","58",false,"0030", "",""],"31": ["Counter_15","0","32","62",false,"0031", "",""],"32": ["Counter_16","0","32","66",false,"0032", "",""],"33": ["Output_Status","0","16","2",false,"0050", "",""]},"out": {"0": ["Output","0","16","70",false,"0051", "",""],"1": ["PWM_1","0","8","72",false,"0052", "",""],"2": ["PWM_2","0","8","73",false,"0053", "",""],"3": ["PWM_3","0","8","74",false,"0054", "",""],"4": ["PWM_4","0","8","75",false,"0055", "",""],"5": ["PWM_5","0","8","76",false,"0056", "",""],"6": ["PWM_6","0","8","77",false,"0057", "",""],"7": ["PWM_7","0","8","78",false,"0058", "",""],"8": ["PWM_8","0","8","79",false,"0059", "",""],"9": ["PWM_9","0","8","80",false,"0060", "",""],"10": ["PWM_10","0","8","81",false,"0061", "",""],"11": ["PWM_11","0","8","82",false,"0062", "",""],"12": ["PWM_12","0","8","83",false,"0063", "",""],"13": ["PWM_13","0","8","84",false,"0064", "",""],"14": ["PWM_14","0","8","85",false,"0065", "",""],"15": ["PWM_15","0","8","86",false,"0066", "",""],"16": ["PWM_16","0","8","87",false,"0067", "",""]},"mem": {"0": ["InputMode_1","0","8","88",false,"0033", "",""],"1": ["InputMode_2","0","8","89",false,"0034", "",""],"2": ["InputMode_3","0","8","90",false,"0035", "",""],"3": ["InputMode_4","0","8","91",false,"0036", "",""],"4": ["InputMode_5","0","8","92",false,"0037", "",""],"5": ["InputMode_6","0","8","93",false,"0038", "",""],"6": ["InputMode_7","0","8","94",false,"0039", "",""],"7": ["InputMode_8","0","8","95",false,"0040", "",""],"8": ["InputMode_9","0","8","96",false,"0041", "",""],"9": ["InputMode_10","0","8","97",false,"0042", "",""],"10": ["InputMode_11","0","8","98",false,"0043", "",""],"11": ["InputMode_12","0","8","99",false,"0044", "",""],"12": ["InputMode_13","0","8","100",false,"00Line truncated
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
[test1]
|
||||||
|
replace=Output_19
|
||||||
|
frm=b
|
||||||
|
defaultvalue=255
|
||||||
|
byteorder=big
|
||||||
|
|
||||||
|
[r_bit0]
|
||||||
|
replace=Output_20
|
||||||
|
bmk=EinBit
|
||||||
|
frm=?
|
||||||
|
bit=0
|
||||||
|
|
||||||
|
[r_bit1]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=1
|
||||||
|
defaultvalue=True
|
||||||
|
|
||||||
|
[r_bit5]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=5
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[data_values]
|
||||||
|
replace = I_LiftData
|
||||||
|
frm = 200s
|
||||||
|
defaultvalue = 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[data_values]
|
||||||
|
replace = I_LiftData
|
||||||
|
frm = 200s
|
||||||
|
defaultvalue = 255 0 0 0 0 a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[test1]
|
||||||
|
replace=Output_19
|
||||||
|
frm=h
|
||||||
|
|
||||||
|
[r_bit0]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=0
|
||||||
|
|
||||||
|
[r_bit1]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=1
|
||||||
|
defaultvalue=True
|
||||||
|
|
||||||
|
[r_bit5]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=5
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[test1]
|
||||||
|
replace=Output_19
|
||||||
|
frm=b
|
||||||
|
|
||||||
|
[r_bit0]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=True
|
||||||
|
|
||||||
|
[r_bit1]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=1
|
||||||
|
defaultvalue=True
|
||||||
|
|
||||||
|
[r_bit5]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=5
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[test1]
|
||||||
|
replace=Output_19
|
||||||
|
frm=c
|
||||||
|
|
||||||
|
[r_bit0]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=0
|
||||||
|
|
||||||
|
[r_bit1]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=1
|
||||||
|
defaultvalue=komisch
|
||||||
|
|
||||||
|
[r_bit5]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=5
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
[test1]
|
||||||
|
replace=Output_19
|
||||||
|
frm=c
|
||||||
|
defaultvalue=True
|
||||||
|
|
||||||
|
[r_bit0]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=0
|
||||||
|
|
||||||
|
[r_bit1]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=1
|
||||||
|
defaultvalue=True
|
||||||
|
|
||||||
|
[r_bit5]
|
||||||
|
replace=Output_20
|
||||||
|
frm=?
|
||||||
|
bit=5
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
[test1
|
||||||
|
replace=Output_19
|
||||||
|
frm h
|
||||||
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""Tests for replace io file."""
|
||||||
|
__author__ = "Sven Sager"
|
||||||
|
__copyright__ = "Copyright (C) 2024 Sven Sager"
|
||||||
|
__license__ = "GPLv2"
|
||||||
|
|
||||||
|
from os.path import join, dirname
|
||||||
|
|
||||||
|
from tests import TestRevPiModIO
|
||||||
|
|
||||||
|
|
||||||
|
class TestReplaceIO(TestRevPiModIO):
|
||||||
|
|
||||||
|
data_dir = dirname(__file__)
|
||||||
|
|
||||||
|
def test_replace_io_file(self):
|
||||||
|
replace_io_file = join(self.data_dir, "replace_io.conf")
|
||||||
|
rpi = self.modio(replace_io_file=replace_io_file)
|
||||||
|
self.assertEqual(rpi.replace_io_file, replace_io_file)
|
||||||
|
rpi.setdefaultvalues()
|
||||||
|
self.assertEqual(rpi.io.test1.value, -1)
|
||||||
|
self.assertFalse(rpi.io.r_bit0.value)
|
||||||
|
self.assertTrue(rpi.io.r_bit1.value)
|
||||||
|
self.assertFalse(rpi.io.r_bit5.value)
|
||||||
|
self.assertFalse("Output_19" in rpi.io)
|
||||||
|
|
||||||
|
self.assertEqual(rpi.io.test1.byteorder, "big")
|
||||||
|
self.assertEqual(rpi.io.r_bit0.byteorder, "little")
|
||||||
|
|
||||||
|
self.assertEqual(rpi.io.r_bit0.bmk, "EinBit")
|
||||||
|
|
||||||
|
with self.assertRaises(RuntimeError):
|
||||||
|
rpi.export_replaced_ios("/gehtnich/replace_io.conf")
|
||||||
|
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
rpi.io.test1.export = 1
|
||||||
|
rpi.io.test1.export = True
|
||||||
|
rpi.io.Input_20.replace_io("byte_test", "3s", defaultvalue=b"\xff\x00\x80", export=True)
|
||||||
|
rpi.export_replaced_ios("/tmp/replace_io.conf")
|
||||||
|
del rpi
|
||||||
|
|
||||||
|
rpi = self.modio(replace_io_file="/tmp/replace_io.conf")
|
||||||
|
self.assertTrue(rpi.io.test1.export)
|
||||||
|
self.assertTrue(rpi.io.byte_test.export)
|
||||||
|
self.assertEqual(rpi.io.byte_test.defaultvalue, b"\xff\x00\x80")
|
||||||
|
|
||||||
|
def test_fb_replace_io_fail(self):
|
||||||
|
with self.assertRaises(RuntimeError):
|
||||||
|
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_fail.conf"))
|
||||||
|
with self.assertRaises(RuntimeError):
|
||||||
|
rpi = self.modio(replace_io_file="no_file_nonono")
|
||||||
|
with self.assertRaises(RuntimeError):
|
||||||
|
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_failformat.conf"))
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
rpi = self.modio(
|
||||||
|
replace_io_file=join(self.data_dir, "replace_io_faildefaultvalue_bool.conf")
|
||||||
|
)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
rpi = self.modio(
|
||||||
|
replace_io_file=join(self.data_dir, "replace_io_faildefaultvalue_int.conf")
|
||||||
|
)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_failbit_int.conf"))
|
||||||
|
with self.assertRaisesRegex(ValueError, r"defaultvalue to bytes"):
|
||||||
|
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_bytes_fail.conf"))
|
||||||
Reference in new issue
Block a user