1
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-04 22:19:38 +00:00
fhem-mirror/t/FHEM/98_Modbus/50_MasterSlave1.t
StefanStrobel 1901729367 98_Modbus: update Tests
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@23942 2b470e98-0d58-463d-a4d8-8e2adae1ed80
2021-03-13 10:12:36 +00:00

59 lines
1.7 KiB
Perl

##############################################
# test master slave with setexpr
##############################################
package main;
use strict;
use warnings;
use Test::More;
use Time::HiRes qw( gettimeofday tv_interval); # return time as float, not just full seconds
use FHEM::HTTPMOD::Utils qw(:all);
use FHEM::Modbus::TestUtils qw(:all);
fhem 'attr global mseclog 1';
NextStep();
sub testStep1 { # preparation of slave content, enable devices
is(FhemTestUtils_gotLog('attribute'), 0, "no unknown attributes"); # logs during init are not collected.
LogStep "enable Master and set value at Slave";
fhem ('attr Master disable 0');
fhem ('attr Master obj-h258-setExpr $val * 3');
fhem ('setreading Slave TempWasserEin 12');
return 0.1;
}
sub testStep10 { # set with setexpr
fhem ('attr Slave obj-h258-allowWrite 1');
fhem ('attr Master obj-h258-setexpr $val * 2');
fhem ('set Master TempWasserAus 20');
return 0.1;
}
sub testStep11 { # check that write holding register did work
LogStep "check result";
is(FhemTestUtils_gotEvent(qr/Slave:TempWasserAus:\s40/xms), 1, "Write value to local slave");
return 0.1;
}
sub setExprSub {
my $val = shift;
return $val * 3;
}
sub testStep20 {
fhem ('attr Slave obj-h258-allowWrite 1');
fhem ('attr Master obj-h258-setexpr setExprSub ($val)');
fhem ('attr Master verbose 5');
fhem ('set Master TempWasserAus 20');
return 0.1;
}
sub testStep21 { # check that write holding register did work
LogStep "check result";
is(FhemTestUtils_gotEvent(qr/Slave:TempWasserAus:\s60/xms), 1, "Write value to local slave");
return 0.1;
}
1;