bool Mixer::addChannel(Identifier channels_id , ValueTree channel_store) { // validate channels group GUI and storage Channels* channels = getChannels(channels_id) ; if (!channels || !channel_store.isValid()) return false ; // create channel GUI and update mixer layout bool was_added = channels->addChannel(channel_store) ; if (was_added && channels != this->masterChannels) resized() ; return was_added ; }
View::~View() { // Use copy - Channel::unsetOutput modifies vector Channels channels = _channels; for( Channels::const_iterator i = channels.begin(); i != channels.end(); ++i ) { Channel* channel = *i; channel->unsetOutput(); } LBASSERT( _channels.empty( )); _channels.clear(); }
unsigned unifiedLength(Channels &a) { unsigned len=0; for(unsigned c=0;c<a.size();c++) if(a[c].size()>len) len=a[c].size(); for(unsigned c=0;c<a.size();c++) if(a[c].size()<len) a[c]=a[c].resizeTo(len); return len; }
unsigned unifiedSamplerate(Channels &a) { unsigned samplerate=0; for(unsigned c=0;c<a.size();c++) if(a[c].samplerate()>samplerate) samplerate=a[c].samplerate(); for(unsigned c=0;c<a.size();c++) if(a[c].samplerate()<samplerate) a[c]=a[c].resampleTo(samplerate); return samplerate; }
// Reload the setup file void SetupFile::LoadSetupFile(Channels &ChannelInfo, string& CommStr, string& OverideStr) { string FileLine; ChannelInfo.clear(); ifstream ChannelFile("HILSIMSetup.txt"); if (ChannelFile.is_open()) { string FoundLine = string("Found File Line: "); while (! ChannelFile.eof() ) { getline (ChannelFile,FileLine); size_t endpos = FileLine.find_last_not_of(" \t\r\n"); if (string::npos != endpos) FileLine = FileLine.substr(0, endpos+1); LoggingFile.AppendString(FoundLine); LoggingFile.AppendString(FileLine); LoggingFile.mLogFile << endl; ParseLine(FileLine, ChannelInfo, CommStr, OverideStr); } ChannelFile.close(); }; };
void SetupFile::ParseEngineLine(string& ParseString, Channels &ChannelInfo) { int iValueIndex = 0; // Index of the number of values found int iSearchPos = 0; // The next position found fora delimeter; int iLastPos = 0; // The next position found fora delimeter; bool EndFound = false; ChannelSetup ParseSetup; ChannelSetup* pParseSetup = (ChannelSetup*) &ParseSetup; // new ChannelSetup(); string FindStr; string TypeStr; FindStr.resize(60); do { FindStr.erase(); iSearchPos = ParseString.find(",",iLastPos); if(iSearchPos == ParseString.npos) { FindStr.append(ParseString,iLastPos,ParseString.length()-iLastPos); EndFound = true; } else { FindStr.append(ParseString,iLastPos,iSearchPos-iLastPos); }; ParseEngineString(FindStr, iValueIndex, pParseSetup); iValueIndex++; iSearchPos++; // Increment search position to avoid repeat finding the same character iLastPos = iSearchPos; } while( !EndFound ); // Only create new data channel if we have the right number of data points if(iValueIndex == DATAPOS_ENGINE_LAST_INDEX) { ChannelSetup* pNewSetup = new ChannelSetup(pParseSetup); ChannelInfo.push_back(pNewSetup); LoggingFile.mLogFile << "New engine added: "; } else { LoggingFile.mLogFile << "New engine failed: "; }; };
Channels Window::_getEventChannels( const PointerEvent& event ) { if( !_grabbedChannels.empty( )) return _grabbedChannels; Channels result; const Channels& channels = getChannels(); for( ChannelsCIter i = channels.begin(); i != channels.end(); ++i ) { Channel* channel = *i; if( !channel->isDestination( )) continue; const PixelViewport& pvp = getPixelViewport(); const PixelViewport& channelPVP = channel->getNativePixelViewport(); // convert y to GL notation (Channel PVP uses GL coordinates) const int32_t y = pvp.h - event.y; if( channelPVP.isInside( event.x, y )) result.push_back( channel ); } return result; }
// Step through list of controls reading the servo channel, calculating new position // and setting either a surface or engine(s) to the value void ServosToControls(void) { int iIndex = 0; int iSize = ControlSurfaces.size(); int iServoChannel; intbb ServoValue; float ControlSetting; ChannelSetup* pScanSetup; for (iIndex = 0; iIndex < iSize; iIndex++) { pScanSetup = &ControlSurfaces[iIndex]; iServoChannel = pScanSetup->mServoChannel; ServoValue._.B1 = SERVO_IN[2*iServoChannel]; ServoValue._.B0 = SERVO_IN[(2*iServoChannel)+1]; ControlSetting = pScanSetup->GetControlDeflection(ServoValue.BB); if (pScanSetup->mControlType == CONTROL_TYPE_SURFACE) { XPLMSetDataf(pScanSetup->mControlSurfaceRef, ControlSetting); } else if (pScanSetup->mControlType == CONTROL_TYPE_ENGINE) { unsigned int Mask = pScanSetup->mEngineMask; for (int Engine = 0; Engine < 8; Engine++) { if ((Mask & 0x01) != 0) { ThrottleSettings[Engine] = ControlSetting; } Mask >>= 1; } if (ControlSetting > PARKBRAKE_THROTTLE_THRESHOLD) // if engine is throttled-up above threshold.. { BrakeSetting = PARKBRAKE_OFF; // remove parkbrake } else { BrakeSetting = PARKBRAKE_ON; // apply parkbrake } } }
// Step through list of controls reading the servo channel, calculating new position // and setting either a surface or engine(s) to the value void ServosToControls() { int iIndex = 0; int iSize = ControlSurfaces.size(); int iServoChannel; intbb ServoValue; int Value; float ControlSetting; ChannelSetup* pScanSetup; for(iIndex = 0; iIndex < iSize; iIndex++) { pScanSetup = &ControlSurfaces[iIndex]; iServoChannel = pScanSetup->mServoChannel; ServoValue._.B1 = SERVO_IN[2*iServoChannel]; ServoValue._.B0 = SERVO_IN[(2*iServoChannel)+1]; ControlSetting = pScanSetup->GetControlDeflection(ServoValue.BB); if(pScanSetup->mControlType == CONTROL_TYPE_SURFACE) { XPLMSetDataf(pScanSetup->mControlSurfaceRef, ControlSetting); } else if(pScanSetup->mControlType == CONTROL_TYPE_ENGINE) { unsigned int Mask = pScanSetup->mEngineMask; for (int Engine = 0; Engine < 8; Engine++) { if( (Mask & 0x01) != 0 ) { ThrottleSettings[Engine] = ControlSetting; } Mask >>= 1; } } }
bool AutoTimer::UpdateFrom(TiXmlElement* autoTimerNode, Channels &channels) { std::string strTmp; int iTmp; m_type = Timer::EPG_AUTO_SEARCH; //this is an auto timer so the state is always scheduled unless it's disabled m_state = PVR_TIMER_STATE_SCHEDULED; m_tags.clear(); if (XMLUtils::GetString(autoTimerNode, "e2tags", strTmp)) m_tags = strTmp; if (autoTimerNode->QueryStringAttribute("name", &strTmp) == TIXML_SUCCESS) m_title = strTmp; if (autoTimerNode->QueryStringAttribute("match", &strTmp) == TIXML_SUCCESS) m_searchPhrase = strTmp; if (autoTimerNode->QueryStringAttribute("enabled", &strTmp) == TIXML_SUCCESS) { if (strTmp == AUTOTIMER_ENABLED_NO) { m_state = PVR_TIMER_STATE_DISABLED; } } if (autoTimerNode->QueryIntAttribute("id", &iTmp) == TIXML_SUCCESS) m_backendId = iTmp; std::string from; std::string to; std::string avoidDuplicateDescription; std::string searchForDuplicateDescription; autoTimerNode->QueryStringAttribute("from", &from); autoTimerNode->QueryStringAttribute("to", &to); autoTimerNode->QueryStringAttribute("avoidDuplicateDescription", &avoidDuplicateDescription); autoTimerNode->QueryStringAttribute("searchForDuplicateDescription", &searchForDuplicateDescription); if (avoidDuplicateDescription != AUTOTIMER_AVOID_DUPLICATE_DISABLED) { if (searchForDuplicateDescription == AUTOTIMER_CHECK_SEARCH_FOR_DUP_IN_TITLE) m_deDup = AutoTimer::DeDup::CHECK_TITLE; else if (searchForDuplicateDescription == AUTOTIMER_CHECK_SEARCH_FOR_DUP_IN_TITLE_AND_SHORT_DESC) m_deDup = AutoTimer::DeDup::CHECK_TITLE_AND_SHORT_DESC; else if (searchForDuplicateDescription.empty() || searchForDuplicateDescription == AUTOTIMER_CHECK_SEARCH_FOR_DUP_IN_TITLE_AND_ALL_DESCS) //Even though this value should be 2 it is sent as ommitted for this attribute, we'll allow 2 anyway incase it changes in the future m_deDup = AutoTimer::DeDup::CHECK_TITLE_AND_ALL_DESCS; } if (autoTimerNode->QueryStringAttribute("encoding", &strTmp) == TIXML_SUCCESS) m_encoding = strTmp; if (autoTimerNode->QueryStringAttribute("searchType", &strTmp) == TIXML_SUCCESS) { m_searchType = strTmp; if (strTmp == AUTOTIMER_SEARCH_TYPE_DESCRIPTION) m_searchFulltext = true; } if (autoTimerNode->QueryStringAttribute("searchCase", &strTmp) == TIXML_SUCCESS) m_searchCase = strTmp; TiXmlElement* serviceNode = autoTimerNode->FirstChildElement("e2service"); if (serviceNode) { const TiXmlElement *nextServiceNode = serviceNode->NextSiblingElement("e2service"); if (!nextServiceNode) { //If we only have one channel if (XMLUtils::GetString(serviceNode, "e2servicereference", strTmp)) { m_channelId = channels.GetChannelUniqueId(Channel::NormaliseServiceReference(strTmp.c_str())); // For autotimers for channels we don't know about, such as when the addon only uses one bouquet or an old channel referene that doesn't exist // we'll default to any channel (as that is what kodi PVR does) and leave in ERROR state if (m_channelId == PVR_CHANNEL_INVALID_UID) { m_state = PVR_TIMER_STATE_ERROR; Logger::Log(LEVEL_DEBUG, "%s Overriding AutoTimer state as channel not found, state is: ERROR", __FUNCTION__); m_channelName = LocalizedString(30520); // Invalid Channel m_channelId = PVR_TIMER_ANY_CHANNEL; m_anyChannel = true; } else { m_channelName = channels.GetChannel(m_channelId)->GetChannelName(); } } } else //otherwise set to any channel { m_channelId = PVR_TIMER_ANY_CHANNEL; m_anyChannel = true; } } else //otherwise set to any channel { m_channelId = PVR_TIMER_ANY_CHANNEL; m_anyChannel = true; } m_weekdays = 0; TiXmlElement* includeNode = autoTimerNode->FirstChildElement("include"); if (includeNode) { for (; includeNode != nullptr; includeNode = includeNode->NextSiblingElement("include")) { std::string includeVal = includeNode->GetText(); std::string where; if (includeNode->QueryStringAttribute("where", &where) == TIXML_SUCCESS) { if (where == "dayofweek") { m_weekdays = m_weekdays |= (1 << atoi(includeVal.c_str())); } } } } if (m_weekdays != PVR_WEEKDAY_NONE) { std::time_t t = std::time(nullptr); std::tm timeinfo = *std::localtime(&t); timeinfo.tm_sec = 0; m_startTime = 0; if (!from.empty()) { ParseTime(from, timeinfo); m_startTime = std::mktime(&timeinfo); } timeinfo = *std::localtime(&t); timeinfo.tm_sec = 0; m_endTime = 0; if (!to.empty()) { ParseTime(to, timeinfo); m_endTime = std::mktime(&timeinfo); } } else { for (int i = 0; i < DAYS_IN_WEEK; i++) { m_weekdays = m_weekdays |= (1 << i); } m_startAnyTime = true; m_endAnyTime = true; } if (ContainsTag(TAG_FOR_GENRE_ID)) { int genreId = 0; if (std::sscanf(ReadTagValue(TAG_FOR_GENRE_ID).c_str(), "0x%02X", &genreId) == 1) { m_genreType = genreId & 0xF0; m_genreSubType = genreId & 0x0F; } else { m_genreType = 0; m_genreSubType = 0; } } return true; }
void Mixer::removeChannel(Identifier channels_id , Identifier channel_id) { Channels* channels = getChannels(channels_id) ; if (channels) channels->removeChannel(channel_id) ; }
void Mixer::resized() { //[UserResized] Add your own custom resize handling here.. DEBUG_TRACE_MIXER_COMPONENTS_VB // master channels int masters_x = getWidth() - this->masterChannels->getWidth() - GUI::PAD ; int masters_y = GUI::MIXERGROUP_Y ; int masters_w = this->masterChannels->getWidth() ; int masters_h = GUI::MIXERGROUP_H ; this->masterChannels->setBounds(masters_x , masters_y , masters_w , masters_h) ; // local and remote channels int channels_x = GUI::PAD ; int channels_y = GUI::MIXERGROUP_Y ; int n_groups = getNumDynamicMixers() ; for (int group_n = GUI::LOCALS_IDX ; group_n < n_groups ; ++group_n) { Channels* channels = (Channels*)getChildComponent(group_n) ; #ifndef FADE_HIDDEN_REMOTES // hide scrolled previous remotes if (group_n > GUI::LOCALS_IDX && group_n < this->scrollZ) { channels->setVisible(false) ; if (group_n == GUI::FIRST_REMOTE_IDX) channels_x += GUI::CHANNEL_SCROLL_BTN_W + GUI::RESIZER_W - GUI::PAD ; continue ; } // position visible channels and increment next channel position channels->setTopLeftPosition(channels_x , channels_y) ; channels_x += GUI::PAD + channels->getWidth() ; // hide scrolled next remotes int masters_resizer_x = getMastersResizerNextX() ; channels->setVisible(channels_x <= masters_resizer_x) ; #else // FADE_HIDDEN_REMOTES // hide scrolled previous remotes if (group_n > GUI::LOCALS_IDX && group_n < this->scrollZ) { if (group_n < this->scrollZ - 1) channels_x += GUI::CHANNEL_SCROLL_BTN_W + GUI::RESIZER_W - GUI::PAD - GUI::PAD + channels->getWidth() ; else{ channels->setVisible(false) ; continue ; } } // hide scrolled next remotes int masters_resizer_x = getMastersResizerNextX() ; channels->setVisible(channels_x <= masters_resizer_x) ; // position visible channels and increment next channel position channels->setTopLeftPosition(channels_x , channels_y) ; channels_x += GUI::PAD + channels->getWidth() ; #endif // FADE_HIDDEN_REMOTES } // resizers positionResizers() ; // scroll buttons int locals_resizer_x = this->localsResizer ->getX() ; int masters_resizer_x = this->mastersResizer->getX() ; bool should_show_prev_scroll_button = this->scrollZ > GUI::FIRST_REMOTE_IDX ; bool should_show_next_scroll_button = (channels_x > masters_resizer_x) ; if (should_show_prev_scroll_button) { int prev_button_x = locals_resizer_x + GUI::RESIZER_W - 1 ; prevScrollButton->setTopLeftPosition(prev_button_x , GUI::CHANNEL_SCROLL_BTN_Y) ; } if (should_show_next_scroll_button) { int next_button_x = masters_resizer_x - GUI::CHANNEL_SCROLL_BTN_W + 1 ; nextScrollButton->setTopLeftPosition(next_button_x , GUI::CHANNEL_SCROLL_BTN_Y) ; } prevScrollButton->setVisible(should_show_prev_scroll_button) ; nextScrollButton->setVisible(should_show_next_scroll_button) ; //[/UserResized] }
void channels ( const Channels & channels ) { static ::DWORD clear = PFD_STEREO | PFD_STEREO_DONTCARE; myCriterion.dwFlags &= ~clear; myCriterion.dwFlags |= channels.get(); }