Пример #1
0
bool CVSCPVariable::setValueFromString( int type, const wxString& strValue )
{	
    // Convert to uppercase
    wxString strUpper;

    switch ( type ) { 

        case VSCP_DAEMON_VARIABLE_CODE_STRING:
            m_strValue = strValue;
            break;

        case VSCP_DAEMON_VARIABLE_CODE_BOOLEAN:
            {
                strUpper = strValue.Upper();
                if ( wxNOT_FOUND != strUpper.Find( _("TRUE") ) ) {
                    m_boolValue = true;
                }
                else {
                    m_boolValue = false;
                }
            }
            break;

        case VSCP_DAEMON_VARIABLE_CODE_INTEGER:
            m_longValue = readStringValue( strValue );
            break;
            
        case VSCP_DAEMON_VARIABLE_CODE_LONG:
            m_longValue = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_DOUBLE:
            strValue.ToDouble( &m_floatValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_MEASUREMENT:
            {
                uint8_t data[ VSCP_MAX_DATA ];
                uint16_t sizeData = 0;
                getVscpDataArrayFromString( data, &sizeData, strValue );
                if ( sizeData > 8 ) sizeData = 8;
                if (sizeData) memcpy( m_normInteger, data, sizeData );
                m_normIntSize = sizeData;
            }
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT:
            getVscpEventFromString( &m_event, strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_GUID:
            getGuidFromString( &m_event, strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_DATA:
            getVscpDataFromString( &m_event, strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_CLASS:
            m_event.vscp_class = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_TYPE:
            m_event.vscp_type = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_TIMESTAMP:
            m_event.timestamp = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_DATETIME:
            m_timestamp.ParseDateTime( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_UNASSIGNED:
            
            // Fall through - Not allowed here

        default:
            return false;

    }

    return true;

}
Пример #2
0
extern "C" bool WINAPI EXPORT vscp_getVscpEventFromString( vscpEvent *pEvent, 
                                                                const char *p )
{
    wxString str = wxString::FromAscii( p );
    return getVscpEventFromString( pEvent, str ); 
}