-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Helevn/LReal
模拟器增加 双精度LReal 读写的功能
- Loading branch information
Showing
12 changed files
with
222 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<UserControl x:Class="S7SvrSim.UserControls.Rws.LRealOpsView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:S7SvrSim.UserControls.Rws" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
|
||
|
||
<Grid Margin="16, 2, 16, 2"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition></ColumnDefinition> | ||
<ColumnDefinition></ColumnDefinition> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition></RowDefinition> | ||
<RowDefinition></RowDefinition> | ||
</Grid.RowDefinitions> | ||
|
||
<Grid.Resources> | ||
<Style TargetType="Button" BasedOn="{StaticResource MaterialDesignOutlinedButton}"> | ||
<Setter Property="VerticalAlignment" Value="Center"></Setter> | ||
</Style> | ||
<Style TargetType="TextBlock" BasedOn="{StaticResource MaterialDesignTextBlock}"> | ||
<Setter Property="VerticalAlignment" Value="Center"></Setter> | ||
</Style> | ||
<Style TargetType="TextBox" BasedOn="{StaticResource MaterialDesignTextBox}"> | ||
<Setter Property="VerticalAlignment" Value="Center"></Setter> | ||
</Style> | ||
</Grid.Resources> | ||
|
||
<Button Name="btnRead" Content="读取" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0"></Button> | ||
<TextBox Name="txtValueRead" HorizontalAlignment="Stretch" IsEnabled="False" Grid.Row="0" Grid.Column="1"></TextBox> | ||
|
||
<TextBox Name="txtValueWritten" Grid.Row="1" Grid.Column="0"></TextBox> | ||
<Button Name="btnWrite" Content="写入" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1"></Button> | ||
</Grid> | ||
|
||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using S7SvrSim.ViewModels.Rw; | ||
using Splat; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace S7SvrSim.UserControls.Rws | ||
{ | ||
/// <summary> | ||
/// Interaction logic for LRealOpsView.xaml | ||
/// </summary> | ||
public partial class LRealOpsView : UserControl, IViewFor<RwLRealVM> | ||
{ | ||
|
||
public LRealOpsView() | ||
{ | ||
InitializeComponent(); | ||
this.WhenActivated(d => { | ||
this.Bind(this.ViewModel, vm => vm.ValueRead, v => v.txtValueRead.Text).DisposeWith(d); | ||
this.Bind(this.ViewModel, vm => vm.ToBeWritten, v => v.txtValueWritten.Text).DisposeWith(d); | ||
this.BindCommand(this.ViewModel, vm => vm.CmdRead, v => v.btnRead).DisposeWith(d); | ||
this.BindCommand(this.ViewModel, vm => vm.CmdWrite, v => v.btnWrite).DisposeWith(d); | ||
|
||
this.ViewModel.CmdRead.ThrownExceptions | ||
.Subscribe(e => MessageBox.Show(e.Message)); | ||
this.ViewModel.CmdWrite.ThrownExceptions | ||
.Subscribe(e => MessageBox.Show(e.Message)); | ||
}); | ||
} | ||
|
||
#region | ||
public RwLRealVM ViewModel | ||
{ | ||
get { return (RwLRealVM)GetValue(ViewModelProperty); } | ||
set { SetValue(ViewModelProperty, value); } | ||
} | ||
|
||
object IViewFor.ViewModel { get => this.ViewModel; set => this.ViewModel = (RwLRealVM)value; } | ||
|
||
// Using a DependencyProperty as the backing store for ViewModel. This enables animation, styling, binding, etc... | ||
public static readonly DependencyProperty ViewModelProperty = | ||
DependencyProperty.Register("ViewModel", typeof(RwLRealVM), typeof(LRealOpsView), new PropertyMetadata(null)); | ||
#endregion | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using S7Svr.Simulator.ViewModels; | ||
|
||
namespace S7SvrSim.ViewModels.Rw; | ||
|
||
public class RwLRealVM : RwVMBase<double> | ||
{ | ||
public RwLRealVM(IS7DataBlockService s7ServerService) : base(s7ServerService) | ||
{ | ||
} | ||
|
||
|
||
protected override void CmdWrite_Impl() | ||
{ | ||
this._s7ServerService.WriteLReal(this.RwVM.TargetDBNumber, this.RwVM.TargetPos, this.ToBeWritten); | ||
} | ||
|
||
protected override double CmdRead_Impl() | ||
{ | ||
var val = this._s7ServerService.ReadLReal(this.RwVM.TargetDBNumber, this.RwVM.TargetPos); | ||
this.ValueRead = val; | ||
return val; | ||
} | ||
|
||
} |