1
1
/*
2
2
* *****************************************************************************
3
- * Copyright (C) 2014-2023 Dennis Sheirer
3
+ * Copyright (C) 2014-2024 Dennis Sheirer
4
4
*
5
5
* This program is free software: you can redistribute it and/or modify
6
6
* it under the terms of the GNU General Public License as published by
23
23
import io .github .dsheirer .alias .action .AliasActionManager ;
24
24
import io .github .dsheirer .audio .AbstractAudioModule ;
25
25
import io .github .dsheirer .audio .AudioModule ;
26
+ import io .github .dsheirer .channel .IChannelDescriptor ;
26
27
import io .github .dsheirer .channel .state .State ;
27
28
import io .github .dsheirer .controller .channel .Channel ;
28
29
import io .github .dsheirer .controller .channel .Channel .ChannelType ;
48
49
import io .github .dsheirer .module .decode .dmr .DecodeConfigDMR ;
49
50
import io .github .dsheirer .module .decode .dmr .audio .DMRAudioModule ;
50
51
import io .github .dsheirer .module .decode .dmr .channel .DMRChannel ;
51
- import io .github .dsheirer .module .decode .dmr .channel .DMRTier3Channel ;
52
+ import io .github .dsheirer .module .decode .dmr .channel .DMRLsn ;
53
+ import io .github .dsheirer .module .decode .dmr .channel .DmrRestLsn ;
52
54
import io .github .dsheirer .module .decode .dmr .message .filter .DmrMessageFilterSet ;
53
55
import io .github .dsheirer .module .decode .event .DecodeEvent ;
54
56
import io .github .dsheirer .module .decode .fleetsync2 .Fleetsync2Decoder ;
@@ -123,9 +125,11 @@ public class DecoderFactory
123
125
* @return list of configured decoders
124
126
*/
125
127
public static List <Module > getModules (ChannelMapModel channelMapModel , Channel channel , AliasModel aliasModel ,
126
- UserPreferences userPreferences , TrafficChannelManager trafficChannelManager )
128
+ UserPreferences userPreferences , TrafficChannelManager trafficChannelManager ,
129
+ IChannelDescriptor channelDescriptor )
127
130
{
128
- List <Module > modules = getPrimaryModules (channelMapModel , channel , aliasModel , userPreferences , trafficChannelManager );
131
+ List <Module > modules = getPrimaryModules (channelMapModel , channel , aliasModel , userPreferences ,
132
+ trafficChannelManager , channelDescriptor );
129
133
modules .addAll (getAuxiliaryDecoders (channel .getAuxDecodeConfiguration ()));
130
134
return modules ;
131
135
}
@@ -138,10 +142,12 @@ public static List<Module> getModules(ChannelMapModel channelMapModel, Channel c
138
142
* @param aliasModel for alias lookups
139
143
* @param userPreferences instance
140
144
* @param trafficChannelManager optional traffic channel manager to use
145
+ * @param channelDescriptor to preload into the decoder state as the current channel.
141
146
* @return list of modules to use for a processing chain
142
147
*/
143
148
public static List <Module > getPrimaryModules (ChannelMapModel channelMapModel , Channel channel , AliasModel aliasModel ,
144
- UserPreferences userPreferences , TrafficChannelManager trafficChannelManager )
149
+ UserPreferences userPreferences , TrafficChannelManager trafficChannelManager ,
150
+ IChannelDescriptor channelDescriptor )
145
151
{
146
152
List <Module > modules = new ArrayList <Module >();
147
153
@@ -160,7 +166,7 @@ public static List<Module> getPrimaryModules(ChannelMapModel channelMapModel, Ch
160
166
break ;
161
167
case DMR :
162
168
processDMR (channel , userPreferences , modules , aliasList , (DecodeConfigDMR )decodeConfig ,
163
- trafficChannelManager );
169
+ trafficChannelManager , channelDescriptor );
164
170
break ;
165
171
case NBFM :
166
172
processNBFM (channel , modules , aliasList , decodeConfig );
@@ -413,7 +419,7 @@ private static void processAM(Channel channel, List<Module> modules, AliasList a
413
419
*/
414
420
private static void processDMR (Channel channel , UserPreferences userPreferences , List <Module > modules ,
415
421
AliasList aliasList , DecodeConfigDMR decodeConfig ,
416
- TrafficChannelManager trafficChannelManager )
422
+ TrafficChannelManager trafficChannelManager , IChannelDescriptor channelDescriptor )
417
423
{
418
424
modules .add (new DMRDecoder (decodeConfig ));
419
425
@@ -437,6 +443,32 @@ private static void processDMR(Channel channel, UserPreferences userPreferences,
437
443
DMRDecoderState state1 = new DMRDecoderState (channel , 1 , dmrTrafficChannelManager );
438
444
DMRDecoderState state2 = new DMRDecoderState (channel , 2 , dmrTrafficChannelManager );
439
445
446
+ //Register the states with each other so that they can pass Cap+ site status messaging to resolve current channel
447
+ state1 .setSisterDecoderState (state2 );
448
+ state2 .setSisterDecoderState (state1 );
449
+
450
+ //If an LSN is provided, apply it to both of the decoder states.
451
+ if (channelDescriptor instanceof DMRLsn lsn )
452
+ {
453
+ //If this is a REST descriptor, change it to a standard LSN descriptor.
454
+ if (channelDescriptor instanceof DmrRestLsn rest )
455
+ {
456
+ lsn = new DMRLsn (rest .getLsn ());
457
+ lsn .setTimeslotFrequency (rest .getTimeslotFrequency ());
458
+ }
459
+
460
+ if (lsn .getTimeslot () == 1 )
461
+ {
462
+ state1 .setCurrentChannel (lsn );
463
+ state2 .setCurrentChannel (lsn .getSisterTimeslot ());
464
+ }
465
+ else
466
+ {
467
+ state1 .setCurrentChannel (lsn .getSisterTimeslot ());
468
+ state2 .setCurrentChannel (lsn );
469
+ }
470
+ }
471
+
440
472
if (decodeConfig .hasChannelGrantEvent ())
441
473
{
442
474
DecodeEvent event = decodeConfig .getChannelGrantEvent ();
0 commit comments