From a5197514ffa3329cd3f6d5962c2acf2b9ac3714c Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 24 Apr 2014 19:16:01 +0000 Subject: [PATCH] fhem.pl: Interface changes by Boris (Forum #22839) git-svn-id: https://svn.fhem.de/fhem/trunk@5632 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 157 ++++----------------------------------------------- 1 file changed, 11 insertions(+), 146 deletions(-) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 6822376f1..8e3883193 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -95,7 +95,6 @@ sub attrSplit($); sub computeClientArray($$); sub concatc($$$); sub configDBUsed(); -sub createInterfaceDefinitions(); sub createNtfyHash(); sub devspec2array($); sub doGlobalDef($); @@ -108,12 +107,6 @@ sub fhemTzOffset($); sub getAllAttr($); sub getAllGets($); sub getAllSets($); -sub getGetters($); -sub getGettersForInterface($); -sub getInterfaces($); -sub getReadingsForInterface($); -sub getSetters($); -sub getSettersForInterface($); sub latin1ToUtf8($); sub myrename($$); sub notifyRegexpChanged($$); @@ -207,7 +200,6 @@ use vars qw(%defaultattr); # Default attributes, used by FHEM2FHEM use vars qw(%defs); # FHEM device/button definitions use vars qw(%inform); # Used by telnet_ActivateInform use vars qw(%intAt); # Internal at timer hash, global for benchmark -use vars qw(%interfaces); # see createInterfaceDefinitions below use vars qw(%modules); # List of loaded modules (device/log/etc) use vars qw(%ntfyHash); # hash of devices needed to be notified. use vars qw(%oldvalue); # Old values, see commandref.html @@ -399,6 +391,14 @@ if($^O =~ m/Win/) { } $winService ||= {}; +################################################### +# initialize the readings semantics meta information +# this must come before any module is loaded +eval { # make errors non-lethal + require FHEM::RTypes; + RTypes_Initialize(); +}; + ################################################### # Server initialization doGlobalDef($ARGV[0]); @@ -468,9 +468,6 @@ if($pfn) { close(PID); } -# create the global interface definitions -createInterfaceDefinitions(); - my $gp = $attr{global}{port}; if($gp) { Log 3, "Converting 'attr global port $gp' to 'define telnetPort telnet $gp'"; @@ -490,6 +487,9 @@ foreach my $d (keys %defs) { delete $defs{$d}{IODevMissing}; } } + +RTypes_ShowTypeLibrary(); + DoTrigger("global", "INITIALIZED", 1); $fhem_started = time; @@ -3320,147 +3320,12 @@ addEvent($$) push(@{$hash->{CHANGED}}, $event); } -################################################################ -# -# Meta-information for devices -# This part maintained by Boris Neubert omega at online dot de -# -################################################################ - - -# get the names of interfaces for the device represented by the $hash -# empty list is returned if interfaces are not defined -sub -getInterfaces($) { - my ($hash)= @_; - #Debug "getInterfaces(" . $hash->{NAME} .")= ".$hash->{internals}{interfaces}; - if(defined($hash->{internals}{interfaces})) { - return split(/:/, $hash->{internals}{interfaces}); - } else { - return (); - } -} - -# get the names of the setters for a named interface -# empty list is returned if interface is not defined -sub -getSettersForInterface($) { - my $interface= shift; - if(defined($interface)) { - return split /:/, $interfaces{$interface}{setters}; - } else { - return (); - } -} - -# get the names of the getters for a named interface -# empty list is returned if interface is not defined -sub -getGettersForInterface($) { - my $interface= shift; - if(defined($interface)) { - return split /:/, $interfaces{$interface}{getters}; - } else { - return (); - } -} - -# get the names of the readings for a named interface -# empty list is returned if interface is not defined -sub -getReadingsForInterface($) { - my $interface= shift; - if(defined($interface)) { - return split /:/, $interfaces{$interface}{readings}; - } else { - return (); - } -} - -# get the names of the setters for the device represented by the $hash -# empty list is returned if interfaces are not defined -sub -getSetters($) { - my ($hash)= @_; - my ($interface, @setters); - #Debug "getSetters..."; - foreach $interface (getInterfaces($hash)) { - #Debug "Interface $interface"; - push @setters, getSettersForInterface($interface); - } - return @setters; -} - -# get the names of the getters for the device represented by the $hash -# empty list is returned if interfaces are not defined -sub -getGetters($) { - my ($hash)= @_; - my @getters; - my $interface; - foreach $interface (getInterfaces($hash)) { - push @getters, getGettersForInterface($interface); - } - return @getters; -} - sub concatc($$$) { my ($separator,$a,$b)= @_;; return($a && $b ? $a . $separator . $b : $a . $b); } - -# this creates the standard interface definitions as in -# http://fhemwiki.de/wiki/DevelopmentInterfaces -sub -createInterfaceDefinitions() { - - #Log 2, "Creating interface definitions..."; - # The interfaces list below consists of lines with the - # pipe-separated parts - # - name - # - ancestor - # - colon separated list of readings - # - colon-separated list of getters - # - colon-separated list of setters - # If no getters are listed they are considered identical - # to the readings. - # Ancestors must be listed before descendants. - # Two interfaces can share a subset of readings, getters and setters - # if and only if one interface is the ancestor of the other. - my $IDefs= <