diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-28 11:20:36 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-28 11:20:36 +0300 |
| commit | af885a34781d8af8f8f38f884d169d036ea1d0d4 (patch) | |
| tree | dfdb6d7e2e02a734d40e3247a886520e47a621c8 /Software/Visual_Studio/MachineStudio/Modules | |
| parent | 9785613e7897747231f0e0f1d02c76ce8407e920 (diff) | |
| download | Tango-af885a34781d8af8f8f38f884d169d036ea1d0d4.tar.gz Tango-af885a34781d8af8f8f38f884d169d036ea1d0d4.zip | |
Fixed issue with dispenser/motor homing animation.
Improved monitor item + monitor decimal places.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
6 files changed, 73 insertions, 19 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs index 037e29b57..f29d0a78d 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/DispenserElementEditor.xaml.cs @@ -118,41 +118,41 @@ namespace Tango.MachineStudio.Technician.Editors private void OnForwardPressed(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).CaptureMouse(); - DispenserItem.RaiseAction(MotorActionType.ForwardPressed); AnimateRight(); + DispenserItem.RaiseAction(MotorActionType.ForwardPressed); } private void OnForwardReleased(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).ReleaseMouseCapture(); - DispenserItem.RaiseAction(MotorActionType.ForwardReleased); StopAnimation(); + DispenserItem.RaiseAction(MotorActionType.ForwardReleased); } private void OnBackwardPressed(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).CaptureMouse(); - DispenserItem.RaiseAction(MotorActionType.BackwardPressed); AnimateLeft(); + DispenserItem.RaiseAction(MotorActionType.BackwardPressed); } private void OnBackwardReleased(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).ReleaseMouseCapture(); - DispenserItem.RaiseAction(MotorActionType.BackwardReleased); StopAnimation(); + DispenserItem.RaiseAction(MotorActionType.BackwardReleased); } private void OnHomingStarted(object sender, RoutedEventArgs e) { - DispenserItem.RaiseAction(MotorActionType.HomingStarted); AnimateLeft(); + DispenserItem.RaiseAction(MotorActionType.HomingStarted); } private void OnHomingStopped(object sender, RoutedEventArgs e) { - DispenserItem.RaiseAction(MotorActionType.HomingStopped); StopAnimation(); + DispenserItem.RaiseAction(MotorActionType.HomingStopped); } private void AnimateRight() diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml index a39fa975c..3c9673de9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MonitorElementEditor.xaml @@ -37,11 +37,13 @@ </Border.Background> <Grid> - <TextBlock FontFamily="../Fonts/#digital-7" TextAlignment="Center" VerticalAlignment="Center" FontSize="90" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=MonitorItem.Value,FallbackValue='0000'}"> - <TextBlock.Foreground> - <SolidColorBrush Color="{Binding Color}"></SolidColorBrush> - </TextBlock.Foreground> - </TextBlock> + <Viewbox Stretch="Uniform" Width="150" VerticalAlignment="Center" Margin="25 10 10 10" HorizontalAlignment="Left"> + <TextBlock FontFamily="../Fonts/#digital-7" TextAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="90" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=MonitorItem.ValueString,FallbackValue='0000'}"> + <TextBlock.Foreground> + <SolidColorBrush Color="{Binding Color}"></SolidColorBrush> + </TextBlock.Foreground> + </TextBlock> + </Viewbox> </Grid> </Border> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs index 625473521..9e76667dd 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/MotorElementEditor.xaml.cs @@ -118,41 +118,41 @@ namespace Tango.MachineStudio.Technician.Editors private void OnForwardPressed(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).CaptureMouse(); - MotorItem.RaiseAction(MotorActionType.ForwardPressed); AnimateRight(); + MotorItem.RaiseAction(MotorActionType.ForwardPressed); } private void OnForwardReleased(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).ReleaseMouseCapture(); - MotorItem.RaiseAction(MotorActionType.ForwardReleased); StopAnimation(); + MotorItem.RaiseAction(MotorActionType.ForwardReleased); } private void OnBackwardPressed(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).CaptureMouse(); - MotorItem.RaiseAction(MotorActionType.BackwardPressed); AnimateLeft(); + MotorItem.RaiseAction(MotorActionType.BackwardPressed); } private void OnBackwardReleased(object sender, MouseButtonEventArgs e) { (e.Source as FrameworkElement).ReleaseMouseCapture(); - MotorItem.RaiseAction(MotorActionType.BackwardReleased); StopAnimation(); + MotorItem.RaiseAction(MotorActionType.BackwardReleased); } private void OnHomingStarted(object sender, RoutedEventArgs e) { - MotorItem.RaiseAction(MotorActionType.HomingStarted); AnimateLeft(); + MotorItem.RaiseAction(MotorActionType.HomingStarted); } private void OnHomingStopped(object sender, RoutedEventArgs e) { - MotorItem.RaiseAction(MotorActionType.HomingStopped); StopAnimation(); + MotorItem.RaiseAction(MotorActionType.HomingStopped); } private void AnimateRight() diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml index 3b84abee2..271849490 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/MonitorTemplate.xaml @@ -29,6 +29,9 @@ <TextBlock FontSize="10" Margin="0 20 0 0"><Run>Update Interval</Run> <Run Text="{Binding UpdateInterval,StringFormat={}{0:N0} ms,FallbackValue=0}"></Run></TextBlock> <Slider Margin="0 5 0 0" Minimum="1" Maximum="1000" Value="{Binding UpdateInterval,Mode=TwoWay}"></Slider> + + <TextBlock FontSize="10" Margin="0 20 0 0">Decimal Places</TextBlock> + <mahapps:NumericUpDown Background="Transparent" Margin="0 5 0 0" HasDecimals="False" Minimum="0" Maximum="4" Value="{Binding DecimalPoints}" HorizontalContentAlignment="Center" Foreground="Gray" /> </StackPanel> </GroupBox> <GroupBox Header="COLOR" Margin="0 10 0 0"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs index 8ac27b2da..5c302e969 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/MonitorItem.cs @@ -17,6 +17,8 @@ namespace Tango.MachineStudio.Technician.TechItems [TechItem(2)] public class MonitorItem : TechItem { + private String _format; + private TechMonitor _techMonitor; /// <summary> /// Gets or sets the db tech monitor. @@ -36,7 +38,21 @@ namespace Tango.MachineStudio.Technician.TechItems public double Value { get { return _value; } - set { _value = value; RaisePropertyChanged(nameof(Value)); LastUpdateTime = DateTime.Now; } + set + { + _value = Math.Round(value, DecimalPoints); + RaisePropertyChanged(nameof(Value)); + RaisePropertyChanged(nameof(ValueString)); + LastUpdateTime = DateTime.Now; + } + } + + public String ValueString + { + get + { + return _value.ToString($"F{DecimalPoints}"); + } } private int _updateInterval; @@ -49,6 +65,29 @@ namespace Tango.MachineStudio.Technician.TechItems set { _updateInterval = value; RaisePropertyChangedAuto(); } } + private int _decimalPoints; + /// <summary> + /// Gets or sets the decimal points. + /// </summary> + public int DecimalPoints + { + get { return _decimalPoints; } + set + { + _decimalPoints = value; RaisePropertyChangedAuto(); + + if (_decimalPoints > 0) + { + _format = "0." + String.Join("", Enumerable.Range(0, DecimalPoints).Select(x => "#")); + } + else + { + _format = "0"; + } + } + } + + /// <summary> /// Gets or sets the last update time. /// </summary> @@ -66,6 +105,7 @@ namespace Tango.MachineStudio.Technician.TechItems Image = ResourceHelper.GetImageFromResources("Images/analog.png"); LastUpdateTime = DateTime.Now; UpdateInterval = 10; + DecimalPoints = 2; } /// <summary> @@ -86,6 +126,7 @@ namespace Tango.MachineStudio.Technician.TechItems MonitorItem cloned = base.Clone() as MonitorItem; cloned.TechMonitor = TechMonitor; cloned.UpdateInterval = UpdateInterval; + cloned.DecimalPoints = DecimalPoints; return cloned; } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs index 9ecfa2312..370f52d00 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModels/MachineTechViewVM.cs @@ -339,7 +339,7 @@ namespace Tango.MachineStudio.Technician.ViewModels if (prop != null) { - monitorItem.Value = GetDataLastValue(monitorItem.TechMonitor, prop.GetValue(data.Monitors)); + monitorItem.Value = GetDataLastValue(monitorItem.TechMonitor, prop.GetValue(data.Monitors)) * 0.232345; } } } @@ -975,6 +975,10 @@ namespace Tango.MachineStudio.Technician.ViewModels } catch (Exception ex) { + item.IsHomingCompleted = true; + item.IsHoming = false; + item.HomingProgress = 0; + item.HomingMaximumProgress = 0; LogManager.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName)); _eventLogger.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName)); } @@ -1062,6 +1066,10 @@ namespace Tango.MachineStudio.Technician.ViewModels } catch (Exception ex) { + item.IsHomingCompleted = true; + item.IsHoming = false; + item.HomingProgress = 0; + item.HomingMaximumProgress = 0; LogManager.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName)); _eventLogger.Log(ex, String.Format("Error executing technician command '{0}' on item '{1}'.", action, item.TechName)); } |
