@@ -649,86 +649,6 @@ void handle_call_update(TrunkMessage message, System *sys) {
649649 }
650650}
651651
652- System *find_system (int sys_num) {
653- System *sys_match = NULL ;
654-
655- for (std::vector<System *>::iterator it = systems.begin (); it != systems.end (); ++it) {
656- System *sys = (System *)*it;
657-
658- if (sys->get_sys_num () == sys_num) {
659- sys_match = sys;
660- break ;
661- }
662- }
663-
664- if (sys_match == NULL ) {
665- BOOST_LOG_TRIVIAL (info) << " Sys is null" ;
666- }
667- return sys_match;
668- }
669-
670- void retune_system (System *sys) {
671- System_impl *system = (System_impl *)sys;
672- bool source_found = false ;
673- Source *current_source = system->get_source ();
674- double control_channel_freq = system->get_next_control_channel ();
675-
676- BOOST_LOG_TRIVIAL (error) << " [" << system->get_short_name () << " ] Retuning to Control Channel: " << format_freq (control_channel_freq);
677-
678- if ((current_source->get_min_hz () <= control_channel_freq) &&
679- (current_source->get_max_hz () >= control_channel_freq)) {
680- source_found = true ;
681- BOOST_LOG_TRIVIAL (info) << " \t - System Source " << current_source->get_num () << " - Min Freq: " << format_freq (current_source->get_min_hz ()) << " Max Freq: " << format_freq (current_source->get_max_hz ());
682- // The source can cover the System's control channel, break out of the
683- // For Loop
684- if (system->get_system_type () == " smartnet" ) {
685- system->smartnet_trunking ->tune_freq (control_channel_freq);
686- system->smartnet_trunking ->reset ();
687- } else if (system->get_system_type () == " p25" ) {
688- system->p25_trunking ->tune_freq (control_channel_freq);
689- } else {
690- BOOST_LOG_TRIVIAL (error) << " \t - Unknown system type for Retune" ;
691- }
692- } else {
693- for (vector<Source *>::iterator src_it = sources.begin (); src_it != sources.end (); src_it++) {
694- Source *source = *src_it;
695-
696- if ((source->get_min_hz () <= control_channel_freq) &&
697- (source->get_max_hz () >= control_channel_freq)) {
698- source_found = true ;
699- BOOST_LOG_TRIVIAL (info) << " \t - System Source " << source->get_num () << " - Min Freq: " << format_freq (source->get_min_hz ()) << " Max Freq: " << format_freq (source->get_max_hz ());
700-
701- if (system->get_system_type () == " smartnet" ) {
702- system->set_source (source);
703- // We must lock the flow graph in order to disconnect and reconnect blocks
704- tb->lock ();
705- tb->disconnect (current_source->get_src_block (), 0 , system->smartnet_trunking , 0 );
706- system->smartnet_trunking = make_smartnet_trunking (control_channel_freq, source->get_center (), source->get_rate (), system->get_msg_queue (), system->get_sys_num ());
707- tb->connect (source->get_src_block (), 0 , system->smartnet_trunking , 0 );
708- tb->unlock ();
709- system->smartnet_trunking ->reset ();
710- } else if (system->get_system_type () == " p25" ) {
711- system->set_source (source);
712- // We must lock the flow graph in order to disconnect and reconnect blocks
713- tb->lock ();
714- tb->disconnect (current_source->get_src_block (), 0 , system->p25_trunking , 0 );
715- system->p25_trunking = make_p25_trunking (control_channel_freq, source->get_center (), source->get_rate (), system->get_msg_queue (), system->get_qpsk_mod (), system->get_sys_num ());
716- tb->connect (source->get_src_block (), 0 , system->p25_trunking , 0 );
717- tb->unlock ();
718- } else {
719- BOOST_LOG_TRIVIAL (error) << " \t - Unkown system type for Retune" ;
720- }
721-
722- // break out of the For Loop
723- break ;
724- }
725- }
726- }
727- if (!source_found) {
728- BOOST_LOG_TRIVIAL (error) << " \t - Unable to retune System control channel, freq not covered by any source." ;
729- }
730- }
731-
732652void handle_message (std::vector<TrunkMessage> messages, System *sys) {
733653 for (std::vector<TrunkMessage>::iterator it = messages.begin (); it != messages.end (); it++) {
734654 TrunkMessage message = *it;
@@ -807,24 +727,90 @@ void handle_message(std::vector<TrunkMessage> messages, System *sys) {
807727 unit_answer_request (sys, message.source , message.talkgroup );
808728 break ;
809729
810- case INVALID_CC_MESSAGE:
811- {
812- // Do not count messages that aren't valid TSBK or MBTs.
813- int msg_count = sys->get_message_count ();
814- if (msg_count > 1 ){
815- sys->set_message_count (msg_count - 1 );
816- }
817- }
730+ case UNKNOWN:
818731 break ;
732+ }
733+ }
734+ }
819735
820- case TDULC:
821- retune_system (sys);
822- break ;
736+ System *find_system (int sys_num) {
737+ System *sys_match = NULL ;
823738
824- case UNKNOWN:
739+ for (std::vector<System *>::iterator it = systems.begin (); it != systems.end (); ++it) {
740+ System *sys = (System *)*it;
741+
742+ if (sys->get_sys_num () == sys_num) {
743+ sys_match = sys;
825744 break ;
826745 }
827746 }
747+
748+ if (sys_match == NULL ) {
749+ BOOST_LOG_TRIVIAL (info) << " Sys is null" ;
750+ }
751+ return sys_match;
752+ }
753+
754+ void retune_system (System *sys) {
755+ System_impl *system = (System_impl *)sys;
756+ bool source_found = false ;
757+ Source *current_source = system->get_source ();
758+ double control_channel_freq = system->get_next_control_channel ();
759+
760+ BOOST_LOG_TRIVIAL (error) << " [" << system->get_short_name () << " ] Retuning to Control Channel: " << format_freq (control_channel_freq);
761+
762+ if ((current_source->get_min_hz () <= control_channel_freq) &&
763+ (current_source->get_max_hz () >= control_channel_freq)) {
764+ source_found = true ;
765+ BOOST_LOG_TRIVIAL (info) << " \t - System Source " << current_source->get_num () << " - Min Freq: " << format_freq (current_source->get_min_hz ()) << " Max Freq: " << format_freq (current_source->get_max_hz ());
766+ // The source can cover the System's control channel, break out of the
767+ // For Loop
768+ if (system->get_system_type () == " smartnet" ) {
769+ system->smartnet_trunking ->tune_freq (control_channel_freq);
770+ system->smartnet_trunking ->reset ();
771+ } else if (system->get_system_type () == " p25" ) {
772+ system->p25_trunking ->tune_freq (control_channel_freq);
773+ } else {
774+ BOOST_LOG_TRIVIAL (error) << " \t - Unknown system type for Retune" ;
775+ }
776+ } else {
777+ for (vector<Source *>::iterator src_it = sources.begin (); src_it != sources.end (); src_it++) {
778+ Source *source = *src_it;
779+
780+ if ((source->get_min_hz () <= control_channel_freq) &&
781+ (source->get_max_hz () >= control_channel_freq)) {
782+ source_found = true ;
783+ BOOST_LOG_TRIVIAL (info) << " \t - System Source " << source->get_num () << " - Min Freq: " << format_freq (source->get_min_hz ()) << " Max Freq: " << format_freq (source->get_max_hz ());
784+
785+ if (system->get_system_type () == " smartnet" ) {
786+ system->set_source (source);
787+ // We must lock the flow graph in order to disconnect and reconnect blocks
788+ tb->lock ();
789+ tb->disconnect (current_source->get_src_block (), 0 , system->smartnet_trunking , 0 );
790+ system->smartnet_trunking = make_smartnet_trunking (control_channel_freq, source->get_center (), source->get_rate (), system->get_msg_queue (), system->get_sys_num ());
791+ tb->connect (source->get_src_block (), 0 , system->smartnet_trunking , 0 );
792+ tb->unlock ();
793+ system->smartnet_trunking ->reset ();
794+ } else if (system->get_system_type () == " p25" ) {
795+ system->set_source (source);
796+ // We must lock the flow graph in order to disconnect and reconnect blocks
797+ tb->lock ();
798+ tb->disconnect (current_source->get_src_block (), 0 , system->p25_trunking , 0 );
799+ system->p25_trunking = make_p25_trunking (control_channel_freq, source->get_center (), source->get_rate (), system->get_msg_queue (), system->get_qpsk_mod (), system->get_sys_num ());
800+ tb->connect (source->get_src_block (), 0 , system->p25_trunking , 0 );
801+ tb->unlock ();
802+ } else {
803+ BOOST_LOG_TRIVIAL (error) << " \t - Unkown system type for Retune" ;
804+ }
805+
806+ // break out of the For Loop
807+ break ;
808+ }
809+ }
810+ }
811+ if (!source_found) {
812+ BOOST_LOG_TRIVIAL (error) << " \t - Unable to retune System control channel, freq not covered by any source." ;
813+ }
828814}
829815
830816void check_message_count (float timeDiff) {
0 commit comments