Skip to content

Commit

Permalink
Bug fixes, added data types
Browse files Browse the repository at this point in the history
Data type conversions and bug fixes
  • Loading branch information
davepruitt committed Sep 28, 2018
1 parent 8c4cbff commit 46be2b7
Show file tree
Hide file tree
Showing 21 changed files with 497 additions and 84 deletions.
104 changes: 85 additions & 19 deletions BetterSerialMonitor/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,9 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<TextBlock Grid.Column="0" Grid.Row="1"
Grid.ColumnSpan="5"
Text="When adding bytes, separate each byte with a space. Bytes can be represented using decimal (0-255) or hexidecimal (0x00-0xff) numbers."
FontSize="12"
TextWrapping="Wrap"
HorizontalAlignment="Left"
Margin="0,3,0,0"
/>

<TextBlock Grid.Column="0"
Text="Text to send: "
VerticalAlignment="Center" />
Expand Down Expand Up @@ -137,6 +129,56 @@
Name="AddAsByteSequenceButton"
Click="AddAsByteSequenceButton_Click"
/>

<GroupBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5"
Header="Convert to data type and add bytes"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="0" Text="Data type:" HorizontalAlignment="Left" VerticalAlignment="Center" />
<ComboBox Grid.Column="1" ItemsSource="{Binding Path=DataTypeOptions}"
SelectedIndex="{Binding Path=DataTypeOptionsIndex,FallbackValue=0}"
VerticalContentAlignment="Center"
Width="150"
Margin="10,5"
/>

<TextBlock Grid.Column="2" Text="Endianness:" HorizontalAlignment="Left" VerticalAlignment="Center"
Margin="10,0,0,0"
/>
<ComboBox Grid.Column="3" ItemsSource="{Binding Path=EndiannessOptions}"
SelectedIndex="{Binding Path=EndiannessOptionsIndex, FallbackValue=0}"
VerticalContentAlignment="Center"
Width="150"
Margin="10,5"
/>

<Button Grid.Column="4" Content="Add to message"
Margin="10,5"
Width="150"
Name="DataTypeAddButton"
Click="DataTypeAddButton_Click"
/>
</Grid>
</GroupBox>



<TextBlock Grid.Column="0" Grid.Row="2"
Grid.ColumnSpan="5"
Text="When adding bytes, separate each byte with a space. Bytes can be represented using decimal (0-255) or hexidecimal (0x00-0xff) numbers."
FontSize="12"
TextWrapping="Wrap"
HorizontalAlignment="Left"
Margin="0,3,0,0"
/>
</Grid>

<GroupBox Header="Current message" Margin="10"
Expand Down Expand Up @@ -219,18 +261,42 @@
VerticalScrollBarVisibility="Auto"
IsEnabled="{Binding Path=IsPortConnected, FallbackValue=True}"
Text="{Binding Path=CurrentReceiveBufferText, FallbackValue=No text, Mode=OneWay}"
TextChanged="TextBox_TextChanged"
Name="DataReceivedBuffer"
/>

<Button Grid.Row="4"
Content="Clear buffer"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Width="150"
Margin="0, 0, 10, 10"
IsEnabled="{Binding Path=IsPortConnected, FallbackValue=True}"
Name="ClearBufferButton"
Click="ClearBufferButton_Click"
/>
<Grid Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="0"
Text="Max input buffer length:"
VerticalAlignment="Center"
Margin="10,0,10,10"
/>
<TextBlock Grid.Column="1"
Text="1000"
VerticalAlignment="Center"
Margin="5,0,10,10"
/>

<Button Grid.Row="0" Grid.Column="2"
Content="Clear buffer"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Width="150"
Margin="0, 0, 10, 10"
IsEnabled="{Binding Path=IsPortConnected, FallbackValue=True}"
Name="ClearBufferButton"
Click="ClearBufferButton_Click"
/>

</Grid>



</Grid>
</Window>
11 changes: 11 additions & 0 deletions BetterSerialMonitor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,16 @@ private void ClearBufferButton_Click(object sender, RoutedEventArgs e)
{
MainWindowViewModel.GetInstance().ClearBuffer();
}

private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
DataReceivedBuffer.ScrollToEnd();
}

private void DataTypeAddButton_Click(object sender, RoutedEventArgs e)
{
MainWindowViewModel.GetInstance().AddAsDataType(ImmediateText.Text);
ImmediateText.Text = string.Empty;
}
}
}
27 changes: 27 additions & 0 deletions BetterSerialMonitor/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,30 @@ public List<string> AvailableBaudRates
}
}

public List<string> DataTypeOptions
{
get
{
return Enum.GetNames(typeof(Model.TypesToInclude)).ToList();
}
}

public List<string> EndiannessOptions
{
get
{
return Enum.GetNames(typeof(Model.Endianness)).ToList();
}
}

public int SelectedPortIndex { get; set; } = 0;

public int SelectedBaudRateIndex { get; set; } = 0;

public int DataTypeOptionsIndex { get; set; } = 0;

public int EndiannessOptionsIndex { get; set; } = 0;

[ReactToModelPropertyChanged(new string[] { "CurrentMessage" })]
public string Message_ASCII
{
Expand Down Expand Up @@ -253,6 +273,13 @@ public void SendCurrentMessage ()
Model.GetInstance().SendCurrentMessage();
}

public void AddAsDataType(string text)
{
Model.TypesToInclude t = (Model.TypesToInclude) DataTypeOptionsIndex;
Model.Endianness end = (Model.Endianness) EndiannessOptionsIndex;
Model.GetInstance().AddAsDataType(text, t, end);
}

#endregion
}
}
Loading

0 comments on commit 46be2b7

Please sign in to comment.