aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-20 12:34:34 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-20 12:34:34 +0200
commitf70d2639099282432295c0949fe6da2c8dd4bb46 (patch)
tree6c63696d5e225b06344b3246072dedd905dc70f8 /Software/Visual_Studio
parentdd4b13d161d64b0e85b8bd5b55e6fd3a71952512 (diff)
downloadTango-f70d2639099282432295c0949fe6da2c8dd4bb46.tar.gz
Tango-f70d2639099282432295c0949fe6da2c8dd4bb46.zip
Improved Tech Single Value Controller!
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml48
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml3
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs42
-rw-r--r--Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs32
4 files changed, 91 insertions, 34 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml
index 60b96bc9d..5cffffc90 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/Editors/ControllerElementEditor.xaml
@@ -30,12 +30,13 @@
<!--Content-->
<Grid ClipToBounds="False" IsHitTestVisible="{Binding RelativeSource={RelativeSource AncestorType=local:ElementsEditor},Path=IsEditable,Converter={StaticResource BooleanInverseConverter}}">
<Border>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="1*" />
- <ColumnDefinition Width="100" />
- </Grid.ColumnDefinitions>
- <Viewbox>
+ <Viewbox>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="1*" />
+ <ColumnDefinition Width="100" />
+ </Grid.ColumnDefinitions>
+
<Grid>
<gauge:CircularGaugeControl
Margin="10"
@@ -45,8 +46,8 @@
ScaleSweepAngle="300"
PointerLength="85"
PointerCapRadius="35"
- MinValue="{Binding TechController.Min}"
- MaxValue="{Binding TechController.Max}"
+ MinValue="{Binding TechController.Min,FallbackValue=0}"
+ MaxValue="{Binding TechController.Max,FallbackValue=100}"
MajorDivisionsCount="10"
MinorDivisionsCount="5"
CurrentValue="{Binding EffectiveValue}"
@@ -57,7 +58,7 @@
RangeIndicatorLightOffset="80"
ScaleLabelRadius="90"
ScaleLabelSize="40,20"
- ScaleLabelFontSize="10"
+ ScaleLabelFontSize="16"
ScaleLabelForeground="LightGray"
MajorTickSize="10,3"
MinorTickSize="3,1"
@@ -66,30 +67,29 @@
ImageOffset="-50"
GaugeBackgroundColor="Black"
PointerThickness ="16"
- OptimalRangeStartValue="300"
- OptimalRangeEndValue="700"
+ OptimalRangeStartValue="{Binding OptimalRangeMinimum,FallbackValue=0}"
+ OptimalRangeEndValue="{Binding OptimalRangeMaximum,FallbackValue=100}"
DialTextOffset="40"
DialTextColor="Black"
>
</gauge:CircularGaugeControl>
</Grid>
- </Viewbox>
- <Grid Grid.Column="1" HorizontalAlignment="Right">
- <Slider Orientation="Vertical" Margin="15" TickPlacement="None" Minimum="{Binding TechController.Min}" Maximum="{Binding TechController.Max}" Value="{Binding Value,Delay=1000}">
- <Slider.Foreground>
- <SolidColorBrush Color="{Binding Color}" />
- </Slider.Foreground>
- </Slider>
- <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="../Fonts/#digital-7" TextAlignment="Right" Margin="-80 10 0 0" FontSize="30" Text="{Binding Value,StringFormat=0.00}">
- <TextBlock.Foreground>
- <SolidColorBrush Color="{Binding Color}" />
- </TextBlock.Foreground>
- </TextBlock>
+ <Grid Grid.Column="1" HorizontalAlignment="Right">
+ <visuals:Fader x:Name="fader" FaderLightBrush="DodgerBlue" Margin="10" Minimum="{Binding TechController.Min}" Maximum="{Binding TechController.Max}" Value="{Binding Value,Delay=500}">
+
+ </visuals:Fader>
+
+ <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" FontFamily="../Fonts/#digital-7" TextAlignment="Right" Margin="-50 10 0 0" FontSize="30" Text="{Binding ElementName=fader,Path=Value,StringFormat=0.0,FallbackValue=100}">
+ <TextBlock.Foreground>
+ <SolidColorBrush Color="{Binding Color,FallbackValue=White}" />
+ </TextBlock.Foreground>
+ </TextBlock>
+ </Grid>
</Grid>
- </Grid>
+ </Viewbox>
</Border>
<Border Margin="0 0 0 -23" VerticalAlignment="Bottom">
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml
index 57d807b09..ffc726abf 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/PropertiesTemplates/ControllerTemplate.xaml
@@ -34,6 +34,9 @@
<Viewbox Margin="0 5 0 0">
<colorPicker:ColorCanvas SelectedColor="{Binding Color,Mode=TwoWay}" Background="Transparent" />
</Viewbox>
+
+ <TextBlock FontSize="10" Margin="0 20 0 0"><Run>Optimal Range:</Run> <Run Text="{Binding OptimalRangeMinimum,StringFormat=0.0}"></Run><Run> to </Run><Run Text="{Binding OptimalRangeMaximum,StringFormat=0.0}"></Run></TextBlock>
+ <mahapps:RangeSlider Margin="0 5 0 0" Minimum="{Binding TechController.Min}" Maximum="{Binding TechController.Max}" LowerValue="{Binding OptimalRangeMinimum}" UpperValue="{Binding OptimalRangeMaximum}"></mahapps:RangeSlider>
</StackPanel>
</GroupBox>
</StackPanel>
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs
index 67266ee66..8a9cba883 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/ControllerItem.cs
@@ -30,7 +30,19 @@ namespace Tango.MachineStudio.Technician.TechItems
public TechController TechController
{
get { return _techController; }
- set { _techController = value; RaisePropertyChangedAuto(); TechName = _techController != null ? _techController.Description : null; ItemGuid = value != null ? value.Guid : null; }
+ set
+ {
+ _techController = value;
+ RaisePropertyChangedAuto();
+ TechName = _techController != null ? _techController.Description : null; ItemGuid = value != null ? value.Guid : null;
+
+ if (_techController != null && !IsSetToDefault)
+ {
+ OptimalRangeMinimum = _techController.Min;
+ OptimalRangeMaximum = _techController.Min + ((_techController.Max - _techController.Min) * 0.7d);
+ IsSetToDefault = true;
+ }
+ }
}
private double _value;
@@ -64,7 +76,6 @@ namespace Tango.MachineStudio.Technician.TechItems
[XmlIgnore]
public DateTime LastUpdateTime { get; set; }
-
private double _effectiveValue;
/// <summary>
/// Gets or sets the effective value received from the embedded device.
@@ -85,6 +96,29 @@ namespace Tango.MachineStudio.Technician.TechItems
}
}
+ private double _optimalRangeMinimum;
+ /// <summary>
+ /// Gets or sets the optimal range.
+ /// </summary>
+ public double OptimalRangeMinimum
+ {
+ get { return _optimalRangeMinimum; }
+ set
+ {
+ _optimalRangeMinimum = value;
+ RaisePropertyChangedAuto();
+ }
+ }
+
+ private double _optimalRangeMaximum;
+ public double OptimalRangeMaximum
+ {
+ get { return _optimalRangeMaximum; }
+ set { _optimalRangeMaximum = value; RaisePropertyChangedAuto(); }
+ }
+
+ public bool IsSetToDefault { get; set; }
+
/// <summary>
/// Initializes a new instance of the <see cref="ControllerItem"/> class.
/// </summary>
@@ -115,6 +149,10 @@ namespace Tango.MachineStudio.Technician.TechItems
{
ControllerItem cloned = base.Clone() as ControllerItem;
cloned.TechController = TechController;
+ cloned.OptimalRangeMinimum = OptimalRangeMinimum;
+ cloned.OptimalRangeMaximum = OptimalRangeMaximum;
+ cloned.IsSetToDefault = IsSetToDefault;
+
return cloned;
}
}
diff --git a/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs b/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs
index 1d1d598c6..7e8f1fa8c 100644
--- a/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs
+++ b/Software/Visual_Studio/Tango.CircularGauge/CircularGaugeControl.cs
@@ -57,6 +57,7 @@ namespace Tango.CircularGauge
private Ellipse pointerCap;
private Ellipse lightIndicator;
private bool isInitialValueSet = false;
+ private List<Path> _rangeIndicators;
private Double arcradius1;
private Double arcradius2;
private int animatingSpeedFactor = 6;
@@ -265,7 +266,7 @@ namespace Tango.CircularGauge
/// </summary>
public static readonly DependencyProperty OptimalRangeColorProperty =
- DependencyProperty.Register("OptimalRangeColor", typeof(Color), typeof(CircularGaugeControl), null);
+ DependencyProperty.Register("OptimalRangeColor", typeof(Color), typeof(CircularGaugeControl), new PropertyMetadata(Colors.White, (d, e) => (d as CircularGaugeControl).DrawRangeIndicator()));
/// <summary>
/// Dependency property to Get/Set the Above Optimal Range Color
@@ -891,6 +892,12 @@ namespace Tango.CircularGauge
#endregion
#region Constructor
+
+ public CircularGaugeControl()
+ {
+ _rangeIndicators = new List<Path>();
+ }
+
static CircularGaugeControl()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CircularGaugeControl), new FrameworkPropertyMetadata(typeof(CircularGaugeControl)));
@@ -915,6 +922,8 @@ namespace Tango.CircularGauge
gauge.OptimalRangeEndValue = gauge.MaxValue;
}
+ (d as CircularGaugeControl).DrawRangeIndicator();
+
}
private static void OnOptimalRangeStartValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
@@ -925,7 +934,7 @@ namespace Tango.CircularGauge
gauge.OptimalRangeStartValue = gauge.MinValue;
}
-
+ (d as CircularGaugeControl).DrawRangeIndicator();
}
public virtual void OnCurrentValueChanged(DependencyPropertyChangedEventArgs e)
@@ -1269,6 +1278,13 @@ namespace Tango.CircularGauge
/// </summary>
private void DrawRangeIndicator()
{
+ if (rootGrid == null) return;
+
+ foreach (var indicator in _rangeIndicators)
+ {
+ rootGrid.Children.Remove(indicator);
+ }
+
Double realworldunit = (ScaleSweepAngle / (MaxValue - MinValue));
Double optimalStartAngle;
Double optimalEndAngle;
@@ -1319,7 +1335,7 @@ namespace Tango.CircularGauge
Point D = GetCircumferencePoint(optimalStartAngleFromStart, arcradius1);
bool isReflexAngle = Math.Abs(optimalStartAngleFromStart - ScaleStartAngle) > 180.0;
- DrawSegment(A, B, C, D, isReflexAngle, BelowOptimalRangeColor);
+ _rangeIndicators.Add(DrawSegment(A, B, C, D, isReflexAngle, BelowOptimalRangeColor));
// Calculating the Points for the Optimal Range segment from the center of the gauge
@@ -1328,7 +1344,7 @@ namespace Tango.CircularGauge
Point C1 = GetCircumferencePoint(optimalEndAngleFromStart, arcradius2);
Point D1 = GetCircumferencePoint(optimalEndAngleFromStart, arcradius1);
bool isReflexAngle1 = Math.Abs(optimalEndAngleFromStart - optimalStartAngleFromStart) > 180.0;
- DrawSegment(A1, B1, C1, D1, isReflexAngle1, OptimalRangeColor);
+ _rangeIndicators.Add(DrawSegment(A1, B1, C1, D1, isReflexAngle1, OptimalRangeColor));
// Calculating the Points for the Above Optimal Range segment from the center of the gauge
@@ -1337,12 +1353,12 @@ namespace Tango.CircularGauge
Point C2 = GetCircumferencePoint(endAngle, arcradius2);
Point D2 = GetCircumferencePoint(endAngle, arcradius1);
bool isReflexAngle2 = Math.Abs(endAngle - optimalEndAngleFromStart) > 180.0;
- DrawSegment(A2, B2, C2, D2, isReflexAngle2, AboveOptimalRangeColor);
+ _rangeIndicators.Add(DrawSegment(A2, B2, C2, D2, isReflexAngle2, AboveOptimalRangeColor));
}
//Drawing the segment with two arc and two line
- private void DrawSegment(Point p1, Point p2, Point p3, Point p4, bool reflexangle, Color clr)
+ private Path DrawSegment(Point p1, Point p2, Point p3, Point p4, bool reflexangle, Color clr)
{
// Segment Geometry
@@ -1383,8 +1399,6 @@ namespace Tango.CircularGauge
else
rangestrokecolor = Colors.White;
-
-
rangeIndicator = new Path()
{
StrokeLineJoin = PenLineJoin.Round,
@@ -1410,8 +1424,10 @@ namespace Tango.CircularGauge
//Set Z index of range indicator
rangeIndicator.SetValue(Canvas.ZIndexProperty, 150);
// Adding the segment to the root grid
+
rootGrid.Children.Add(rangeIndicator);
+ return rangeIndicator;
}
#endregion