/**
 * Subscribe to all registered state variables.
 */
void ClientDbxZonePro::_subscribeSVValues() {
	for(uint8_t a=0; a<_SVnumStored; a++)	{
		_subscribe(_SVstore[a*8+0],_SVstore[a*8+1],_SVstore[a*8+2],_SVstore[a*8+3]);
	}
}
int main (int argc, char ** argv)
{
    try
    {
        CIMClient client;

        //
        //  Connect to CIM Server
        //
        try
        {
            client.connectLocal ();
        }

        catch(Exception& e)
        {
            cerr << "Exception thown by client.connectLocal(): " 
                << e.getMessage() << endl;
            return -1;
        }


        if (argc > 2)
        {
            _usage ();
            return 1;
        }

        else if (argc == 1)
        {
            try
            {
                _subscribe (client);
            }
            catch(Exception& e)
            {
                cerr << "Exception thrown by _subscribe method: " 
                    << e.getMessage() << endl;
                return -1;
            }

            Sint32 result = _sendTestIndications (client);

            if (result == 0)
            {
                cout << "Successfully sent test indications" << endl;
            }
            else
            {
                cerr << "Failed to send test indications" << endl;
            }

            try
            {
                _unsubscribe (client);
            }
            catch(Exception& e)
            {
                cerr << "Exception thrown by _unsubscribe method: " 
                    << e.getMessage() << endl;
                return -1;
            }
        }

        else
        {
            const char * opt = argv [1];

            if (String::equalNoCase (opt, "subscribe"))
            {
                try
                {
                    _subscribe (client);
                }
                catch(Exception& e)
                {
                    cerr << "Exception thrown by _subscribe method: "
                         << e.getMessage() << endl;
                    return -1;
                }
            }
            else if (String::equalNoCase (opt, "sendTestIndications"))
            {
                Sint32 result = _sendTestIndications (client);

                if (result == 0)
                {
                    cout << "Successfully sent test indications" << endl;
                }
                else
                {
                    cerr << "Failed to send test indications" << endl;
                }
            }
            else if (String::equalNoCase (opt, "unsubscribe"))
            {
                try
                {
                    _unsubscribe (client);
                }
                catch(Exception& e)
                {
                    cerr << "Exception thrown by _unsubscribe method: "
                         << e.getMessage() << endl;
                    return -1;
                }
            }
            else
            {
                cerr << "Invalid option: " << opt << endl;
                _usage ();
                return -1;
            }
        }
    }
    catch (Exception & e)
    {
        cerr << "SendTestIndications failed: " << e.getMessage () << endl;
        return -1;
    }

    return 0;
}