2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

00_ElsnerWS: prototypes removed

git-svn-id: https://svn.fhem.de/fhem/trunk@28917 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
klaus.schauer 2024-05-27 16:26:19 +00:00
parent 8ab2611ce9
commit 040c414680

View File

@ -9,13 +9,13 @@ use warnings;
use DevIo; use DevIo;
use Time::HiRes qw(gettimeofday usleep); use Time::HiRes qw(gettimeofday usleep);
sub ElsnerWS_Checksum($$); sub ElsnerWS_Checksum;
sub ElsnerWS_Define($$$); sub ElsnerWS_Define;
sub ElsnerWS_Delete($$); sub ElsnerWS_Delete;
sub ElsnerWS_Initialize($); sub ElsnerWS_Initialize;
sub ElsnerWS_Read($); sub ElsnerWS_Read;
sub ElsnerWS_Ready($); sub ElsnerWS_Ready;
sub ElsnerWS_Shutdown($); sub ElsnerWS_Shutdown;
# trigger values for down and up commands # trigger values for down and up commands
my %customCmdTrigger = ('dayNight' => ['night', 'day'], my %customCmdTrigger = ('dayNight' => ['night', 'day'],
@ -35,7 +35,7 @@ my %customCmdPeriod =(once => -1,
my %specials; my %specials;
# Init # Init
sub ElsnerWS_Initialize($) { sub ElsnerWS_Initialize {
my ($hash) = @_; my ($hash) = @_;
# Provider # Provider
@ -67,7 +67,7 @@ sub ElsnerWS_Initialize($) {
} }
# Define # Define
sub ElsnerWS_Define($$$) { sub ElsnerWS_Define {
my ($hash, $a, $h) = @_; my ($hash, $a, $h) = @_;
my $name = $a->[0]; my $name = $a->[0];
#return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS {devicename[\@baudrate]|ip:port}" if($#$a != 2); #return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS {devicename[\@baudrate]|ip:port}" if($#$a != 2);
@ -76,17 +76,17 @@ sub ElsnerWS_Define($$$) {
} elsif (exists $h->{comtype}) { } elsif (exists $h->{comtype}) {
$hash->{ComType} = $h->{comtype}; $hash->{ComType} = $h->{comtype};
} else { } else {
return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS [comtype=](rs485) [devicename=]{devicename[\@baudrate]|ip:port}"; return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS [comtype=]rs485 [devicename=]{devicename[\@baudrate]|ip:port}";
} }
if ($hash->{ComType} ne 'rs485') { if ($hash->{ComType} ne 'rs485') {
return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS [comtype=](rs485) [devicename=]{devicename[\@baudrate]|ip:port}"; return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS [comtype=]rs485 [devicename=]{devicename[\@baudrate]|ip:port}";
} }
if (defined $a->[3]) { if (defined $a->[3]) {
$hash->{DeviceName} = $a->[3]; $hash->{DeviceName} = $a->[3];
} elsif (exists $h->{devicename}) { } elsif (exists $h->{devicename}) {
$hash->{DeviceName} = $h->{devicename}; $hash->{DeviceName} = $h->{devicename};
} else { } else {
return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS [comtype=](rs485|modbus) [devicename=]{devicename[\@baudrate]|ip:port}"; return "ElsnerWS: wrong syntax, correct is: define <name> ElsnerWS [comtype=](rs485) [devicename=]{devicename[\@baudrate]|ip:port}";
} }
$hash->{NOTIFYDEV} = "global"; $hash->{NOTIFYDEV} = "global";
my ($autocreateFilelog, $autocreateHash, $autocreateName, $autocreateDeviceRoom, $autocreateWeblinkRoom) = my ($autocreateFilelog, $autocreateHash, $autocreateName, $autocreateDeviceRoom, $autocreateWeblinkRoom) =
@ -162,7 +162,7 @@ sub ElsnerWS_Define($$$) {
} }
# Initialize serial communication # Initialize serial communication
sub ElsnerWS_InitSerialCom($) { sub ElsnerWS_InitSerialCom {
# return if attribute list is incomplete # return if attribute list is incomplete
#return undef if (!$init_done); #return undef if (!$init_done);
my ($hash) = @_; my ($hash) = @_;
@ -177,7 +177,7 @@ sub ElsnerWS_InitSerialCom($) {
return undef; return undef;
} }
sub ElsnerWS_Checksum($$) { sub ElsnerWS_Checksum {
my ($packetType, $msg) = @_; my ($packetType, $msg) = @_;
$msg = $packetType . $msg; $msg = $packetType . $msg;
my $ml = length($msg); my $ml = length($msg);
@ -190,7 +190,7 @@ sub ElsnerWS_Checksum($$) {
# Read # Read
# called from the global loop, when the select for hash->{FD} reports data # called from the global loop, when the select for hash->{FD} reports data
sub ElsnerWS_Read($) { sub ElsnerWS_Read {
my ($hash) = @_; my ($hash) = @_;
my $buf = DevIo_SimpleRead($hash); my $buf = DevIo_SimpleRead($hash);
return "" if(!defined($buf)); return "" if(!defined($buf));
@ -509,7 +509,7 @@ sub ElsnerWS_Read($) {
return; return;
} }
sub ElsnerWS_CustomCmdDoTrigger($$$$$) { sub ElsnerWS_CustomCmdDoTrigger {
# set do trigger # set do trigger
my ($hash, $customCmdName, $customCmdVal, $customCmdTrigger, $element) = @_; my ($hash, $customCmdName, $customCmdVal, $customCmdTrigger, $element) = @_;
my $readingName; my $readingName;
@ -547,7 +547,7 @@ sub ElsnerWS_CustomCmdDoTrigger($$$$$) {
return; return;
} }
sub ElsnerWS_CustomCmdDo($$$$) { sub ElsnerWS_CustomCmdDo {
my ($hash, $customCmdName, $customCmd, $customCmdPeriod) = @_; my ($hash, $customCmdName, $customCmd, $customCmdPeriod) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
#Log3 $name, 3, "ElsnerWS $name $customCmdName do: $hash->{helper}{$customCmdName}{do} Count: $hash->{helper}{$customCmdName}{Count}"; #Log3 $name, 3, "ElsnerWS $name $customCmdName do: $hash->{helper}{$customCmdName}{do} Count: $hash->{helper}{$customCmdName}{Count}";
@ -584,7 +584,7 @@ sub ElsnerWS_CustomCmdDo($$$$) {
return; return;
} }
sub ElsnerWS_AlarmOn($) { sub ElsnerWS_AlarmOn {
my ($readingParam) = @_; my ($readingParam) = @_;
my ($hash, $readingName, $readingVal, $ctrl, $log, $clear) = @$readingParam; my ($hash, $readingName, $readingVal, $ctrl, $log, $clear) = @$readingParam;
if (defined $hash) { if (defined $hash) {
@ -600,7 +600,7 @@ sub ElsnerWS_AlarmOn($) {
return; return;
} }
sub ElsnerWS_updateArrayElement($$$$$) { sub ElsnerWS_updateArrayElement {
# read und update values to array # read und update values to array
my ($hash, $readingName, $readingVal, $arrayName, $numArrayElementsMax) = @_; my ($hash, $readingName, $readingVal, $arrayName, $numArrayElementsMax) = @_;
my $numArrayElements = $#{$hash->{helper}{$arrayName}{$readingName}{val}}; my $numArrayElements = $#{$hash->{helper}{$arrayName}{$readingName}{val}};
@ -616,7 +616,7 @@ sub ElsnerWS_updateArrayElement($$$$$) {
return $numArrayElements; return $numArrayElements;
} }
sub ElsnerWS_SMA($$$$$$$$) { sub ElsnerWS_SMA {
# simple moving average (SMA) # simple moving average (SMA)
my ($hash, $readingName, $readingVal, $averageName, $valMaxName, $valMinName, $arrayName, $numArrayElementsCalc) = @_; my ($hash, $readingName, $readingVal, $averageName, $valMaxName, $valMinName, $arrayName, $numArrayElementsCalc) = @_;
my $average = exists($hash->{helper}{$arrayName}{$readingName}{average}) ? $hash->{helper}{$arrayName}{$readingName}{average} : $readingVal; my $average = exists($hash->{helper}{$arrayName}{$readingName}{average}) ? $hash->{helper}{$arrayName}{$readingName}{average} : $readingVal;
@ -638,7 +638,7 @@ sub ElsnerWS_SMA($$$$$$$$) {
return ($average, $valMin, $valMax); return ($average, $valMin, $valMax);
} }
sub ElsnerWS_LWMA($$$$) { sub ElsnerWS_LWMA {
# linear weighted moving average (LWMA) # linear weighted moving average (LWMA)
my ($hash, $readingName, $readingVal, $numArrayElementsMax) = @_; my ($hash, $readingName, $readingVal, $numArrayElementsMax) = @_;
push(@{$hash->{helper}{lwma}{$readingName}{val}}, $readingVal); push(@{$hash->{helper}{lwma}{$readingName}{val}}, $readingVal);
@ -654,7 +654,7 @@ sub ElsnerWS_LWMA($$$$) {
return $average; return $average;
} }
sub ElsnerWS_EMA($$$$) { sub ElsnerWS_EMA {
# exponential moving average (EMA) # exponential moving average (EMA)
# 0 < $wheight < 1 # 0 < $wheight < 1
my ($hash, $readingName, $readingVal, $wheight) = @_; my ($hash, $readingName, $readingVal, $wheight) = @_;
@ -664,7 +664,7 @@ sub ElsnerWS_EMA($$$$) {
return $average; return $average;
} }
sub ElsnerWS_Smooting($$$$$) { sub ElsnerWS_Smooting {
my ($hash, $readingName, $readingVal, $theshold, $averageParam) = @_; my ($hash, $readingName, $readingVal, $theshold, $averageParam) = @_;
my $iniVal; my $iniVal;
$readingVal = ElsnerWS_EMA($hash, $readingName, $readingVal, $averageParam) if (defined $averageParam); $readingVal = ElsnerWS_EMA($hash, $readingName, $readingVal, $averageParam) if (defined $averageParam);
@ -682,7 +682,7 @@ sub ElsnerWS_Smooting($$$$$) {
return $iniVal; return $iniVal;
} }
sub ElsnerWS_swayCtrl($$$$$$$$$$$) { sub ElsnerWS_swayCtrl {
# sway range and delay calculation # sway range and delay calculation
my ($hash, $readingName, $readingVal, $attrNameRange, $attrNameDelay, $swayRangeLow, $swayRangeHigh, $swayDelayLow, $swayDelayHigh, $swayRangeLowVal, $swayRangeHighVal) = @_; my ($hash, $readingName, $readingVal, $attrNameRange, $attrNameDelay, $swayRangeLow, $swayRangeHigh, $swayDelayLow, $swayDelayHigh, $swayRangeLowVal, $swayRangeHighVal) = @_;
my ($swayRangeLowAttr, $swayRangeHighAttr) = split(':', AttrVal($hash->{NAME}, $attrNameRange, "$swayRangeLow:$swayRangeHigh")); my ($swayRangeLowAttr, $swayRangeHighAttr) = split(':', AttrVal($hash->{NAME}, $attrNameRange, "$swayRangeLow:$swayRangeHigh"));
@ -748,7 +748,7 @@ sub ElsnerWS_swayCtrl($$$$$$$$$$$) {
return $swayVal; return $swayVal;
} }
sub ElsnerWS_swayCtrlDelay($) { sub ElsnerWS_swayCtrlDelay {
my ($readingParam) = @_; my ($readingParam) = @_;
my ($hash, $readingName, $readingVal, $delay, $ctrl, $log, $clear) = @$readingParam; my ($hash, $readingName, $readingVal, $delay, $ctrl, $log, $clear) = @$readingParam;
if (defined $hash) { if (defined $hash) {
@ -760,7 +760,7 @@ sub ElsnerWS_swayCtrlDelay($) {
return; return;
} }
sub ElsnerWS_readingsSingleUpdate($) { sub ElsnerWS_readingsSingleUpdate {
my ($readingParam) = @_; my ($readingParam) = @_;
my ($hash, $readingName, $readingVal, $ctrl, $log, $clear) = @$readingParam; my ($hash, $readingName, $readingVal, $ctrl, $log, $clear) = @$readingParam;
if (defined $hash) { if (defined $hash) {
@ -770,7 +770,7 @@ sub ElsnerWS_readingsSingleUpdate($) {
return; return;
} }
sub ElsnerWS_readingsBulkUpdate($$$$$$) { sub ElsnerWS_readingsBulkUpdate {
my ($hash, $readingName, $readingVal, $theshold, $averageParam, $sFormat) = @_; my ($hash, $readingName, $readingVal, $theshold, $averageParam, $sFormat) = @_;
if (exists $hash->{helper}{timer}{heartbeat}) { if (exists $hash->{helper}{timer}{heartbeat}) {
$readingVal = sprintf("$sFormat", ElsnerWS_Smooting($hash, $readingName, $readingVal, $theshold, $averageParam)); $readingVal = sprintf("$sFormat", ElsnerWS_Smooting($hash, $readingName, $readingVal, $theshold, $averageParam));
@ -783,7 +783,7 @@ sub ElsnerWS_readingsBulkUpdate($$$$$$) {
} }
# #
sub ElsnerWS_cdmClearTimer($) { sub ElsnerWS_cdmClearTimer {
my ($functionArray) = @_; my ($functionArray) = @_;
my ($hash, $timer) = @$functionArray; my ($hash, $timer) = @$functionArray;
delete $hash->{helper}{timer}{$timer}; delete $hash->{helper}{timer}{$timer};
@ -792,7 +792,7 @@ sub ElsnerWS_cdmClearTimer($) {
} }
# Ready # Ready
sub ElsnerWS_Ready($) { sub ElsnerWS_Ready {
my ($hash) = @_; my ($hash) = @_;
return DevIo_OpenDev($hash, 1, undef) if($hash->{STATE} eq "disconnected"); return DevIo_OpenDev($hash, 1, undef) if($hash->{STATE} eq "disconnected");
# This is relevant for windows/USB only # This is relevant for windows/USB only
@ -803,7 +803,7 @@ sub ElsnerWS_Ready($) {
} }
# Attributes check # Attributes check
sub ElsnerWS_Attr(@) { sub ElsnerWS_Attr {
my ($cmd, $name, $attrName, $attrVal) = @_; my ($cmd, $name, $attrName, $attrVal) = @_;
my $hash = $defs{$name}; my $hash = $defs{$name};
# return if attribute list is incomplete # return if attribute list is incomplete
@ -938,7 +938,7 @@ sub ElsnerWS_Attr(@) {
} }
# Notify actions # Notify actions
sub ElsnerWS_Notify(@) { sub ElsnerWS_Notify {
my ($hash, $dev) = @_; my ($hash, $dev) = @_;
return "" if (IsDisabled($hash->{NAME})); return "" if (IsDisabled($hash->{NAME}));
if ($dev->{NAME} eq "global" && grep (m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})) { if ($dev->{NAME} eq "global" && grep (m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})) {
@ -948,14 +948,14 @@ sub ElsnerWS_Notify(@) {
} }
# Undef # Undef
sub ElsnerWS_Undef($$) { sub ElsnerWS_Undef {
my ($hash, $arg) = @_; my ($hash, $arg) = @_;
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
return undef; return undef;
} }
# Delete # Delete
sub ElsnerWS_Delete($$) { sub ElsnerWS_Delete {
my ($hash, $name) = @_; my ($hash, $name) = @_;
my $logName = "FileLog_$name"; my $logName = "FileLog_$name";
my ($count, $gplotFile, $logFile, $weblinkName, $weblinkHash); my ($count, $gplotFile, $logFile, $weblinkName, $weblinkHash);
@ -984,7 +984,7 @@ sub ElsnerWS_Delete($$) {
} }
# Shutdown # Shutdown
sub ElsnerWS_Shutdown($) { sub ElsnerWS_Shutdown {
my ($hash) = @_; my ($hash) = @_;
DevIo_CloseDev($hash); DevIo_CloseDev($hash);
return undef; return undef;