209 lines
8.4 KiB
C#
209 lines
8.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
|
|
namespace DatabaseImport
|
|
{
|
|
/// <summary>
|
|
/// this is a test object that belongs to a test, it's different in that it can have test specific settings ...
|
|
/// </summary>
|
|
public class TestTestObject : TestObject
|
|
{
|
|
public TestTestObject(TestObject obj)
|
|
: base(obj)
|
|
{
|
|
}
|
|
private string _position = ChannelDefaultsKey;
|
|
public MMEPositions Position
|
|
{
|
|
get => GetGroupPosition(_position);
|
|
set
|
|
{
|
|
SetProperty(ref _position, value.Position, "Position");
|
|
if (_position == UserSetKey)
|
|
{
|
|
GroupPositionComboBoxVisible = Visibility.Hidden;
|
|
GroupPositionButtonVisible = Visibility.Visible;
|
|
}
|
|
else
|
|
{
|
|
GroupPositionComboBoxVisible = Visibility.Visible;
|
|
GroupPositionButtonVisible = Visibility.Hidden;
|
|
//set the position for every sensor in the test object using this position
|
|
var isoTestObject = GetISOTestObject();
|
|
foreach (var ch in isoTestObject.AllChannels)
|
|
{
|
|
if (!ch.Required) { continue; }
|
|
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
|
var sd = GetSensor(ch.Name, ch.SensorSerialNumber, ch.GetId()); // now using ch.Name instead of ch.GetID(); FB 7391 - Group sensor settings not in test when you set the test obj. and position.
|
|
if (null == sd) { continue; }
|
|
sd.Position = value.Position;
|
|
SetSensor(ch.GetId(), sd);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public const string ChannelDefaultsKey = "#";
|
|
public const string UserSetKey = "@";
|
|
|
|
private MMEPositions GetGroupPosition(string groupPositionKey)
|
|
{
|
|
foreach (var position in AvailableGroupPositions)
|
|
{
|
|
if (position.Position == groupPositionKey)
|
|
{
|
|
return position;
|
|
}
|
|
}
|
|
return _userSetGUID;
|
|
}
|
|
|
|
private Visibility _groupPositionComboBoxVisible = Visibility.Visible;
|
|
public Visibility GroupPositionComboBoxVisible
|
|
{
|
|
get
|
|
{
|
|
if (_groupPositionComboBoxVisible == Visibility.Visible)
|
|
{
|
|
return SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed : _groupPositionComboBoxVisible;
|
|
}
|
|
return _groupPositionComboBoxVisible;
|
|
}
|
|
set => SetProperty(ref _groupPositionComboBoxVisible, value, "GroupPositionComboBoxVisible");
|
|
}
|
|
|
|
private Visibility _groupPositionButtonVisible = Visibility.Hidden;
|
|
public Visibility GroupPositionButtonVisible
|
|
{
|
|
get
|
|
{
|
|
if (_groupPositionButtonVisible == Visibility.Visible)
|
|
{
|
|
return SerializedSettings.ISOSupportLevel == SerializedSettings.ISOSupportLevels.NO_ISO ? Visibility.Collapsed : _groupPositionButtonVisible;
|
|
}
|
|
return _groupPositionButtonVisible;
|
|
}
|
|
set => SetProperty(ref _groupPositionButtonVisible, value, "GroupPositionButtonVisible");
|
|
}
|
|
|
|
private string _testObject = "?";
|
|
public MMETestObjects TestObject
|
|
{
|
|
get => ((App)Application.Current).IsoDb.GetTestObjectByIso(_testObject);
|
|
set
|
|
{
|
|
if (value == null) return;
|
|
SetProperty(ref _testObject, value.Test_Object, "TestObject");
|
|
//also set the test object for all sensors!
|
|
|
|
var isoTestObject = GetISOTestObject();
|
|
foreach (var ch in isoTestObject.AllChannels)
|
|
{
|
|
if (!ch.Required) { continue; }
|
|
if (string.IsNullOrWhiteSpace(ch.SensorSerialNumber)) { continue; }
|
|
var sd = GetSensor(ch.GetId(), ch.SensorSerialNumber, ch.GetId());
|
|
if (null == sd) { continue; }
|
|
sd.TestObject = value.Test_Object;
|
|
SetSensor(ch.GetId(), sd);
|
|
}
|
|
}
|
|
}
|
|
|
|
private int _channelTypesIndex = -1;
|
|
public int ChannelTypesIndex
|
|
{
|
|
get => _channelTypesIndex;
|
|
set => SetProperty(ref _channelTypesIndex, value, Tags.ChannelTypesIndex.ToString());
|
|
}
|
|
|
|
public void SetTestObject(string s)
|
|
{
|
|
_testObject = s;
|
|
OnPropertyChanged("TestObject");
|
|
}
|
|
|
|
public void SetPosition(string s)
|
|
{
|
|
_position = s;
|
|
OnPropertyChanged("Position");
|
|
if (s == UserSetKey)
|
|
{
|
|
GroupPositionComboBoxVisible = Visibility.Hidden;
|
|
GroupPositionButtonVisible = Visibility.Visible;
|
|
}
|
|
else
|
|
{
|
|
GroupPositionComboBoxVisible = Visibility.Visible;
|
|
GroupPositionButtonVisible = Visibility.Hidden;
|
|
}
|
|
}
|
|
public MMEPositions[] AvailablePositions => ((App)Application.Current).IsoDb.GetPositions();
|
|
|
|
private const string DATAPRO_DEFINED = "DataPRO-defined";
|
|
public static MMEPositions _channelDefaultsGUID = new MMEPositions(Guid.NewGuid().ToString(), ChannelDefaultsKey, "(channel defaults)", "(channel defaults)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
|
DATAPRO_DEFINED, "", MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
|
private MMEPositions _userSetGUID = new MMEPositions(Guid.NewGuid().ToString(), UserSetKey, "(multiple)", "(multiple)", 1, DateTime.Now, DATAPRO_DEFINED, false, "", DateTime.Now,
|
|
DATAPRO_DEFINED, "", MMEPossibleChannels.MMEChannelTypes.ISO13499_106);
|
|
public MMEPositions[] AvailableGroupPositions
|
|
{
|
|
get
|
|
{
|
|
var availableGroupPositions = new List<MMEPositions>();
|
|
availableGroupPositions.Add(_channelDefaultsGUID);
|
|
availableGroupPositions.AddRange(AvailablePositions);
|
|
|
|
return availableGroupPositions.ToArray();
|
|
}
|
|
}
|
|
public TestTestObject(TestTestObject to)
|
|
: base(to)
|
|
{
|
|
MetaCommonConstructor(to);
|
|
}
|
|
/// <summary>
|
|
/// takes care of the meta data copy constructor items
|
|
/// </summary>
|
|
/// <param name="to"></param>
|
|
private void MetaCommonConstructor(TestTestObject to)
|
|
{
|
|
ExcitationWarmupTimeMS = to.ExcitationWarmupTimeMS;
|
|
TargetSampleRate = to.TargetSampleRate;
|
|
PreTriggerSeconds = to.PreTriggerSeconds;
|
|
PostTriggerSeconds = to.PostTriggerSeconds;
|
|
_position = to._position;
|
|
Position = to.Position;
|
|
_testObject = to._testObject;
|
|
SerialNumberConverted = to.SerialNumberConverted;
|
|
SysBuilt = to.SysBuilt; //executed?
|
|
ChannelTypesIndex = to.ChannelTypesIndex;
|
|
}
|
|
private int _excitationWarmupTime;
|
|
public int ExcitationWarmupTimeMS
|
|
{
|
|
get => _excitationWarmupTime;
|
|
set => SetProperty(ref _excitationWarmupTime, value, "ExcitationWarmupTimeMS");
|
|
}
|
|
private double _targetSampleRate;
|
|
public double TargetSampleRate
|
|
{
|
|
get => _targetSampleRate;
|
|
set => SetProperty(ref _targetSampleRate, value, "TargetSampleRate");
|
|
}
|
|
|
|
private double _preTriggerSeconds;
|
|
public double PreTriggerSeconds
|
|
{
|
|
get => _preTriggerSeconds;
|
|
set => SetProperty(ref _preTriggerSeconds, value, "PreTriggerSeconds");
|
|
}
|
|
|
|
private double _postTriggerSeconds;
|
|
public double PostTriggerSeconds
|
|
{
|
|
get => _postTriggerSeconds;
|
|
set => SetProperty(ref _postTriggerSeconds, value, "PostTriggerSeconds");
|
|
}
|
|
}
|
|
}
|