smich123 / open-zwave

Automatically exported from code.google.com/p/open-zwave
0 stars 0 forks source link

Basic class mapping is not saved #166

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start OZW with a fresh zwcfg
2. After the new node is found Node::SetDeviceClasses will call cc->SetMapping( 
basicMapping ) and thereby initialize the mapping between the basic command 
class and the associated class
3. CommandClass::SetValueBasic will work as desired in both directions
4. Shutdown and Restart OWZ
5. Basic mapping won't work

What version of the product are you using? On what operating system?
OZW trunk

Please include the file OZW_Log.txt from your program. Make sure the file
zwcfg*.xml is NOT present.

Please provide any additional information below.
This is due to CommandClass::m_basicMapped and Basic::m_mapping not being saved 
during shutdown and reloaded after a new start.

Original issue reported on code.google.com by matthias...@googlemail.com on 24 Jan 2013 at 9:10

GoogleCodeExporter commented 9 years ago
Attached is a patch which remedies this by saving the values in WriteXML and 
reloads them in ReadXML.
However I don't know if that's the correct approach, so please review it.

Original comment by matthias...@googlemail.com on 24 Jan 2013 at 9:12

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in r638.

Original comment by glsatz on 10 Feb 2013 at 6:51

GoogleCodeExporter commented 9 years ago
Thank you!
But unfortunatly it doesn't work yet. The mapping is saved but not loaded.
The problem is that the Basic Class loads the mapping and calls SetMapping.
Then SetMapping searches for the mapped command class, but this does not exist 
at the time the basic class is loaded/created. So nothing happens :-(
So we should either wait until the whole node was loaded before calling 
SetMapping or store and load the mapping in both classes like in my patch.

Original comment by matthias...@googlemail.com on 10 Feb 2013 at 2:18

GoogleCodeExporter commented 9 years ago
Another alternative is to look up if the current class is basic mapped in the 
CommandClass::ReadXML like this. However it works only if we are sure that all 
other command classes are stored after basic in the XML. Also m_mapping would 
have to be set in Basic::ReadXML without checking that the mapped Class really 
exists.

if( this->GetCommandClassId() != NoOperation::StaticGetCommandClassId()  && 
this->GetCommandClassId() != Basic::StaticGetCommandClassId())
{
    if( Node const* node = GetNodeUnsafe() )
    {
        if( CommandClass* cc = node->GetCommandClass( Basic::StaticGetCommandClassId() ) )
        {
            if (cc == NULL) return;
            if (((Basic*)cc)->GetMapping() == GetCommandClassId()) SetBasicMapped( true );
        }
    }
}

Original comment by matthias...@googlemail.com on 10 Feb 2013 at 3:05

GoogleCodeExporter commented 9 years ago

Original comment by glsatz on 10 Feb 2013 at 4:54

GoogleCodeExporter commented 9 years ago
How about we save the BASIC class xml at the end of the list of xml command 
classes? This cleans up lots of code and we just have to document this behavior?

Original comment by glsatz on 10 Feb 2013 at 4:55

GoogleCodeExporter commented 9 years ago
For me this is also fine if this helps with this problem and maybe also others.
But you and others know the internals of OZW much better than me and should 
take this decision. I have not looked in detail about how nodes and command 
classes are discovered, created, loaded and saved.
Are there any special cases like devices that do not provide a basic command 
class at all? If yes then this also has to be considered.

Original comment by matthias...@googlemail.com on 11 Feb 2013 at 8:50

GoogleCodeExporter commented 9 years ago
The mapping has been simplified to only map from BASIC to the mapped class. 
This makes the order of saving the output unnecessary. Give the latest 
repository version a try, please.

Original comment by glsatz on 15 Feb 2013 at 5:27

GoogleCodeExporter commented 9 years ago
Hi!

I think I'm experiencing an issue linked to this one - since the implementation 
of the BASIC class has been changed some of the helper methods like SetNodeOn 
and SetNodeOff are not working (r645 for instance).

I checked the xml configuration file, and I can see some mapping, but the 
helper methods never work: not at first launch, and not after a restart of the 
application.

On the contrary SwitchAllOn and SwitchAllOff are working (my app now crashes 
after executing the command, however). Is there something specific I should 
know.

Cheers,
Didier

Original comment by didier.d...@gmail.com on 12 Mar 2013 at 7:02

GoogleCodeExporter commented 9 years ago

Original comment by glsatz on 15 Apr 2013 at 2:25