init
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.XMLUtils;
|
||||
|
||||
namespace DTS.Common.Interface.BuildTestSetup
|
||||
{
|
||||
public interface IBuildTestSetup : INotifyPropertyChanged
|
||||
{
|
||||
string DASSerialNumber { get; set; }
|
||||
string SetupName { get; set; }
|
||||
string SetupDescription { get; set; }
|
||||
string AutomaticMode { get; set; }
|
||||
string AutomaticModeDelay { get; set; }
|
||||
string WarnOnBatteryFail { get; set; }
|
||||
string ViewRealtime { get; set; }
|
||||
string RecordingMode { get; set; }
|
||||
string SamplesPerSecond { get; set; }
|
||||
string PreTriggerSeconds { get; set; }
|
||||
string PostTriggerSeconds { get; set; }
|
||||
string NumberOfEvents { get; set; }
|
||||
string WakeUpMotionTimeout { get; set; }
|
||||
string StrictDiagnostics { get; set; }
|
||||
string RequireConfirmationOnErrors { get; set; }
|
||||
string AllowSensorIdToBlankChannel { get; set; }
|
||||
string ExcitationWarmupTimeMS { get; set; }
|
||||
string PerformArmChecklist { get; set; }
|
||||
string CheckInputVoltage { get; set; }
|
||||
string CheckBatteryVoltage { get; set; }
|
||||
string CheckSquibResistance { get; set; }
|
||||
string CheckSensorIds { get; set; }
|
||||
string CheckStartEventLines { get; set; }
|
||||
string CheckTiltSensor { get; set; }
|
||||
string CheckTemperature { get; set; }
|
||||
string RequireAllUnitsPassArmCheckList { get; set; }
|
||||
string ROIDownload { get; set; }
|
||||
string ViewROIDownload { get; set; }
|
||||
string DownloadAll { get; set; }
|
||||
string RealtimeCharts { get; set; }
|
||||
string ROIStart { get; set; }
|
||||
string ROIEnd { get; set; }
|
||||
string ViewDownloadAll { get; set; }
|
||||
string Export { get; set; }
|
||||
//string ExportFormat { get; set; }
|
||||
string UseLabDetails { get; set; }
|
||||
string UseCustomerDetails { get; set; }
|
||||
string AllowMissingSensors { get; set; }
|
||||
string LastModified { get; set; }
|
||||
string LastModifiedBy { get; set; }
|
||||
string PostTestDiagnostics { get; set; }
|
||||
string UserTags { get; set; }
|
||||
string CalibrationBehavior { get; set; }
|
||||
string SuppressMissingSensorsWarning { get; set; }
|
||||
string NotAllChannelsRealTime { get; set; }
|
||||
string NotAllChannelsViewer { get; set; }
|
||||
string TriggerCheckStep { get; set; }
|
||||
string QuitTestWithoutWarning { get; set; }
|
||||
string ExportFolder { get; set; }
|
||||
string ExportCh10FilteredEUDesired { get; set; }
|
||||
//string ExportCh10UnfilteredEUDesired { get; set; }
|
||||
string ExportChryslerDDASDesired { get; set; }
|
||||
string ExportCSVADCDesired { get; set; }
|
||||
string ExportCSVFilteredDesired { get; set; }
|
||||
string ExportCSVMVDesired { get; set; }
|
||||
string ExportCSVUnfilteredDesired { get; set; }
|
||||
string ExportDiademADCDesired { get; set; }
|
||||
string ExportHDFADCDesired { get; set; }
|
||||
//string ExportHDFFilteredDesired { get; set; }
|
||||
string ExportHDFMVDesired { get; set; }
|
||||
string ExportHDFUnfilteredDesired { get; set; }
|
||||
string ExportISOFilteredDesired { get; set; }
|
||||
string ExportISOUnfilteredDesired { get; set; }
|
||||
string ExportRDFADCDesired { get; set; }
|
||||
//string ExportSomatFilteredDesired { get; set; }
|
||||
//string ExportSomatUnfilteredDesired { get; set; }
|
||||
string ExportTDASADCDesired { get; set; }
|
||||
string ExportTDMSADCDesired { get; set; }
|
||||
//string ExportToyotaFilteredDesired { get; set; }
|
||||
string ExportToyotaUnfilteredDesired { get; set; }
|
||||
string ExportTSVFilteredDesired { get; set; }
|
||||
string ExportTSVUnfilteredDesired { get; set; }
|
||||
string ExportXLSXFilteredDesired { get; set; }
|
||||
string ExportXLSXUnfilteredDesired { get; set; }
|
||||
string ExportASCDesired { get; set; }
|
||||
string DownloadFolder { get; set; }
|
||||
string CommonStatusLine { get; set; }
|
||||
string UploadData { get; set; }
|
||||
string UploadDataFolder { get; set; }
|
||||
string UseTestEngineerDetails { get; set; }
|
||||
string AutoArm { get; set; }
|
||||
string Streaming { get; set; }
|
||||
string MeasureSquibResistances { get; set; }
|
||||
|
||||
List<GroupXMLClass> Groups { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,541 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace DTS.Common.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class used to display spinning animation circle to indicate
|
||||
/// system is busy with background process
|
||||
///
|
||||
/// Adapting from open source found via Google so it doesn' conform to our
|
||||
/// coding formatting or commenting rules
|
||||
/// </summary>
|
||||
public class BusyWaitAnimation
|
||||
{
|
||||
|
||||
// Constants =========================================================
|
||||
private const double NumberOfDegreesInCircle = 360;
|
||||
private const double NumberOfDegreesInHalfCircle = NumberOfDegreesInCircle / 2;
|
||||
private const int DefaultInnerCircleRadius = 8;
|
||||
private const int DefaultOuterCircleRadius = 10;
|
||||
private const int DefaultNumberOfSpoke = 10;
|
||||
private const int DefaultSpokeThickness = 4;
|
||||
private readonly Color _defaultColor = Color.DarkGray;
|
||||
|
||||
private const int MacOsxInnerCircleRadius = 5;
|
||||
private const int MacOsxOuterCircleRadius = 11;
|
||||
private const int MacOsxNumberOfSpoke = 12;
|
||||
private const int MacOsxSpokeThickness = 2;
|
||||
|
||||
private const int FireFoxInnerCircleRadius = 6;
|
||||
private const int FireFoxOuterCircleRadius = 7;
|
||||
private const int FireFoxNumberOfSpoke = 9;
|
||||
private const int FireFoxSpokeThickness = 4;
|
||||
|
||||
private const int Ie7InnerCircleRadius = 8;
|
||||
private const int Ie7OuterCircleRadius = 9;
|
||||
private const int Ie7NumberOfSpoke = 24;
|
||||
private const int Ie7SpokeThickness = 4;
|
||||
|
||||
// Enumeration =======================================================
|
||||
public enum StylePresets
|
||||
{
|
||||
MacOsx,
|
||||
Firefox,
|
||||
Ie7,
|
||||
Custom
|
||||
}
|
||||
|
||||
// Attributes ========================================================
|
||||
private readonly DispatcherTimer _timer;
|
||||
private bool _isTimerActive;
|
||||
private int _numberOfSpoke;
|
||||
private int _spokeThickness;
|
||||
private int _progressValue;
|
||||
private int _outerCircleRadius;
|
||||
private int _innerCircleRadius;
|
||||
private PointF _centerPoint;
|
||||
private Color _color;
|
||||
private Color[] _colors;
|
||||
private double[] _angles;
|
||||
private StylePresets _stylePreset;
|
||||
|
||||
// Properties ========================================================
|
||||
/// <summary>
|
||||
/// Gets or sets the lightest color of the circle.
|
||||
/// </summary>
|
||||
/// <value>The lightest color of the circle.</value>
|
||||
[TypeConverter("System.Drawing.ColorConverter"),
|
||||
Category("LoadingCircle"),
|
||||
Description("Sets the color of spoke.")]
|
||||
public Color Color
|
||||
{
|
||||
get => _color;
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
|
||||
GenerateColorsPallet();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Background color
|
||||
/// </summary>
|
||||
public Color BgColor
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the outer circle radius.
|
||||
/// </summary>
|
||||
/// <value>The outer circle radius.</value>
|
||||
[Description("Gets or sets the radius of outer circle."),
|
||||
Category("LoadingCircle")]
|
||||
public int OuterCircleRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_outerCircleRadius == 0)
|
||||
{ _outerCircleRadius = DefaultOuterCircleRadius; }
|
||||
|
||||
return _outerCircleRadius;
|
||||
}
|
||||
set
|
||||
{
|
||||
_outerCircleRadius = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the inner circle radius.
|
||||
/// </summary>
|
||||
/// <value>The inner circle radius.</value>
|
||||
[Description("Gets or sets the radius of inner circle."),
|
||||
Category("LoadingCircle")]
|
||||
public int InnerCircleRadius
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_innerCircleRadius == 0)
|
||||
_innerCircleRadius = DefaultInnerCircleRadius;
|
||||
|
||||
return _innerCircleRadius;
|
||||
}
|
||||
set
|
||||
{
|
||||
_innerCircleRadius = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of spoke.
|
||||
/// </summary>
|
||||
/// <value>The number of spoke.</value>
|
||||
[Description("Gets or sets the number of spoke."),
|
||||
Category("LoadingCircle")]
|
||||
public int NumberSpoke
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_numberOfSpoke == 0)
|
||||
_numberOfSpoke = DefaultNumberOfSpoke;
|
||||
|
||||
return _numberOfSpoke;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_numberOfSpoke != value && _numberOfSpoke > 0)
|
||||
{
|
||||
_numberOfSpoke = value;
|
||||
GenerateColorsPallet();
|
||||
GetSpokesAngles();
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="T:LoadingCircle"/> is active.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if active; otherwise, <c>false</c>.</value>
|
||||
[Description("Gets or sets the number of spoke."),
|
||||
Category("LoadingCircle")]
|
||||
public bool Active
|
||||
{
|
||||
get => _isTimerActive;
|
||||
set
|
||||
{
|
||||
_isTimerActive = value;
|
||||
ActiveTimer();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the spoke thickness.
|
||||
/// </summary>
|
||||
/// <value>The spoke thickness.</value>
|
||||
[Description("Gets or sets the thickness of a spoke."),
|
||||
Category("LoadingCircle")]
|
||||
public int SpokeThickness
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_spokeThickness <= 0)
|
||||
_spokeThickness = DefaultSpokeThickness;
|
||||
|
||||
return _spokeThickness;
|
||||
}
|
||||
set
|
||||
{
|
||||
_spokeThickness = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the rotation speed.
|
||||
/// </summary>
|
||||
/// <value>The rotation speed.</value>
|
||||
[Description("Gets or sets the rotation speed. Higher the slower."),
|
||||
Category("LoadingCircle")]
|
||||
public long RotationSpeed
|
||||
{
|
||||
get => _timer.Interval.Ticks;
|
||||
set
|
||||
{
|
||||
if (value > 0)
|
||||
_timer.Interval = TimeSpan.FromMilliseconds(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Quickly sets the style to one of these presets, or a custom style if desired
|
||||
/// </summary>
|
||||
/// <value>The style preset.</value>
|
||||
[Category("LoadingCircle"),
|
||||
Description("Quickly sets the style to one of these presets, or a custom style if desired"),
|
||||
DefaultValue(typeof(StylePresets), "Custom")]
|
||||
public StylePresets StylePreset
|
||||
{
|
||||
get => _stylePreset;
|
||||
set
|
||||
{
|
||||
_stylePreset = value;
|
||||
|
||||
switch (_stylePreset)
|
||||
{
|
||||
case StylePresets.MacOsx:
|
||||
SetCircleAppearance(MacOsxNumberOfSpoke,
|
||||
MacOsxSpokeThickness, MacOsxInnerCircleRadius,
|
||||
MacOsxOuterCircleRadius);
|
||||
break;
|
||||
case StylePresets.Firefox:
|
||||
SetCircleAppearance(FireFoxNumberOfSpoke,
|
||||
FireFoxSpokeThickness, FireFoxInnerCircleRadius,
|
||||
FireFoxOuterCircleRadius);
|
||||
break;
|
||||
case StylePresets.Ie7:
|
||||
SetCircleAppearance(Ie7NumberOfSpoke,
|
||||
Ie7SpokeThickness, Ie7InnerCircleRadius,
|
||||
Ie7OuterCircleRadius);
|
||||
break;
|
||||
case StylePresets.Custom:
|
||||
SetCircleAppearance(DefaultNumberOfSpoke,
|
||||
DefaultSpokeThickness,
|
||||
DefaultInnerCircleRadius,
|
||||
DefaultOuterCircleRadius);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int _xxx = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Construtor Initializes a new instance of the <see cref="T:LoadingCircle"/> class.
|
||||
/// </summary>
|
||||
public BusyWaitAnimation()
|
||||
{
|
||||
_xxx++;
|
||||
|
||||
_color = _defaultColor;
|
||||
BgColor = Color.LightGray;
|
||||
|
||||
GenerateColorsPallet();
|
||||
GetSpokesAngles();
|
||||
GetControlCenterPoint();
|
||||
|
||||
_timer = new DispatcherTimer();
|
||||
_timer.Tick += new EventHandler(aTimer_Tick);
|
||||
ActiveTimer();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Tick event of the aTimer control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
|
||||
void aTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
_progressValue = ++_progressValue % _numberOfSpoke;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
|
||||
/// </summary>
|
||||
/// <param name="g">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
|
||||
private void OnPaint(Graphics g)
|
||||
{
|
||||
if (_numberOfSpoke <= 0) return;
|
||||
_backgroundGraphics.Clear(BgColor);
|
||||
|
||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
var intPosition = _progressValue;
|
||||
for (var intCounter = 0; intCounter < _numberOfSpoke; intCounter++)
|
||||
{
|
||||
intPosition = intPosition % _numberOfSpoke;
|
||||
DrawLine(_backgroundGraphics,
|
||||
GetCoordinate(_centerPoint, _innerCircleRadius, _angles[intPosition]),
|
||||
GetCoordinate(_centerPoint, _outerCircleRadius, _angles[intPosition]),
|
||||
_colors[intCounter], _spokeThickness);
|
||||
intPosition++;
|
||||
}
|
||||
|
||||
g.DrawImage(_backgroundImage, new Point(_drawArea.Left, _drawArea.Top));
|
||||
}
|
||||
|
||||
|
||||
// Methods ===========================================================
|
||||
/// <summary>
|
||||
/// Darkens a specified color.
|
||||
/// </summary>
|
||||
/// <param name="objColor">Color to darken.</param>
|
||||
/// <param name="intPercent">The percent of darken.</param>
|
||||
/// <returns>The new color generated.</returns>
|
||||
private Color Darken(Color objColor, int intPercent)
|
||||
{
|
||||
int intRed = objColor.R;
|
||||
int intGreen = objColor.G;
|
||||
int intBlue = objColor.B;
|
||||
return Color.FromArgb(intPercent, Math.Min(intRed, byte.MaxValue), Math.Min(intGreen, byte.MaxValue), Math.Min(intBlue, byte.MaxValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates the colors pallet.
|
||||
/// </summary>
|
||||
private void GenerateColorsPallet()
|
||||
{
|
||||
_colors = GenerateColorsPallet(_color, Active, _numberOfSpoke);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates the colors pallet.
|
||||
/// </summary>
|
||||
/// <param name="color">Color of the lightest spoke.</param>
|
||||
/// <param name="bhadeColor">if set to <c>true</c> the color will be shaded on X spoke.</param>
|
||||
/// <param name="nbSpoke"></param>
|
||||
/// <returns>An array of color used to draw the circle.</returns>
|
||||
private Color[] GenerateColorsPallet(Color color, bool bhadeColor, int nbSpoke)
|
||||
{
|
||||
var objColors = new Color[NumberSpoke];
|
||||
|
||||
// Value is used to simulate a gradient feel... For each spoke, the
|
||||
// color will be darken by value in intIncrement.
|
||||
var bytIncrement = (byte)(byte.MaxValue / NumberSpoke);
|
||||
|
||||
//Reset variable in case of multiple passes
|
||||
byte percentageOfDarken = 0;
|
||||
|
||||
for (var intCursor = 0; intCursor < NumberSpoke; intCursor++)
|
||||
{
|
||||
if (bhadeColor)
|
||||
{
|
||||
if (intCursor == 0 || intCursor < NumberSpoke - nbSpoke)
|
||||
objColors[intCursor] = color;
|
||||
else
|
||||
{
|
||||
// Increment alpha channel color
|
||||
percentageOfDarken += bytIncrement;
|
||||
|
||||
// Ensure that we don't exceed the maximum alpha
|
||||
// channel value (255)
|
||||
if (percentageOfDarken > byte.MaxValue)
|
||||
percentageOfDarken = byte.MaxValue;
|
||||
|
||||
// Determine the spoke forecolor
|
||||
objColors[intCursor] = Darken(color, percentageOfDarken);
|
||||
}
|
||||
}
|
||||
else
|
||||
objColors[intCursor] = color;
|
||||
}
|
||||
|
||||
return objColors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the control center point.
|
||||
/// </summary>
|
||||
private void GetControlCenterPoint()
|
||||
{
|
||||
// m_CenterPoint = GetControlCenterPoint(this);
|
||||
_centerPoint = new PointF(_drawArea.Width / 2, _drawArea.Height / 2 - 1);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Draws the line with GDI+.
|
||||
/// </summary>
|
||||
/// <param name="graphics">The Graphics object.</param>
|
||||
/// <param name="pointOne">The point one.</param>
|
||||
/// <param name="pointTwo">The point two.</param>
|
||||
/// <param name="color">Color of the spoke.</param>
|
||||
/// <param name="lineThickness">The thickness of spoke.</param>
|
||||
private void DrawLine(Graphics graphics, PointF pointOne, PointF pointTwo,
|
||||
Color color, int lineThickness)
|
||||
{
|
||||
using (var objPen = new Pen(new SolidBrush(color), lineThickness))
|
||||
{
|
||||
objPen.StartCap = LineCap.Round;
|
||||
objPen.EndCap = LineCap.Round;
|
||||
graphics.DrawLine(objPen, pointOne, pointTwo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the coordinate.
|
||||
/// </summary>
|
||||
/// <param name="circleCenter">The Circle center.</param>
|
||||
/// <param name="radius">The radius.</param>
|
||||
/// <param name="angle">The angle.</param>
|
||||
/// <returns></returns>
|
||||
private PointF GetCoordinate(PointF circleCenter, int radius, double angle)
|
||||
{
|
||||
var dblAngle = Math.PI * angle / NumberOfDegreesInHalfCircle;
|
||||
|
||||
return new PointF(circleCenter.X + radius * (float)Math.Cos(dblAngle),
|
||||
circleCenter.Y + radius * (float)Math.Sin(dblAngle));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spokes angles.
|
||||
/// </summary>
|
||||
private void GetSpokesAngles()
|
||||
{
|
||||
_angles = GetSpokesAngles(NumberSpoke);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spoke angles.
|
||||
/// </summary>
|
||||
/// <param name="numberSpoke">The number spoke.</param>
|
||||
/// <returns>An array of angle.</returns>
|
||||
private double[] GetSpokesAngles(int numberSpoke)
|
||||
{
|
||||
var angles = new double[numberSpoke];
|
||||
var angle = NumberOfDegreesInCircle / numberSpoke;
|
||||
|
||||
for (var shtCounter = 0; shtCounter < numberSpoke; shtCounter++)
|
||||
angles[shtCounter] = (shtCounter == 0 ? angle : angles[shtCounter - 1] + angle);
|
||||
|
||||
return angles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Actives the timer.
|
||||
/// </summary>
|
||||
private void ActiveTimer()
|
||||
{
|
||||
if (_isTimerActive)
|
||||
_timer.Start();
|
||||
else
|
||||
{
|
||||
_timer.Stop();
|
||||
_progressValue = 0;
|
||||
}
|
||||
|
||||
GenerateColorsPallet();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the circle appearance.
|
||||
/// </summary>
|
||||
/// <param name="numberSpoke">The number spoke.</param>
|
||||
/// <param name="spokeThickness">The spoke thickness.</param>
|
||||
/// <param name="innerCircleRadius">The inner circle radius.</param>
|
||||
/// <param name="outerCircleRadius">The outer circle radius.</param>
|
||||
public void SetCircleAppearance(int numberSpoke, int spokeThickness, int innerCircleRadius, int outerCircleRadius)
|
||||
{
|
||||
NumberSpoke = numberSpoke;
|
||||
SpokeThickness = spokeThickness;
|
||||
InnerCircleRadius = innerCircleRadius;
|
||||
OuterCircleRadius = outerCircleRadius;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
#region new methods
|
||||
|
||||
private Rectangle _drawArea;
|
||||
private Graphics _graphics;
|
||||
private int _hDc = int.MinValue;
|
||||
private Bitmap _backgroundImage;
|
||||
private Graphics _backgroundGraphics;
|
||||
|
||||
private void Invalidate()
|
||||
{
|
||||
if (_graphics != null)
|
||||
{
|
||||
_graphics.DrawImageUnscaled(_backgroundImage, new Point(_drawArea.Left, _drawArea.Top));
|
||||
OnPaint(_graphics);
|
||||
}
|
||||
}
|
||||
|
||||
public Graphics GDIGraphics => _graphics;
|
||||
|
||||
public int hDC
|
||||
{
|
||||
set
|
||||
{
|
||||
|
||||
if (_graphics != null) _graphics.Dispose();
|
||||
_hDc = value;
|
||||
_graphics = Graphics.FromHdc(new IntPtr(value));
|
||||
|
||||
}
|
||||
|
||||
get => _hDc;
|
||||
}
|
||||
|
||||
public void SetDrawArea(Rectangle rect)
|
||||
{
|
||||
_drawArea = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
|
||||
GetControlCenterPoint();
|
||||
|
||||
_backgroundImage = new Bitmap(rect.Width, rect.Height);
|
||||
|
||||
_backgroundGraphics = Graphics.FromImage(_backgroundImage);
|
||||
_backgroundGraphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using DTS.Common.Controls;
|
||||
using DTS.Common.Events;
|
||||
using Prism.Ioc;
|
||||
using Prism.Events;
|
||||
|
||||
namespace DTS.Common.Behaviors
|
||||
{
|
||||
public class TextBoxPasteBehavior
|
||||
{
|
||||
public static readonly DependencyProperty PasteCommandProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"PasteCommand",
|
||||
typeof(ICommand),
|
||||
typeof(TextBoxPasteBehavior),
|
||||
new FrameworkPropertyMetadata(PasteCommandChanged)
|
||||
);
|
||||
|
||||
public static ICommand GetPasteCommand(DependencyObject target)
|
||||
{
|
||||
return (ICommand)target.GetValue(PasteCommandProperty);
|
||||
}
|
||||
|
||||
public static void SetPasteCommand(DependencyObject target, ICommand value)
|
||||
{
|
||||
target.SetValue(PasteCommandProperty, value);
|
||||
}
|
||||
|
||||
private static void PasteCommandChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
TextBox textBox = sender as TextBox;
|
||||
if (null == textBox && sender is ChannelCodeBuilder ccb)
|
||||
{
|
||||
textBox = ccb.MainEditBox;
|
||||
}
|
||||
else if (null == textBox && sender is ChannelNameBuilder cnb)
|
||||
{
|
||||
textBox = cnb.MainEditBox;
|
||||
}
|
||||
if (null == textBox) { return; }
|
||||
var newValue = (ICommand)e.NewValue;
|
||||
textBox.RemoveHandler(CommandManager.ExecutedEvent, new RoutedEventHandler(CommandExecuted));
|
||||
if (newValue != null)
|
||||
{
|
||||
textBox.AddHandler(CommandManager.ExecutedEvent, new RoutedEventHandler(CommandExecuted), true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CommandExecuted(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!(e is ExecutedRoutedEventArgs eArgs)) { return; }
|
||||
|
||||
if (eArgs.Command != ApplicationCommands.Paste)
|
||||
{
|
||||
if (eArgs.Command is RoutedUICommand secureUICommand)
|
||||
{
|
||||
if (secureUICommand.Name != "Paste") { return; }
|
||||
}
|
||||
else { return; }
|
||||
}
|
||||
TextBox textBox = sender as TextBox;
|
||||
if (null == textBox && sender is ChannelCodeBuilder ccb)
|
||||
{
|
||||
textBox = ccb.MainEditBox;
|
||||
}
|
||||
else if (null == textBox && sender is ChannelNameBuilder cnb)
|
||||
{
|
||||
textBox = cnb.MainEditBox;
|
||||
}
|
||||
|
||||
var command = GetPasteCommand(textBox);
|
||||
|
||||
try
|
||||
{
|
||||
var text = Clipboard.GetText();
|
||||
|
||||
if (command.CanExecute(null))
|
||||
command.Execute(textBox);
|
||||
e.Handled = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var eventAggregator = ContainerLocator.Container.Resolve<IEventAggregator>();
|
||||
eventAggregator.GetEvent<PageErrorEvent>().Publish(new PageErrorArg(new[] { ex.Message }, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DTS.Common.Validators
|
||||
{
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S101:Types should be named in PascalCase", Justification = "acronyms")]
|
||||
public class UARTBAUDRateValidator : ValidationRule
|
||||
{
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
||||
{
|
||||
if (value is string s)
|
||||
{
|
||||
if (!long.TryParse(s, out var temp))
|
||||
{
|
||||
return new ValidationResult(false, StringResources.InvalidFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (temp > Constant.EmbeddedSensors.BAUD_RATE_MAX)
|
||||
{
|
||||
return new ValidationResult(false, $"{StringResources.MaxValueIs}{Constant.EmbeddedSensors.BAUD_RATE_MAX}");
|
||||
}
|
||||
if ( temp < Constant.EmbeddedSensors.BAUD_RATE_MIN)
|
||||
{
|
||||
return new ValidationResult(false, $"{StringResources.MinValueIs}{Constant.EmbeddedSensors.BAUD_RATE_MIN}");
|
||||
}
|
||||
return new ValidationResult(true, null);
|
||||
}
|
||||
}
|
||||
return new ValidationResult(false, StringResources.InvalidFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface.CustomChannels
|
||||
{
|
||||
public interface ICustomChannelsExportView : IBaseView { }
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Interface.TestSetups;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Classes.TestSetups
|
||||
{
|
||||
public class ISFSensorRecord : IISFSensorRecord
|
||||
{
|
||||
private char[] _record1 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH the whole first record
|
||||
/// </summary>
|
||||
public char[] Record1
|
||||
{
|
||||
get => _record1;
|
||||
set
|
||||
{
|
||||
_record1.Fill(' ');
|
||||
Array.Copy(value, 0, _record1, 0, Math.Min(ConstantsAndEnums.RECORD_LENGTH, value.Length));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2 characters, starting at character 75
|
||||
/// </summary>
|
||||
public char[] Tag
|
||||
{
|
||||
get => _record1.GetValues(75, 2);
|
||||
set => _record1.SetValues(value, 75, 2, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 5 characters start at character 7
|
||||
/// </summary>
|
||||
public char[] DataChannelNumber
|
||||
{
|
||||
get => _record1.GetValues(7, 5);
|
||||
set => _record1.SetValues(value, 7, 5, ' ');
|
||||
}
|
||||
|
||||
public void SetDataChannelNumber(short value)
|
||||
{
|
||||
DataChannelNumber = value.ToString().ToCharArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 1 character, starting at character 15
|
||||
/// </summary>
|
||||
public bool UserIdSensorIDIsNotSpecified
|
||||
{
|
||||
get => _record1[15] == '1';
|
||||
set => _record1[15] = value ? '1' : '0';
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters start at 19
|
||||
/// </summary>
|
||||
public char[] CapacityCharacters
|
||||
{
|
||||
get => _record1.GetValues(19, 11);
|
||||
set => _record1.SetValues(value, 19, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetCapacity(double capacity)
|
||||
{
|
||||
CapacityCharacters = capacity.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
public double GetCapacity()
|
||||
{
|
||||
var s = CapacityCharacters.ToString();
|
||||
s = s.Trim();
|
||||
if (double.TryParse(s, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 12 characters, starting at 30
|
||||
/// </summary>
|
||||
public char[] SerialNumber
|
||||
{
|
||||
get => _record1.GetValues(30, 12);
|
||||
set => _record1.SetValues(value, 30, 12, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters, start at 42
|
||||
/// is Sensitivity/1000 (V)
|
||||
/// can also be c0 if polynomial
|
||||
/// </summary>
|
||||
public char[] Sensitivity
|
||||
{
|
||||
get => _record1.GetValues(42, 11);
|
||||
set => _record1.SetValues(value, 42, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetSensitivity(double sensitivity)
|
||||
{
|
||||
Sensitivity = sensitivity.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
public double GetSensitivity()
|
||||
{
|
||||
var s = Sensitivity.ToString().Trim();
|
||||
if (double.TryParse(s, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters starting at 53
|
||||
/// </summary>
|
||||
public char[] BridgeResistance
|
||||
{
|
||||
get => _record1.GetValues(53, 11);
|
||||
set => _record1.SetValues(value, 53, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetBridgeResistance(double resistance)
|
||||
{
|
||||
BridgeResistance = resistance.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
private char[] _record2 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH
|
||||
/// </summary>
|
||||
public char[] Record2
|
||||
{
|
||||
get => _record2;
|
||||
set
|
||||
{
|
||||
_record2.Fill(' ');
|
||||
Array.Copy(value, 0, _record2, 0, ConstantsAndEnums.RECORD_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 12 characters, starting at character 7 (of record 2)
|
||||
/// </summary>
|
||||
public char[] EngineeringUnits
|
||||
{
|
||||
get => _record2.GetValues(7, 12);
|
||||
set => _record2.SetValues(value, 7, 12, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters, starting at character 20
|
||||
/// </summary>
|
||||
public char[] C1
|
||||
{
|
||||
get => _record2.GetValues(20, 11);
|
||||
set => _record2.SetValues(value, 20, 11, ' ');
|
||||
}
|
||||
public void SetC1(double c1)
|
||||
{
|
||||
C1 = c1.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
public double GetC1()
|
||||
{
|
||||
var s = C1.ToString().Trim();
|
||||
if (double.TryParse(s, out var d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
return double.NaN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 17 characters, starting at character 31
|
||||
/// </summary>
|
||||
public char[] EID
|
||||
{
|
||||
get => _record2.GetValues(31, 17);
|
||||
set => _record2.SetValues(value, 31, 17, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 4 characters, starting at 49
|
||||
/// </summary>
|
||||
public char[] Unknown1
|
||||
{
|
||||
get => _record2.GetValues(49, 4);
|
||||
set => _record2.SetValues(value, 49, 4, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2 characters, starting at 53
|
||||
/// </summary>
|
||||
public char[] Unknown2
|
||||
{
|
||||
get => _record2.GetValues(53, 2);
|
||||
set => _record2.SetValues(value, 53, 2, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters starting at 55 (TOM ONLY [sensortype TI])
|
||||
/// is /1000 of ordinary
|
||||
/// </summary>
|
||||
public char[] FireDelay
|
||||
{
|
||||
get => _record2.GetValues(55, 11);
|
||||
set => _record2.SetValues(value, 55, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetFireDelay(double fireDelay)
|
||||
{
|
||||
FireDelay = fireDelay.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 8 characters, starting at 66
|
||||
/// STANDARD is the default value, we don't really support anything else currently
|
||||
/// </summary>
|
||||
public char[] TOMConfigurationName
|
||||
{
|
||||
get => _record2.GetValues(66, 8);
|
||||
set => _record2.SetValues(value, 66, 8, ' ');
|
||||
}
|
||||
|
||||
private char[] _record3 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH, third record of 4
|
||||
/// </summary>
|
||||
public char[] Record3
|
||||
{
|
||||
get => _record3;
|
||||
set
|
||||
{
|
||||
_record3.Fill(' ');
|
||||
Array.Copy(value, 0, _record3, 0, Math.Min(ConstantsAndEnums.RECORD_LENGTH, value.Length));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 15 characters start at 14 of record 3
|
||||
/// </summary>
|
||||
public char[] CommentPart1
|
||||
{
|
||||
get => _record3.GetValues(14, 15);
|
||||
set => _record3.SetValues(value, 14, 15, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 40 characters starting at 33
|
||||
/// </summary>
|
||||
public char[] CommentPart2
|
||||
{
|
||||
get => _record3.GetValues(33, 40);
|
||||
set => _record3.SetValues(value, 33, 40, ' ');
|
||||
}
|
||||
|
||||
private char[] _record4 = new char[ConstantsAndEnums.RECORD_LENGTH];
|
||||
|
||||
/// <summary>
|
||||
/// RECORD_LENGTH, the 4th record of 4
|
||||
/// </summary>
|
||||
public char[] Record4
|
||||
{
|
||||
get => _record4;
|
||||
set
|
||||
{
|
||||
_record4.Fill(' ');
|
||||
Array.Copy(value, 0, _record4, 0, Math.Min(ConstantsAndEnums.RECORD_LENGTH, value.Length));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 15 characters, starting at character 12
|
||||
/// </summary>
|
||||
public char[] CommentPart3
|
||||
{
|
||||
get => _record4.GetValues(12, 15);
|
||||
set => _record4.SetValues(value, 12, 15, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sets CommentPart1, CommentPart2, CommentPart3
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void SetSensorComment(string s)
|
||||
{
|
||||
var newBuffer = new char[15 + 40 + 15];
|
||||
newBuffer.SetValues(s.ToCharArray(), 0, newBuffer.Length, ' ');
|
||||
//comment1 - 15 chars
|
||||
CommentPart1 = newBuffer.GetValues(0, 15);
|
||||
//comment2 - 40chars
|
||||
CommentPart2 = newBuffer.GetValues(15, 40);
|
||||
//comment3 - 15chars
|
||||
CommentPart3 = newBuffer.GetValues(55, 15);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 20 characters starting at 30
|
||||
/// checked for digital inputs (should contain N/O or N/C)
|
||||
/// </summary>
|
||||
public char[] SensorType
|
||||
{
|
||||
get => _record4.GetValues(30, 20);
|
||||
set => _record4.SetValues(value, 30, 20, ' ');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 11 characters starting at 50
|
||||
/// </summary>
|
||||
public char[] C2
|
||||
{
|
||||
get => _record4.GetValues(50, 11);
|
||||
set => _record4.SetValues(value, 50, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetC2(double c2)
|
||||
{
|
||||
C2 = c2.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// 11 characters starting at 61
|
||||
/// notice for poly's we should be multiplying by 1000D?
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(0, calibration.Records.Records[0].Sensitivity / 1000.0D);
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(1, c1 / 1000.0D);
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(2, c2 / 1000.0D);
|
||||
/// calibration.Records.Records.First().Poly.SetCoefficient(3, c3 / 1000.0D);
|
||||
/// </summary>
|
||||
public char[] C3
|
||||
{
|
||||
get => _record4.GetValues(61, 11);
|
||||
set => _record4.SetValues(value, 61, 11, ' ');
|
||||
}
|
||||
|
||||
public void SetC3(double c3)
|
||||
{
|
||||
C3 = c3.ToString(System.Globalization.CultureInfo.InvariantCulture).ToCharArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// writes record to stream
|
||||
/// </summary>
|
||||
/// <param name="writer"></param>
|
||||
public void Write(System.IO.BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Record1);
|
||||
writer.Write(Record2);
|
||||
writer.Write(Record3);
|
||||
writer.Write(Record4);
|
||||
}
|
||||
|
||||
public ISFSensorRecord()
|
||||
{
|
||||
_record1.Fill(' ');
|
||||
_record2.Fill(' ');
|
||||
_record3.Fill(' ');
|
||||
_record4.Fill(' ');
|
||||
TOMConfigurationName = "STANDARD".ToCharArray();
|
||||
}
|
||||
|
||||
public void SetSensor(ISensorData sensor)
|
||||
{
|
||||
SerialNumber = sensor.SerialNumber.ToCharArray();
|
||||
var sc = sensor.GetLatestCalibration();
|
||||
SetSensitivity(sc.Records.Records[0].Sensitivity);
|
||||
SetBridgeResistance(sensor.BridgeResistance);
|
||||
SetCapacity(sensor.Capacity);
|
||||
SetSensorComment(sensor.Comment);
|
||||
Tag = "VS".ToCharArray();//ConstantsAndEnums.ISFKnownChannelTypes.VS.ToString().ToCharArray();
|
||||
UserIdSensorIDIsNotSpecified = true;
|
||||
EID = sensor.EID.ToCharArray();
|
||||
EngineeringUnits = sc.EngineeringUnits.ToCharArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user