----------------------------------------------------------------------------- Write ourselves to an XML document -----------------------------------------------------------------------------
| 842 | // Write ourselves to an XML document |
| 843 | //----------------------------------------------------------------------------- |
| 844 | void Driver::WriteCache |
| 845 | ( |
| 846 | ) |
| 847 | { |
| 848 | char str[32]; |
| 849 | |
| 850 | if (!m_homeId) { |
| 851 | Log::Write( LogLevel_Warning, "WARNING: Tried to write driver config with no home ID set"); |
| 852 | return; |
| 853 | } |
| 854 | Log::Write(LogLevel_Info, "Saving Cache"); |
| 855 | // Create a new XML document to contain the driver configuration |
| 856 | TiXmlDocument doc; |
| 857 | TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "utf-8", "" ); |
| 858 | TiXmlElement* driverElement = new TiXmlElement( "Driver" ); |
| 859 | doc.LinkEndChild( decl ); |
| 860 | doc.LinkEndChild( driverElement ); |
| 861 | |
| 862 | driverElement->SetAttribute( "xmlns", "https://github.com/OpenZWave/open-zwave" ); |
| 863 | |
| 864 | snprintf( str, sizeof(str), "%d", c_configVersion ); |
| 865 | driverElement->SetAttribute( "version", str ); |
| 866 | |
| 867 | snprintf( str, sizeof(str), "%d", GetManufacturerSpecificDB()->getRevision()); |
| 868 | driverElement->SetAttribute( "revision", str); |
| 869 | |
| 870 | snprintf( str, sizeof(str), "0x%.8x", m_homeId ); |
| 871 | driverElement->SetAttribute( "home_id", str ); |
| 872 | |
| 873 | snprintf( str, sizeof(str), "%d", m_Controller_nodeId ); |
| 874 | driverElement->SetAttribute( "node_id", str ); |
| 875 | |
| 876 | snprintf( str, sizeof(str), "%d", m_initCaps ); |
| 877 | driverElement->SetAttribute( "api_capabilities", str ); |
| 878 | |
| 879 | snprintf( str, sizeof(str), "%d", m_controllerCaps ); |
| 880 | driverElement->SetAttribute( "controller_capabilities", str ); |
| 881 | |
| 882 | snprintf( str, sizeof(str), "%d", m_pollInterval ); |
| 883 | driverElement->SetAttribute( "poll_interval", str ); |
| 884 | |
| 885 | snprintf( str, sizeof(str), "%s", m_bIntervalBetweenPolls ? "true" : "false" ); |
| 886 | driverElement->SetAttribute( "poll_interval_between", str ); |
| 887 | |
| 888 | { |
| 889 | LockGuard LG(m_nodeMutex); |
| 890 | |
| 891 | for( int i=0; i<256; ++i ) |
| 892 | { |
| 893 | if( m_nodes[i] ) |
| 894 | { |
| 895 | if (m_nodes[i]->GetCurrentQueryStage() == Node::QueryStage_Complete) { |
| 896 | m_nodes[i]->WriteXML( driverElement ); |
| 897 | Log::Write(LogLevel_Info, i, "Cache Save for Node %d as its QueryStage_Complete", i); |
| 898 | } else { |
| 899 | Log::Write(LogLevel_Info, i, "Skipping Cache Save for Node %d as its not QueryStage_Complete", i); |
| 900 | } |
| 901 | } |
no test coverage detected