init
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
using DTS.Common.Base;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
|
||||
namespace DTS.Common.Interface.Sensors.SensorsList
|
||||
{
|
||||
public interface ISensorsListView : IBaseView
|
||||
{
|
||||
void HandleColumns(CalibrationBehaviors calibrationBehavior);
|
||||
void SetIncludedVisible(bool bUsesIncludeColumn);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface ICheckChannelsView: IBaseView { }
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using DTS.Common.Classes;
|
||||
using DTS.Common.Events;
|
||||
using DTS.Common.Interface;
|
||||
using DTS.Common.Base;
|
||||
using Microsoft.Practices.Prism.Regions;
|
||||
using Microsoft.Practices.Prism.Events;
|
||||
using Microsoft.Practices.Unity;
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable CheckNamespace
|
||||
namespace DTS.Common
|
||||
{
|
||||
public class DTSViewRegionManager : IDTSViewRegionManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Injected unity container
|
||||
/// </summary>
|
||||
private readonly IUnityContainer _unityContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Injected region manager
|
||||
/// </summary>
|
||||
private readonly IRegionManager _regionManager;
|
||||
|
||||
/// <summary>
|
||||
/// Injected event aggregator
|
||||
/// </summary>
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="DTSRegionManager"/> class.
|
||||
/// </summary>
|
||||
/// <param name="unityContainer">Obtained reference of the unity container by using dependency injection.</param>
|
||||
/// <param name="regionManager">Obtained reference of the region manager by using dependency injection.</param>
|
||||
/// <param name="eventAggregator">Obtained reference of the event aggregator by using dependency injection.</param>
|
||||
public DTSViewRegionManager(IUnityContainer unityContainer, IRegionManager regionManager, IEventAggregator eventAggregator)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
_regionManager = regionManager;
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds View to the Main Region.
|
||||
/// </summary>
|
||||
/// <param name="viewDefinition">The View definition.</param>
|
||||
/// <param name="parameter">The parameter which uses to initialize the View.</param>
|
||||
public void AddView(ViewDefinition viewDefinition, object parameter)
|
||||
{
|
||||
AddView(viewDefinition, parameter, false);
|
||||
}
|
||||
|
||||
private IShellViewModel GetShellViewModelByRegionName(string regionName)
|
||||
{
|
||||
IShellViewModel shellVm = null;
|
||||
shellVm = _unityContainer.Resolve<IShellViewModel>();
|
||||
return shellVm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds View to the Main Region.
|
||||
/// </summary>
|
||||
/// <param name="viewDefinition">The View definition.</param>
|
||||
/// <param name="parameter">The parameter which uses to initialize the View.</param>
|
||||
/// <param name="allowMultipleInstances">A value indicating whether to allow to create the multiple views.</param>
|
||||
public void AddView(ViewDefinition viewDefinition, object parameter, bool allowMultipleInstances)
|
||||
{
|
||||
var shell = _unityContainer.Resolve<IShellViewModel>();
|
||||
|
||||
var viewModel = (IBaseViewModel)_unityContainer.Resolve(viewDefinition.ViewModelInterfaceType);
|
||||
var view = (IBaseView)_unityContainer.Resolve(viewDefinition.ViewInterfaceType);
|
||||
view.DataContext = viewModel;
|
||||
|
||||
_regionManager.AddViewToRegion(viewDefinition.RegionName, view);
|
||||
_regionManager.ActivateViewIfExists(viewDefinition.RegionName, viewDefinition.ViewInterfaceType);
|
||||
|
||||
if (parameter == null)
|
||||
viewModel.Initialize();
|
||||
else
|
||||
viewModel.Initialize(parameter);
|
||||
|
||||
switch (viewDefinition.RegionName)
|
||||
{
|
||||
case RegionNames.MainRegion:
|
||||
shell.ContextMainRegion = view;
|
||||
break;
|
||||
}
|
||||
|
||||
//IShellViewModel shellVm = GetShellViewModelByRegionName(viewDefinition.RegionName);
|
||||
//if (shellVm != null)
|
||||
//{
|
||||
// shellVm.ContextMainRegion = view;
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds View to the Main Region asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="viewDefinition">The View definition.</param>
|
||||
/// <param name="parameter">The parameter which uses to initialize the View.</param>
|
||||
public async Task AddViewAsync(ViewDefinition viewDefinition, object parameter)
|
||||
{
|
||||
await AddViewAsync(viewDefinition, parameter, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds View to the Main Region asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="viewDefinition">The View definition.</param>
|
||||
/// <param name="parameter">The parameter which uses to initialize the View.</param>
|
||||
/// <param name="allowMultipleInstances">A value indicating whether to allow to create the multiple views.</param>
|
||||
public async Task AddViewAsync(ViewDefinition viewDefinition, object parameter, bool allowMultipleInstances)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!allowMultipleInstances)
|
||||
{
|
||||
if (_regionManager.ActivateViewIfExists(viewDefinition.RegionName, viewDefinition.ViewInterfaceType))
|
||||
return;
|
||||
}
|
||||
|
||||
var viewModel = (IBaseViewModel)_unityContainer.Resolve(viewDefinition.ViewModelInterfaceType);
|
||||
var view = (IBaseView)_unityContainer.Resolve(viewDefinition.ViewInterfaceType);
|
||||
view.DataContext = viewModel;
|
||||
|
||||
_regionManager.AddViewToRegion(viewDefinition.RegionName, view);
|
||||
_regionManager.ActivateViewIfExists(viewDefinition.RegionName, viewDefinition.ViewInterfaceType);
|
||||
|
||||
if (parameter == null)
|
||||
await viewModel.InitializeAsync();
|
||||
else
|
||||
await viewModel.InitializeAsync(parameter);
|
||||
|
||||
var shellVm = GetShellViewModelByRegionName(viewDefinition.RegionName);
|
||||
|
||||
if (shellVm != null)
|
||||
{
|
||||
shellVm.ContextMainRegion = view;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_eventAggregator.GetEvent<RaiseNotification>()
|
||||
.Publish(new NotificationContentEventArgs(Utility.GetAllErrorMessages(ex)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes View from the Main Region asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="viewModel">The View-model.</param>
|
||||
public void RemoveView(IBaseViewModel viewModel)
|
||||
{
|
||||
// Jtacc is composed of three regions(three shells)
|
||||
foreach (var region in _regionManager.Regions)
|
||||
{
|
||||
var view =
|
||||
region.Views.FirstOrDefault(
|
||||
v => v is IBaseView && ReferenceEquals(((IBaseView)v).DataContext, viewModel));
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
viewModel.Cleanup();
|
||||
region.Deactivate(view);
|
||||
region.Remove(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveViewByRegionName(string regionName)
|
||||
{
|
||||
_regionManager.ClearRegion(regionName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads data for the specified View.
|
||||
/// </summary>
|
||||
/// <param name="interfaceForView">Type of the View's interface.</param>
|
||||
/// <param name="parameter">The parameter which uses to initialize the View.</param>
|
||||
public void RefreshView(Type interfaceForView, object parameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var region in _regionManager.Regions)
|
||||
{
|
||||
var existingView = _regionManager.GetView(region.Name, interfaceForView) as IBaseView;
|
||||
|
||||
if (existingView != null)
|
||||
{
|
||||
var viewModel = existingView.DataContext as IBaseViewModel;
|
||||
if (viewModel != null)
|
||||
{
|
||||
viewModel.Cleanup();
|
||||
|
||||
if (parameter == null)
|
||||
viewModel.Initialize();
|
||||
else
|
||||
viewModel.Initialize(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_eventAggregator.GetEvent<RaiseNotification>().Publish(new NotificationContentEventArgs(Utility.GetAllErrorMessages(ex)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads data for the specified View asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="interfaceForView">Type of the View's interface.</param>
|
||||
/// <param name="parameter">The parameter which uses to initialize the View.</param>
|
||||
public async Task RefreshViewAsync(Type interfaceForView, object parameter)
|
||||
{
|
||||
//TODO: fix so that it finds view in right view.
|
||||
try
|
||||
{
|
||||
foreach (var region in _regionManager.Regions)
|
||||
{
|
||||
var existingView =
|
||||
_regionManager.GetView(region.Name, interfaceForView) as IBaseView;
|
||||
if (existingView == null) continue;
|
||||
var viewModel = existingView.DataContext as IBaseViewModel;
|
||||
if (viewModel == null) continue;
|
||||
await viewModel.CleanupAsync();
|
||||
|
||||
if (parameter == null)
|
||||
await viewModel.InitializeAsync();
|
||||
else
|
||||
await viewModel.InitializeAsync(parameter);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_eventAggregator.GetEvent<RaiseNotification>().Publish(new NotificationContentEventArgs(Utility.GetAllErrorMessages(ex)));
|
||||
}
|
||||
}
|
||||
|
||||
public IRegionCollection Regions { get; private set; }
|
||||
public IRegionManager CreateRegionManager()
|
||||
{
|
||||
return new RegionManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using DTS.Common.Enums.Communication;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.Interface.Communication;
|
||||
using DTS.Common.Interface.Connection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace DTS.Common.Interface.DASFactory
|
||||
{
|
||||
public interface ICommunication: IComparable<ICommunication>, IComparable<string>
|
||||
{
|
||||
IConnection Transport { get; set; }
|
||||
/// <summary>
|
||||
/// setups the receivebuffer and callback, this needs to be done whenever
|
||||
/// the sock is connected
|
||||
/// </summary>
|
||||
void SetupReader();
|
||||
int ReceiveBufferSize { get; set; }
|
||||
|
||||
string SerialNumber { get; set; }
|
||||
|
||||
string FirmwareVersion { get; set; }
|
||||
|
||||
byte ProtocolVersion { get; set; }
|
||||
|
||||
ICommunication_DASInfo DASInfo { get; set; }
|
||||
|
||||
Dictionary<DFConstantsAndEnums.ProtocolLimitedCommands, byte> MinimumProtocols { get; set; }
|
||||
|
||||
void InitMinProto();
|
||||
|
||||
bool IsCommandSupported(DFConstantsAndEnums.ProtocolLimitedCommands command);
|
||||
|
||||
byte GetMinProto(DFConstantsAndEnums.ProtocolLimitedCommands command);
|
||||
|
||||
event EventHandler OnDisconnected;
|
||||
|
||||
string ConnectString { get; }
|
||||
|
||||
bool Connected { get; }
|
||||
|
||||
void Connect(string ConnectString,
|
||||
CommunicationConstantsAndEnums.CommunicationCallback Callback,
|
||||
object CallbackObject,
|
||||
int CallbackTimeout, string ipAddress);
|
||||
|
||||
void Disconnect(bool reuseSocket,
|
||||
CommunicationConstantsAndEnums.CommunicationCallback Callback,
|
||||
object CallbackObject,
|
||||
int CallbackTimeout);
|
||||
|
||||
void Close(int Timeout);
|
||||
|
||||
void Flush(int Timeout);
|
||||
|
||||
bool ExecuteIsBusy { get; set; }
|
||||
|
||||
void Execute(byte[] byteData,
|
||||
CommunicationConstantsAndEnums.CommunicationCallback Callback,
|
||||
object CallbackObject,
|
||||
int CallbackTimeout);
|
||||
|
||||
void PseudoExecute(byte[] byteData,
|
||||
CommunicationConstantsAndEnums.CommunicationCallback Callback,
|
||||
object CallbackObject,
|
||||
int CallbackTimeout);
|
||||
|
||||
byte[] SyncExecute(byte[] byteData,
|
||||
int Timeout);
|
||||
|
||||
void Cancel();
|
||||
void ForceCancel();
|
||||
|
||||
bool IsCanceled();
|
||||
|
||||
void ClearCancel();
|
||||
/// <summary>
|
||||
/// event that will signal if cancel has happened
|
||||
/// prior to this IsCanceled would have to be checked
|
||||
/// or polled
|
||||
/// 17600 Communication class improvements from 3.2
|
||||
/// </summary>
|
||||
ManualResetEvent CancelEvent { get; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user