init
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface IMainViewModel : IBaseViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Main View.
|
||||
/// </summary>
|
||||
IBaseView View { get; }
|
||||
|
||||
object ContextNavigationRegion { get; set; }
|
||||
|
||||
object ContextGraphRegion { get; set; }
|
||||
|
||||
object ContextTestsRegion { get; set; }
|
||||
object ContextGraphsRegion { get; set; }
|
||||
object ContextLegendRegion { get; set; }
|
||||
|
||||
object ContextDiagRegion { get; set; }
|
||||
object ContextStatsRegion { get; set; }
|
||||
object ContextCursorRegion { get; set; }
|
||||
|
||||
object ContextPropertyRegion { get; set; }
|
||||
|
||||
List<FrameworkElement> GetRegions();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using DTS.Common.Interface.Hardware;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
|
||||
namespace DTS.Common.Converters
|
||||
{
|
||||
public class DiagStatusShuntColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (value is DiagStatuses status)
|
||||
{
|
||||
if (status == DiagStatuses.NoResults) { return BrushesAndColors.Brush_ApplicationStatus_Idle; }
|
||||
if ((status & DiagStatuses.FailedShunt) == DiagStatuses.FailedShunt)
|
||||
{
|
||||
return BrushesAndColors.Brush_ApplicationStatus_Failed;
|
||||
}
|
||||
return BrushesAndColors.Brush_ApplicationStatus_Complete;
|
||||
}
|
||||
return BrushesAndColors.Brush_ApplicationStatus_Idle;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return value.Equals(true) ? parameter : Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.Common.Classes
|
||||
{
|
||||
/// <summary>
|
||||
/// This class represents work requested of the services framework
|
||||
/// </summary>
|
||||
public class ServiceCall
|
||||
{
|
||||
public bool Started { get; set; } = false;
|
||||
/// <summary>
|
||||
/// the work to be done when service call is made
|
||||
/// </summary>
|
||||
public Action WorkAction{ get; set; }
|
||||
/// <summary>
|
||||
/// indicates the service call is complete
|
||||
/// </summary>
|
||||
public void MarkDone()
|
||||
{
|
||||
ServiceQueue.MarkFinished(this);
|
||||
}
|
||||
public string Name { get; set; }
|
||||
public ServiceCall(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// this class handles calls of the services framework by doing a little managing of who gets to run and when
|
||||
/// </summary>
|
||||
public class ServiceQueue
|
||||
{
|
||||
/// <summary>
|
||||
/// just a lock to keep resource access thread safe
|
||||
/// </summary>
|
||||
private static readonly object QueueLock = new object();
|
||||
/// <summary>
|
||||
/// this is sort of a Queue, actions are enqueued when the are instantiated,
|
||||
/// but using a list allows us to re-order then when needed and to remove items that are no longer needed and haven't been
|
||||
/// started yet
|
||||
/// </summary>
|
||||
private readonly List<ServiceCall> ServiceCalls = new List<ServiceCall>();
|
||||
|
||||
/// <summary>
|
||||
/// the singleton/the instance of the queue
|
||||
/// </summary>
|
||||
private static ServiceQueue _serviceQueue = new ServiceQueue();
|
||||
|
||||
/// <summary>
|
||||
/// adds a new item for the services framework to handle
|
||||
/// </summary>
|
||||
/// <param name="call"></param>
|
||||
public static void Enqueue(ServiceCall call)
|
||||
{
|
||||
lock (QueueLock)
|
||||
{
|
||||
//adds work item to the queue
|
||||
_serviceQueue.ServiceCalls.Add(call);
|
||||
//start the item if it's the only item in the queue
|
||||
if (1 == _serviceQueue.ServiceCalls.Count)
|
||||
{
|
||||
StartWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// starts a call into the services framework
|
||||
/// </summary>
|
||||
private static void StartWork()
|
||||
{
|
||||
lock (QueueLock)
|
||||
{
|
||||
//if there's any calls in the queue, launch the first
|
||||
if (_serviceQueue.ServiceCalls.Any())
|
||||
{
|
||||
var work = _serviceQueue.ServiceCalls.First();
|
||||
//to prevent multiple startworks from starting the same work, just make sure it's not started
|
||||
if( work.Started ){ return; }
|
||||
work.Started = true;
|
||||
Task.Run(() => { work.WorkAction(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// marks a servicecall as finished, if it's the current work item the next work item will be started if any
|
||||
/// </summary>
|
||||
/// <param name="call"></param>
|
||||
public static void MarkFinished(ServiceCall call)
|
||||
{
|
||||
lock (QueueLock)
|
||||
{
|
||||
if (!_serviceQueue.ServiceCalls.Any() || !_serviceQueue.ServiceCalls.Contains(call))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_serviceQueue.ServiceCalls.First() != call)
|
||||
{
|
||||
//it wasn't being actively worked on, just remove
|
||||
_serviceQueue.ServiceCalls.Remove(call);
|
||||
return;
|
||||
}
|
||||
//this was the current work item, so we are free to start a new item
|
||||
_serviceQueue.ServiceCalls.RemoveAt(0);
|
||||
if (_serviceQueue.ServiceCalls.Any())
|
||||
{
|
||||
StartWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestSetupMetadata : ITestSetupMetadata
|
||||
{
|
||||
public string SetupName { get; set; }
|
||||
public DateTime TimeStamp { get; set; }
|
||||
public List<ITestGraphs> TestGraphs { get; set; }
|
||||
public CalibrationBehaviors CalibrationBehavior { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user