init
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Utilities;
|
||||
using DTS.Utilities.DotNetProgrammingConstructs;
|
||||
|
||||
namespace DTS.Serialization
|
||||
{
|
||||
//[Serializable]
|
||||
public partial class TestSetup : Exceptional
|
||||
{
|
||||
public partial class Sensor : Exceptional
|
||||
{
|
||||
public Sensor()
|
||||
{
|
||||
_FilterClass.Value = null;
|
||||
_Name.Value = null;
|
||||
_Polarity.Value = null;
|
||||
_Position.Value = null;
|
||||
_Range.Value = null;
|
||||
_Version.Value = "1.0.0.0";
|
||||
}
|
||||
|
||||
public string FilterClass
|
||||
{
|
||||
get { return _FilterClass.Value; }
|
||||
set { _FilterClass.Value = value; }
|
||||
}
|
||||
private Property<string> _FilterClass
|
||||
= new Property<string>(typeof(Graph).Namespace + ".Sensor.FilterClass", "", false);
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _Name.Value; }
|
||||
set { _Name.Value = value; }
|
||||
}
|
||||
private Property<string> _Name
|
||||
= new Property<string>(typeof(Graph).Namespace + ".Sensor.Name", "", false);
|
||||
|
||||
public string Polarity
|
||||
{
|
||||
get { return _Polarity.Value; }
|
||||
set { _Polarity.Value = value; }
|
||||
}
|
||||
private Property<string> _Polarity
|
||||
= new Property<string>(typeof(Graph).Namespace + ".Sensor.Polarity", "", false);
|
||||
|
||||
public string Position
|
||||
{
|
||||
get { return _Position.Value; }
|
||||
set { _Position.Value = value; }
|
||||
}
|
||||
private Property<string> _Position
|
||||
= new Property<string>(typeof(Graph).Namespace + ".Sensor.Position", "", false);
|
||||
|
||||
public string Range
|
||||
{
|
||||
get { return _Range.Value; }
|
||||
set { _Range.Value = value; }
|
||||
}
|
||||
private Property<string> _Range
|
||||
= new Property<string>(typeof(Graph).Namespace + ".Sensor.Range", "", false);
|
||||
|
||||
public string Version
|
||||
{
|
||||
get { return _Version.Value; }
|
||||
set { _Version.Value = value; }
|
||||
}
|
||||
private Property<string> _Version
|
||||
= new Property<string>(typeof(Graph).Namespace + ".Sensor.Version", "", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* SoMat.File.Writer.cs
|
||||
*
|
||||
* Copyright © 2009
|
||||
* Diversified Technical Systems, Inc.
|
||||
* All Rights Reserved
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Serialization.SoMat
|
||||
{
|
||||
// *** see SoMat.File.Writer.cs ***
|
||||
public partial class File
|
||||
{ ///
|
||||
/// <summary>
|
||||
/// Utility object for serializing <see cref="DTS.Serialization.Test"/>s to disk
|
||||
/// in the Diadem
|
||||
/// </summary>
|
||||
///
|
||||
public class Writer : Writer<File>, IWriter<Test>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialize an instance of the SoMat.File.Writer class.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="fileType">
|
||||
/// The associated <see cref="DTS.SErialization.Diadem.File"/> object.
|
||||
/// </param>
|
||||
///
|
||||
internal Writer(File fileType, int encoding)
|
||||
: base(fileType, encoding)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Write the specified test to the specified pathname.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="pathname">
|
||||
/// The <see cref="string"/> pathname to which the specified test should be serialized.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="test">
|
||||
/// The <see cref="DTS.Serialization.Test"/> to be written out.
|
||||
/// </param>
|
||||
///
|
||||
public void Write(string pathname, string id, Test test, bool bFiltering, bool includeGroupNameInISOExport, double minStartTime, int dataCollectionLength)
|
||||
{
|
||||
throw new NotSupportedException("SoMat::File::Writer Write(pathname, id, test, bFiltering) not supported");
|
||||
}
|
||||
private FilteredData[] _filterdData = null;
|
||||
public FilteredData[] FilteredData
|
||||
{
|
||||
get => _filterdData;
|
||||
set => _filterdData = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write the representation file/files of the specified DTS.Serialization.Test
|
||||
/// at the given pathname.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="targetPathname">
|
||||
/// The <see cref="string"/> pathname of the specified object's resulting file
|
||||
/// representation.
|
||||
/// </param>
|
||||
///
|
||||
public void Write(string pathname,
|
||||
string id,
|
||||
string dataFolder,
|
||||
Test test,
|
||||
bool bFiltering,
|
||||
bool includeGroupNameInISOExport,
|
||||
FilteredData fd,
|
||||
Test.Module.Channel tmChannel,
|
||||
int channelNumber,
|
||||
BeginEventHandler beginEventHandler,
|
||||
CancelEventHandler cancelEventHandler,
|
||||
EndEventHandler endEventHandler,
|
||||
TickEventHandler tickEventHandler,
|
||||
ErrorEventHandler errorEventHandler,
|
||||
CancelRequested cancelRequested,
|
||||
double minStartTime,
|
||||
int dataCollectionLength)
|
||||
{
|
||||
System.Exception exception = null;
|
||||
try
|
||||
{
|
||||
beginEventHandler?.Invoke(this, Convert.ToUInt32(test.Channels.Count)); var header = new SoMatTestHeader(test, FilteredData);
|
||||
using (var sw = new StreamWriter(pathname, false, Encoding.Default))
|
||||
{
|
||||
header.Serialize(sw);
|
||||
foreach (var channel in header.Channels)
|
||||
{
|
||||
channel.Serialize(sw);
|
||||
}
|
||||
|
||||
sw.Write("DM_Start=\r\n");
|
||||
|
||||
ulong maxSamples = 0;
|
||||
foreach (var module in test.Modules)
|
||||
{
|
||||
maxSamples = Math.Max(maxSamples, module.NumberOfSamples);
|
||||
}
|
||||
|
||||
double totalWriteTicksDispatched = 0;
|
||||
double totalWriteTicksNeeded = 100;
|
||||
|
||||
var DataSamplesPerTick = Convert.ToUInt64(maxSamples / (double)totalWriteTicksNeeded);
|
||||
|
||||
for (uint i = 0; i < maxSamples; i++)
|
||||
{
|
||||
sw.WriteLine();
|
||||
var bNeedTab = false;
|
||||
foreach (var fdvar in _filterdData)
|
||||
{
|
||||
if (bNeedTab) { sw.Write("\t"); }
|
||||
if (i < fdvar.Data.Length)
|
||||
{
|
||||
sw.Write(fdvar.Data[i].ToString("0.00000E+00"));
|
||||
}
|
||||
bNeedTab = true;
|
||||
}
|
||||
if (0 == i % DataSamplesPerTick)
|
||||
{
|
||||
if (null != tickEventHandler)
|
||||
{
|
||||
tickEventHandler(this, ((double)totalWriteTicksDispatched++) / totalWriteTicksNeeded * 100);
|
||||
System.Windows.Forms.Application.DoEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
exception = ex;
|
||||
APILogger.Log("encountered problem writing SoMat test files", ex);
|
||||
}
|
||||
tickEventHandler?.Invoke(this, 100D);
|
||||
if (null != errorEventHandler && null != exception)
|
||||
{
|
||||
endEventHandler(this);
|
||||
errorEventHandler(this, exception);
|
||||
}
|
||||
else if (null != exception) { throw exception; }
|
||||
else
|
||||
{
|
||||
tickEventHandler?.Invoke(this, 100.0);
|
||||
endEventHandler?.Invoke(this);
|
||||
}
|
||||
}
|
||||
public void Initialize(string pathname,
|
||||
string id,
|
||||
string dataFolder,
|
||||
Test test,
|
||||
bool bFiltering,
|
||||
bool includeGroupNameInISOExport,
|
||||
FilteredData fd,
|
||||
Test.Module.Channel tmChannel,
|
||||
int channelNumber,
|
||||
BeginEventHandler beginEventHandler,
|
||||
CancelEventHandler cancelEventHandler,
|
||||
EndEventHandler endEventHandler,
|
||||
TickEventHandler tickEventHandler,
|
||||
ErrorEventHandler errorEventHandler,
|
||||
CancelRequested cancelRequested)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user