コード例 #1
0
wxString BigGridTable::GetValue(int row, int col)
{
    static int last_row = 0;
    static VscpRXObj *pRecord = NULL;
    static wxString str;

    if ((0 == last_row) || (row != last_row)) {
        if (NULL == (pRecord = readEvent(row))) return wxString(_(""));
    }

    if (NULL == pRecord) return wxString(_(""));

    // Save the row
    last_row = row;

    switch (col) {

    case VSCP_RCVGRID_COLUMN_DIR:
        if (VSCP_EVENT_DIRECTION_RX == pRecord->m_nDir) {
            return wxString(_("RX"));
        }
        else {
            return wxString(_("TX"));
        }
        break;

    case VSCP_RCVGRID_COLUMN_CLASS:
        if (g_Config.m_UseSymbolicNames) {
            wxString strClass =
                g_vscpinfo.getClassDescription(pRecord->m_pEvent->vscp_class);
            if (0 == strClass.Length()) strClass = _("Unknown class");
            return str.Format(_("%s \n0x%04X, %d"),
                strClass.c_str(),
                pRecord->m_pEvent->vscp_class,
                pRecord->m_pEvent->vscp_class);
        }
        else {
            return str.Format(_("0x%04X, %d"),
                pRecord->m_pEvent->vscp_class,
                pRecord->m_pEvent->vscp_class);
        }

    case VSCP_RCVGRID_COLUMN_TYPE:
        if (g_Config.m_UseSymbolicNames) {
            wxString strType =
                g_vscpinfo.getTypeDescription(pRecord->m_pEvent->vscp_class,
                pRecord->m_pEvent->vscp_type);
            if (0 == strType.Length()) strType = _("Unknown type");
            return str.Format(_("%s \n0x%04X, %d "),
                strType.c_str(),
                pRecord->m_pEvent->vscp_type,
                pRecord->m_pEvent->vscp_type);
        }
        else {
            return str.Format(_("0x%04X, %d"),
                pRecord->m_pEvent->vscp_type,
                pRecord->m_pEvent->vscp_type);
        }

    case VSCP_RCVGRID_COLUMN_NOTE:
        if ( pRecord->m_wxStrNote.Length() ) {
            return pRecord->m_wxStrNote;
        }
        else {
            // Use field for info
            wxString strGUID;
            vscp_writeGuidArrayToString( pRecord->m_pEvent->GUID, strGUID );
            return str.Format(_("Nodeid=%d GUID=%s"), ((pRecord->m_pEvent->GUID[ 14 ]<<8) + pRecord->m_pEvent->GUID[15]), (const char *)strGUID.mbc_str() );
        }

    default:
        str = _("Invalid column");
    }

    return str;
}
コード例 #2
0
void frmScanforDevices::openConfiguration(wxCommandEvent& event)
{
    frmDeviceConfig *subframe = new frmDeviceConfig(this, 2000, _("VSCP Configuration window"));

    if (INTERFACE_CANAL == m_interfaceType) {

        // Hide the Level II checkbox
        subframe->m_bLevel2->Show(false);

        // Init node id combo
        wxRect rc = subframe->m_comboNodeID->GetRect();
        rc.SetWidth(60);
        subframe->m_comboNodeID->SetSize(rc);

        for (int i = 1; i < 256; i++) {
            subframe->m_comboNodeID->Append(wxString::Format(_("0x%02x"), i));
        }

        subframe->m_comboNodeID->SetValue(_("0x01"));
        subframe->SetTitle(_("VSCP Registers (CANAL) - ") +
                m_canalif.m_strDescription);

        subframe->m_csw.setInterface(m_canalif.m_strDescription,
                m_canalif.m_strPath,
                m_canalif.m_strConfig,
                m_canalif.m_flags, 0, 0);

        scanElement *pElement =
                (scanElement *) m_DeviceTree->GetItemData(m_DeviceTree->GetSelection());
        if (NULL != pElement) {
            subframe->m_comboNodeID->SetSelection(pElement->m_nodeid - 1);
        }

        // Close our interface
        m_csw.doCmdClose();

        // Connect to device bus
        subframe->enableInterface();

        // subframe->OnInterfaceActivate( ev );
        wxCommandEvent ev;
        subframe->OnButtonUpdateClick(ev);

        // Move window on top
        subframe->Raise();

        // Show the VSCP configuration windows
        subframe->Show(true);

        // Close the scan window
        Show(false);

    } 
    else if (INTERFACE_VSCP == m_interfaceType) {

        wxString str;
        unsigned char GUID[16];
        memcpy(GUID, m_vscpif.m_GUID, 16);

        // Fill the combo
        for (int i = 1; i < 256; i++) {
            GUID[0] = i;
            vscp_writeGuidArrayToString(GUID, str);
            subframe->m_comboNodeID->Append(str);
        }

        GUID[0] = 0x01;
        vscp_writeGuidArrayToString(GUID, str);
        subframe->m_comboNodeID->SetValue(str);

        subframe->SetTitle(_("VSCP Registers (TCP/IP)- ") +
                m_vscpif.m_strDescription);

        // If server username is given and no password is entered we ask for it.
        if (m_vscpif.m_strPassword.IsEmpty() &&
                !m_vscpif.m_strUser.IsEmpty()) {
            m_vscpif.m_strPassword =
                    ::wxGetTextFromUser(_("Please enter password"),
                    _("Connection Test"));
        }

        //subframe->m_csw = m_interfaceType;
        subframe->m_csw.setInterface(m_vscpif.m_strHost,
                m_vscpif.m_strUser,
                m_vscpif.m_strPassword);

        // Connect to host
        subframe->enableInterface();

        // Show the VSCP configuration windows
        subframe->Show(true);

        // Move window on top
        subframe->Raise();

    }

    event.Skip(false);
}