SpokePOVFrame::SpokePOVFrame(const wxString &title) : wxFrame((wxFrame *)NULL, wxID_ANY, title, wxPoint(150, 150), wxSize(750, 550), (wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE)) { wxString *key; LoadConfiguration(); key = GetConfigValue(wxT("num_leds")); if (key == NULL) num_leds = 30; else { long foo; if (key->ToLong(&foo)) num_leds = foo; else num_leds = 30; } wxLogDebug(wxT("Config: %d LEDs"), num_leds); SetConfigValue(wxT("num_leds"), wxString::Format(wxT("%d"),num_leds)); key = GetConfigValue(wxT("hub_size")); if (key == NULL) hub_size = 5; else { long foo; if (key->ToLong(&foo)) hub_size = foo; else hub_size = 5; } wxLogDebug(wxT("Config: %d\" hub"), hub_size); SetConfigValue(wxT("hub_size"), wxString::Format(wxT("%d"),hub_size)); key = GetConfigValue(wxT("comm_delay")); if (key == NULL) comm_delay = 500; else { long foo; if (key->ToLong(&foo)) comm_delay = foo; else comm_delay = 500; } wxLogDebug(wxT("Delay: %d\" us"), comm_delay); SetConfigValue(wxT("comm_delay"), wxString::Format(wxT("%d"),comm_delay)); key = GetConfigValue(wxT("commlink")); #if defined (W32_NATIVE) if (key == NULL) { commlink = wxT("parallel"); } else if ((key->IsSameAs("parallel")) || (key->IsSameAs("serial")) || (key->IsSameAs("usb"))) { commlink = wxString(*key); wxLogDebug(wxT("Config: %s", commlink.c_str()); } else {
bool CNotificationManager::MarkDeleted(CBSLNotification& bslNotification, bool bValue) { if (!(bslNotification.GetCategory() == wxT("scheduler")) && !(bslNotification.GetCategory() == wxT("client"))) { SetConfigValue(DeterminePath(bslNotification), wxT("Deleted"), bValue); wxGetApp().GetState()->FireEvent(wxEVT_BSLNOTIFICATION_UPDATE, bslNotification.GetHostHandle(), bslNotification.GetNotificationHandle()); } return true; }
/*---------------------------------------------------------------------- | NPT_LogManager::Configure +---------------------------------------------------------------------*/ NPT_Result NPT_LogManager::Configure(const char* config_sources) { // exit if we're already initialized if (m_Configured) return NPT_SUCCESS; // prevent multiple threads from configuring at the same time NPT_LogManagerAutoLocker lock(*this); if (m_Configured) return NPT_SUCCESS; // we need to be disabled while we configure ourselves NPT_LogManagerAutoDisabler autodisabler; // set some default config values SetConfigValue(".handlers", NPT_LOG_ROOT_DEFAULT_HANDLER); // see if the config sources have been set to non-default values if (config_sources == NULL) { config_sources = NPT_CONFIG_DEFAULT_LOG_CONFIG_SOURCE; } NPT_String config_sources_system; if (NPT_SUCCEEDED(NPT_GetSystemLogConfig(config_sources_system))) { config_sources = config_sources_system; } NPT_String config_sources_env; if (NPT_SUCCEEDED(NPT_Environment::Get(NPT_CONFIG_LOG_CONFIG_ENV, config_sources_env))) { config_sources = config_sources_env; } /* load all configs */ NPT_String config_source; const char* cursor = config_sources; const char* source = config_sources; for (;;) { if (*cursor == '\0' || *cursor == '|') { if (cursor != source) { config_source.Assign(source, (NPT_Size)(cursor-source)); config_source.Trim(" \t"); ParseConfigSource(config_source); if (*cursor == '|') source = cursor+1; } if (*cursor == '\0') break; } cursor++; } /* create the root logger */ LogManager.m_Root = new NPT_Logger("", *this); LogManager.m_Root->m_Level = NPT_CONFIG_DEFAULT_LOG_LEVEL; LogManager.m_Root->m_LevelIsInherited = false; ConfigureLogger(LogManager.m_Root); // we're initialized now m_Configured = true; return NPT_SUCCESS; }
BOOL CNdasDevice::Enable(BOOL bEnable) { ximeta::CAutoLock autolock(this); if (bEnable) { // // To enable this device // if (NDAS_DEVICE_STATUS_DISABLED != m_status) { return TRUE; } // // DISABLED -> DISCONNECTED // ChangeStatus(NDAS_DEVICE_STATUS_DISCONNECTED); } else { // // To disable this device // if (NDAS_DEVICE_STATUS_DISABLED == m_status) { return TRUE; } // // You cannot disable this device when a unit device is mounted // if (IsAnyUnitDevicesMounted()) { ::SetLastError(NDASHLPSVC_ERROR_CANNOT_DISABLE_MOUNTED_DEVICE); return FALSE; } // // DISCONNECTED/CONNECTED -> DISABLED // ChangeStatus(NDAS_DEVICE_STATUS_DISABLED); } (VOID) SetConfigValue(_T("Enabled"), bEnable); // // Clear Device Error // SetLastDeviceError(NDAS_DEVICE_ERROR_NONE); return TRUE; }
VOID CNdasDevice::SetName(LPCTSTR szName) { ximeta::CAutoLock autolock(this); HRESULT hr = ::StringCchCopy( m_szDeviceName, MAX_NDAS_DEVICE_NAME_LEN, szName); _ASSERTE(SUCCEEDED(hr)); (VOID) SetConfigValue(_T("DeviceName"), szName); (VOID) pGetNdasEventPublisher()->DevicePropertyChanged(m_dwSlotNo); }
CNdasDevice::CNdasDevice( DWORD dwSlotNo, CONST NDAS_DEVICE_ID& deviceId, BOOL fVolatile, BOOL fAutoRegistered) : m_status(NDAS_DEVICE_STATUS_DISABLED), m_lastError(NDAS_DEVICE_ERROR_NONE), m_dwSlotNo(dwSlotNo), m_deviceId(deviceId), m_grantedAccess(0x00000000L), m_dwLastHeartbeatTick(0), m_dwCommFailureCount(0), m_fAutoRegistered(fAutoRegistered), m_fVolatile(fVolatile) { m_szDeviceName[0] = TEXT('\0'); ::ZeroMemory( &m_hwInfo, sizeof(HARDWARE_INFO)); ::ZeroMemory( m_pUnitDevices, sizeof(CNdasUnitDevice*) * MAX_NDAS_UNITDEVICE_COUNT); HRESULT hr = ::StringCchPrintf( m_szCfgContainer, 30, TEXT("Devices\\%04d"), dwSlotNo); _ASSERT(SUCCEEDED(hr)); // // After we allocate m_szCfgContainer, we can use SetConfigValue // if (fAutoRegistered) { (VOID) SetConfigValue(_T("AutoRegistered"), fAutoRegistered); } else { (VOID) DeleteConfigValue(_T("AutoRegistered")); } DBGPRT_TRACE(_FT("ctor: %s\n"), ToString()); }
/*---------------------------------------------------------------------- | NPT_LogManager::ParseConfig +---------------------------------------------------------------------*/ NPT_Result NPT_LogManager::ParseConfig(const char* config, NPT_Size config_size) { const char* cursor = config; const char* line = config; const char* separator = NULL; NPT_String key; NPT_String value; /* parse all entries */ while (cursor <= config+config_size) { /* separators are newlines, ';' or end of buffer */ if ( cursor == config+config_size || *cursor == '\n' || *cursor == '\r' || *cursor == ';') { /* newline or end of buffer */ if (separator && line[0] != '#') { /* we have a property */ key.Assign(line, (NPT_Size)(separator-line)); value.Assign(line+(separator+1-line), (NPT_Size)(cursor-(separator+1))); key.Trim(" \t"); value.Trim(" \t"); SetConfigValue((const char*)key, (const char*)value); } line = cursor+1; separator = NULL; } else if (*cursor == '=' && separator == NULL) { separator = cursor; } cursor++; } return NPT_SUCCESS; }