per last commits add channel mode to ChannelBox to differentiate between P25 and DMR channels; correct sizing of SystemStatusBox; add light codeplug validation to check for errors at startup; ensure channel and system name lengths are length validated (channel names can be 15 characters, system names 10 characters);

pull/1/head
Bryan Biedenkapp 11 months ago
parent 7c29e95157
commit 9e9919967a

@ -38,7 +38,14 @@
<!-- Main Info Section --> <!-- Main Info Section -->
<StackPanel Grid.Column="1" HorizontalAlignment="Left" Width="119" Margin="48,0,0,1" Grid.RowSpan="2" Grid.ColumnSpan="2"> <StackPanel Grid.Column="1" HorizontalAlignment="Left" Width="119" Margin="48,0,0,1" Grid.RowSpan="2" Grid.ColumnSpan="2">
<TextBlock Text="{Binding ChannelName}" FontWeight="Bold" Foreground="White" FontSize="12"/> <TextBlock x:Name="ChannelTextBlock" FontWeight="Bold" Foreground="White" FontSize="12">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} ({1})">
<Binding Path="ChannelName" />
<Binding Path="ChannelMode" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<TextBlock Text="{Binding LastSrcId}" Foreground="Gold" FontSize="10"/> <TextBlock Text="{Binding LastSrcId}" Foreground="Gold" FontSize="10"/>
<TextBlock Text="{Binding SystemName}" Foreground="Gold" FontSize="10"/> <TextBlock Text="{Binding SystemName}" Foreground="Gold" FontSize="10"/>
</StackPanel> </StackPanel>

@ -89,6 +89,10 @@ namespace dvmconsole.Controls
/// </summary> /// </summary>
public string ChannelName { get; set; } public string ChannelName { get; set; }
/// <summary> /// <summary>
/// Textual mode of the channel.
/// </summary>
public string ChannelMode { get; set; }
/// <summary>
/// Textual name of system channel belongs to. /// Textual name of system channel belongs to.
/// </summary> /// </summary>
public string SystemName { get; set; } public string SystemName { get; set; }
@ -375,6 +379,7 @@ namespace dvmconsole.Controls
flashingBackgroundManager = new FlashingBackgroundManager(this); flashingBackgroundManager = new FlashingBackgroundManager(this);
ChannelName = channelName; ChannelName = channelName;
ChannelMode = "P25";
DstId = dstId; DstId = dstId;
SystemName = $"System: {systemName}"; SystemName = $"System: {systemName}";
LastSrcId = $"Last ID: {LastSrcId}"; LastSrcId = $"Last ID: {LastSrcId}";

@ -1,14 +1,14 @@
<UserControl x:Class="dvmconsole.Controls.SystemStatusBox" <UserControl x:Class="dvmconsole.Controls.SystemStatusBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="105" Height="55"> Width="145" Height="45">
<UserControl.Effect> <UserControl.Effect>
<DropShadowEffect ShadowDepth="1" BlurRadius="16" Color="#FF686767" Opacity="0.3" /> <DropShadowEffect ShadowDepth="1" BlurRadius="16" Color="#FF686767" Opacity="0.3" />
</UserControl.Effect> </UserControl.Effect>
<Border x:Name="ControlBorder" BorderBrush="LightGray" BorderThickness="1,1,1,1" CornerRadius="6"> <Border x:Name="ControlBorder" BorderBrush="LightGray" BorderThickness="1,1,1,1" CornerRadius="6">
<StackPanel Margin="2,2,2,2"> <StackPanel Margin="2,2,2,2">
<TextBlock Text="{Binding ConnectionState}" Foreground="Gold" FontSize="10" TextAlignment="Center" /> <TextBlock Text="{Binding ConnectionState}" Margin="0,2,0,0" Foreground="Gold" FontSize="10" TextAlignment="Center" />
<TextBlock Text="{Binding SystemName}" FontWeight="Bold" Foreground="White" FontSize="16" TextAlignment="Center" /> <TextBlock Text="{Binding SystemName}" Margin="0,4,0,0" FontWeight="Bold" Foreground="White" FontSize="16" TextAlignment="Center" />
</StackPanel> </StackPanel>
</Border> </Border>
</UserControl> </UserControl>

@ -37,6 +37,7 @@ using fnecore.DMR;
using fnecore.P25; using fnecore.P25;
using fnecore.P25.KMM; using fnecore.P25.KMM;
using fnecore.P25.LC.TSBK; using fnecore.P25.LC.TSBK;
using static dvmconsole.Codeplug;
namespace dvmconsole namespace dvmconsole
{ {
@ -69,6 +70,9 @@ namespace dvmconsole
public const int MBE_SAMPLES_LENGTH = 160; public const int MBE_SAMPLES_LENGTH = 160;
public const int PCM_SAMPLES_LENGTH = 320; // MBE_SAMPLES_LENGTH * 2 public const int PCM_SAMPLES_LENGTH = 320; // MBE_SAMPLES_LENGTH * 2
public const int MAX_SYSTEM_NAME_LEN = 10;
public const int MAX_CHANNEL_NAME_LEN = 15;
private const string INVALID_SYSTEM = "INVALID SYSTEM"; private const string INVALID_SYSTEM = "INVALID SYSTEM";
private const string INVALID_CODEPLUG_CHANNEL = "INVALID CODEPLUG CHANNEL"; private const string INVALID_CODEPLUG_CHANNEL = "INVALID CODEPLUG CHANNEL";
private const string ERR_INVALID_FNE_REF = "invalid FNE peer reference, this should not happen"; private const string ERR_INVALID_FNE_REF = "invalid FNE peer reference, this should not happen";
@ -242,6 +246,61 @@ namespace dvmconsole
string yaml = File.ReadAllText(filePath); string yaml = File.ReadAllText(filePath);
Codeplug = deserializer.Deserialize<Codeplug>(yaml); Codeplug = deserializer.Deserialize<Codeplug>(yaml);
// perform codeplug validation
List<string> errors = new List<string>();
// ensure string lengths are acceptable
// systems
Dictionary<string, string> replacedSystemNames = new Dictionary<string, string>();
foreach (Codeplug.System system in Codeplug.Systems)
{
// ensure system name is less then or equals to the max
if (system.Name.Length > MAX_SYSTEM_NAME_LEN)
{
string original = system.Name;
system.Name = system.Name.Substring(0, MAX_SYSTEM_NAME_LEN);
replacedSystemNames.Add(original, system.Name);
Log.WriteLine($"{original} SYSTEM NAME was greater then {MAX_SYSTEM_NAME_LEN} characters, truncated {system.Name}");
}
}
// zones
foreach (Codeplug.Zone zone in Codeplug.Zones)
{
// channels
foreach (Codeplug.Channel channel in zone.Channels)
{
if (Codeplug.Systems.Find((x) => x.Name == channel.System) == null)
errors.Add($"{channel.Name} refers to an {INVALID_SYSTEM} {channel.System}.");
// because we possibly truncated system names above lets see if we
// have to replaced the related system name
if (replacedSystemNames.ContainsKey(channel.System))
channel.System = replacedSystemNames[channel.System];
// ensure channel name is less then or equals to the max
if (channel.Name.Length > MAX_CHANNEL_NAME_LEN)
{
string original = channel.Name;
channel.Name = channel.Name.Substring(0, MAX_CHANNEL_NAME_LEN);
Log.WriteLine($"{original} CHANNEL NAME was greater then {MAX_CHANNEL_NAME_LEN} characters, truncated {channel.Name}");
}
}
}
// compile list of errors and throw up a messagebox of doom
if (errors.Count > 0)
{
string newLine = Environment.NewLine + Environment.NewLine;
string messageBoxString = $"Loaded codeplug {filePath} contains errors. {PLEASE_CHECK_CODEPLUG}" + newLine;
foreach (string error in errors)
messageBoxString += error + newLine;
messageBoxString = messageBoxString.TrimEnd(new char[] { '\r', '\n' });
MessageBox.Show(messageBoxString, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
// generate widgets and enable controls
GenerateChannelWidgets(); GenerateChannelWidgets();
EnableControls(); EnableControls();
} }
@ -356,6 +415,8 @@ namespace dvmconsole
foreach (var channel in zone.Channels) foreach (var channel in zone.Channels)
{ {
ChannelBox channelBox = new ChannelBox(selectedChannelsManager, audioManager, channel.Name, channel.System, channel.Tgid, settingsManager.TogglePTTMode); ChannelBox channelBox = new ChannelBox(selectedChannelsManager, audioManager, channel.Name, channel.System, channel.Tgid, settingsManager.TogglePTTMode);
channelBox.ChannelMode = channel.Mode.ToUpperInvariant();
systemStatuses.Add(channel.Name, new SlotStatus()); systemStatuses.Add(channel.Name, new SlotStatus());
if (settingsManager.ChannelPositions.TryGetValue(channel.Name, out var position)) if (settingsManager.ChannelPositions.TryGetValue(channel.Name, out var position))
@ -425,6 +486,7 @@ namespace dvmconsole
// initialize the playback channel // initialize the playback channel
playbackChannelBox = new ChannelBox(selectedChannelsManager, audioManager, PLAYBACKCHNAME, PLAYBACKSYS, PLAYBACKTG); playbackChannelBox = new ChannelBox(selectedChannelsManager, audioManager, PLAYBACKCHNAME, PLAYBACKSYS, PLAYBACKTG);
playbackChannelBox.ChannelMode = "Local";
if (settingsManager.ChannelPositions.TryGetValue(PLAYBACKCHNAME, out var pos)) if (settingsManager.ChannelPositions.TryGetValue(PLAYBACKCHNAME, out var pos))
{ {

Loading…
Cancel
Save

Powered by TurnKey Linux.