using System;
namespace DTS.Common.Interface.DASFactory.Download
{
public interface IDownload
{
///
/// What do you want to download?
///
IDownloadRequest WhatToDownload { get; set; }
void SetWhatToDownload(IDownloadRequest request, bool bSetInDb = true);
///
/// The Retrieved information about stored events.
///
IDownloadReport EventInfo { get; set; }
void SetEventInfo(IDownloadReport eventInfo, bool bSetInDb = true);
///
/// QueryDownloadedStatus will fill this array (indexed by event number, true if
/// HasBeenDownloaded was set for this event, false otherwise)
///
bool[] EventDownloadedStatus { get; set; }
void SetEventDownloadStatus(bool[] status, bool storeInDb = true);
///
/// DASFactory will fill this array (indexed by event number).
///
Guid[] EventGuids { get; set; }
void SetEventGuids(Guid[] guids, bool storeInDb = true);
///
/// DASFactory will fill this array (indexed by event number).
///
ushort[] FaultFlags { get; set; }
void SetEventFaultFlags(ushort[] flags, bool storeInDb = true);
///
/// any extended fault flags1, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
///
uint[] ExtendedFaultFlags1 { get; set; }
///
/// any extended fault flags2, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
///
uint[] ExtendedFaultFlags2 { get; set; }
///
/// any extended fault flags3, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
///
uint[] ExtendedFaultFlags3 { get; set; }
///
/// any extended fault flags4, if there are multiple events then each event is an additional index
/// however downloads are always done one event at a time
///
uint[] ExtendedFaultFlags4 { get; set; }
///
/// sets the properties for extended fault flags, first array is always events, second array is extended fault flags
/// there are currently 4 extended fault flags in SLICE
/// http://manuscript.dts.local/f/cases/39223/
///
///
void SetExtendedFaultFlags(uint[][] flags);
///
/// DASFactory will fill this array (indexed by event number).
///
byte[] ArmAttempts { get; set; }
void SetEventArmAttemps(byte[] armAttempts, bool storeInDb = true);
}
public static class DownloadExtendedFaultFunctions
{
public static void SetExtendedFaultFlags(uint[][] flags, IDownload download)
{
if (null == flags || 0 == flags.Length)
{
ClearExtendedFaultFlags(download);
return;
}
download.ExtendedFaultFlags1 = new uint[flags.Length];
download.ExtendedFaultFlags2 = new uint[flags.Length];
download.ExtendedFaultFlags3 = new uint[flags.Length];
download.ExtendedFaultFlags4 = new uint[flags.Length];
for (var i = 0; i < flags.Length; i++)
{
download.ExtendedFaultFlags1[i] = flags[i].Length > 0 ? flags[i][0] : 0;
download.ExtendedFaultFlags2[i] = flags[i].Length > 1 ? flags[i][1] : 0;
download.ExtendedFaultFlags3[i] = flags[i].Length > 2 ? flags[i][2] : 0;
download.ExtendedFaultFlags4[i] = flags[i].Length > 3 ? flags[i][3] : 0;
}
}
public static void ClearExtendedFaultFlags(IDownload download)
{
download.ExtendedFaultFlags1 = null;
download.ExtendedFaultFlags2 = null;
download.ExtendedFaultFlags3 = null;
download.ExtendedFaultFlags4 = null;
}
}
}