本文整理汇总了C#中HFM.Core.DataTypes.UnitInfo类的典型用法代码示例。如果您正苦于以下问题:C# UnitInfo类的具体用法?C# UnitInfo怎么用?C# UnitInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnitInfo类属于HFM.Core.DataTypes命名空间,在下文中一共展示了UnitInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DuplicateTestMixed
public void DuplicateTestMixed()
{
var instance1 = new SlotModel { UserId = "1" };
var unitInfo1 = new UnitInfo { ProjectID = 1 };
var logic1 = CreateUnitInfoLogic(unitInfo1);
instance1.UnitInfoLogic = logic1;
var instance2 = new SlotModel { UserId = "1" };
var unitInfo2 = new UnitInfo { ProjectID = 2 };
var logic2 = CreateUnitInfoLogic(unitInfo2);
instance2.UnitInfoLogic = logic2;
var instance3 = new SlotModel { UserId = "2" };
var unitInfo3 = new UnitInfo { ProjectID = 1 };
var logic3 = CreateUnitInfoLogic(unitInfo3);
instance3.UnitInfoLogic = logic3;
(new[] { instance1, instance2, instance3 }).FindDuplicates();
Assert.IsTrue(instance1.UserIdIsDuplicate);
Assert.IsTrue(instance1.ProjectIsDuplicate);
Assert.IsTrue(instance2.UserIdIsDuplicate);
Assert.IsFalse(instance2.ProjectIsDuplicate);
Assert.IsFalse(instance3.UserIdIsDuplicate);
Assert.IsTrue(instance3.ProjectIsDuplicate);
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:26,代码来源:ExtensionsTests.cs
示例2: CurrentFrameTest4
public void CurrentFrameTest4()
{
var unitInfo = new UnitInfo();
var unitFrame = new UnitFrame { FrameID = -1 };
unitInfo.SetUnitFrame(unitFrame);
Assert.IsNull(unitInfo.CurrentFrame);
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:7,代码来源:UnitInfoTests.cs
示例3: GetUnitFrameTest2
public void GetUnitFrameTest2()
{
var unitInfo = new UnitInfo();
unitInfo.SetUnitFrame(new UnitFrame { FrameID = 0 });
Assert.IsNotNull(unitInfo.GetUnitFrame(0));
Assert.IsNull(unitInfo.GetUnitFrame(1));
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:7,代码来源:UnitInfoTests.cs
示例4: UnitInfo_CurrentFrame_Test1
public void UnitInfo_CurrentFrame_Test1()
{
// Arrange
var unitInfo = new UnitInfo();
// Act & Assert
Assert.IsNull(unitInfo.CurrentFrame);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:7,代码来源:UnitInfoTests.cs
示例5: CurrentFrameTest2
public void CurrentFrameTest2()
{
var unitInfo = new UnitInfo();
var unitFrame = new UnitFrame { FrameID = 0 };
unitInfo.SetUnitFrame(unitFrame);
Assert.AreSame(unitFrame, unitInfo.CurrentFrame);
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:7,代码来源:UnitInfoTests.cs
示例6: UnitInfo_CurrentFrame_Test2
public void UnitInfo_CurrentFrame_Test2()
{
// Arrange
var unitInfo = new UnitInfo();
var unitFrame = new UnitFrame { FrameID = 0 };
var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame };
unitInfo.LogLines = new List<LogLine>(new[] { logLine });
// Act & Assert
Assert.AreSame(unitFrame, unitInfo.CurrentFrame);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:10,代码来源:UnitInfoTests.cs
示例7: AllFramesCompleted1
public void AllFramesCompleted1()
{
var unitInfo = new UnitInfo();
unitInfo.SetUnitFrame(MakeUnitFrame("00:00:00", 100));
var unitInfoLogic = CreateUnitInfoLogic(null, unitInfo);
unitInfoLogic.UtcOffsetIsZero = false;
unitInfoLogic.ClientTimeOffset = 0;
Assert.IsTrue(unitInfoLogic.AllFramesCompleted);
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:10,代码来源:UnitInfoLogicTests.cs
示例8: DownloadTimeTest3
public void DownloadTimeTest3()
{
var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow };
var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo);
unitInfoLogic.UtcOffsetIsZero = true;
unitInfoLogic.ClientTimeOffset = 0;
Assert.AreEqual(unitInfo.DownloadTime,
unitInfoLogic.DownloadTime);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:10,代码来源:UnitInfoLogicTests.cs
示例9: DownloadTimeTest4
public void DownloadTimeTest4()
{
var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow };
var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo);
unitInfoLogic.UtcOffsetIsZero = true;
unitInfoLogic.ClientTimeOffset = -60;
Assert.AreEqual(unitInfo.DownloadTime
.Add(TimeSpan.FromMinutes(60)),
unitInfoLogic.DownloadTime);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:11,代码来源:UnitInfoLogicTests.cs
示例10: DownloadTimeTest2
public void DownloadTimeTest2()
{
var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow };
var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo);
unitInfoLogic.UtcOffsetIsZero = false;
unitInfoLogic.ClientTimeOffset = 60;
Assert.AreEqual(unitInfo.DownloadTime.ToLocalTime()
.Subtract(TimeSpan.FromMinutes(60)),
unitInfoLogic.DownloadTime);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:11,代码来源:UnitInfoLogicTests.cs
示例11: UnitInfo_CurrentFrame_Test3
public void UnitInfo_CurrentFrame_Test3()
{
// Arrange
var unitInfo = new UnitInfo();
var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 0 } };
var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 1 } };
var unitFrame5 = new UnitFrame { FrameID = 5 };
var logLine5 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame5 };
unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1, logLine5 });
// Act & Assert
Assert.AreSame(unitFrame5, unitInfo.CurrentFrame);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:12,代码来源:UnitInfoTests.cs
示例12: UpdateBenchmarkDataTest
public void UpdateBenchmarkDataTest()
{
// setup
var benchmarkCollection = new ProteinBenchmarkCollection();
var database = MockRepository.GenerateMock<IUnitInfoDatabase>();
var fahClient = new FahClient(MockRepository.GenerateStub<IMessageConnection>()) { BenchmarkCollection = benchmarkCollection, UnitInfoDatabase = database };
var unitInfo1 = new UnitInfo();
unitInfo1.OwningClientName = "Owner";
unitInfo1.OwningClientPath = "Path";
unitInfo1.OwningSlotId = 0;
unitInfo1.ProjectID = 2669;
unitInfo1.ProjectRun = 1;
unitInfo1.ProjectClone = 2;
unitInfo1.ProjectGen = 3;
unitInfo1.FinishedTime = new DateTime(2010, 1, 1);
unitInfo1.QueueIndex = 0;
var currentUnitInfo = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1 };
var unitInfo1Clone = unitInfo1.DeepClone();
unitInfo1Clone.FramesObserved = 4;
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(0), FrameID = 0 });
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(5), FrameID = 1 });
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(10), FrameID = 2 });
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(15), FrameID = 3 });
unitInfo1Clone.UnitResult = WorkUnitResult.FinishedUnit;
var unitInfoLogic1 = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1Clone };
var parsedUnits = new[] { unitInfoLogic1 };
// arrange
database.Stub(x => x.Connected).Return(true);
database.Expect(x => x.Insert(null)).IgnoreArguments().Repeat.Times(1);
var benchmarkClient = new BenchmarkClient("Owner Slot 00", "Path");
// assert before act
Assert.AreEqual(false, benchmarkCollection.Contains(benchmarkClient));
Assert.AreEqual(false, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
Assert.IsNull(benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData));
// act
fahClient.UpdateBenchmarkData(currentUnitInfo, parsedUnits, 0);
// assert after act
Assert.AreEqual(true, benchmarkCollection.Contains(benchmarkClient));
Assert.AreEqual(true, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData).AverageFrameTime);
database.VerifyAllExpectations();
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:51,代码来源:FahClientTests.cs
示例13: AggregateData
/// <summary>
/// Aggregate Data and return UnitInfo Dictionary.
/// </summary>
public DataAggregatorResult AggregateData(ClientRun clientRun, UnitCollection unitCollection, Info info, Options options,
SlotOptions slotOptions, UnitInfo currentUnitInfo, int slotId)
{
if (clientRun == null) throw new ArgumentNullException("clientRun");
if (unitCollection == null) throw new ArgumentNullException("unitCollection");
if (options == null) throw new ArgumentNullException("options");
if (slotOptions == null) throw new ArgumentNullException("slotOptions");
if (currentUnitInfo == null) throw new ArgumentNullException("currentUnitInfo");
var result = new DataAggregatorResult();
result.CurrentUnitIndex = -1;
SlotRun slotRun = null;
if (clientRun.SlotRuns.ContainsKey(slotId))
{
slotRun = clientRun.SlotRuns[slotId];
}
result.StartTime = clientRun.Data.StartTime;
result.Arguments = clientRun.Data.Arguments;
result.ClientVersion = clientRun.Data.ClientVersion;
result.UserID = clientRun.Data.UserID;
result.MachineID = clientRun.Data.MachineID;
result.Status = slotRun != null ? slotRun.Data.Status : SlotStatus.Unknown;
if (Logger.IsDebugEnabled)
{
foreach (var s in clientRun.Where(x => x.LineType == LogLineType.Error))
{
Logger.DebugFormat(Constants.ClientNameFormat, ClientName, String.Format("Failed to parse log line: {0}", s));
}
}
GenerateUnitInfoDataFromQueue(result, slotRun, unitCollection, options, slotOptions, currentUnitInfo, slotId);
result.Queue = BuildClientQueue(unitCollection, info, slotOptions, slotId);
if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex) && result.UnitInfos[result.CurrentUnitIndex].LogLines != null)
{
result.CurrentLogLines = result.UnitInfos[result.CurrentUnitIndex].LogLines;
}
else if (slotRun != null)
{
result.CurrentLogLines = slotRun.ToList();
}
else
{
result.CurrentLogLines = clientRun.ToList();
}
return result;
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:53,代码来源:FahClientDataAggregator.cs
示例14: UnitInfo_DefaultPropertyValues_Test
public void UnitInfo_DefaultPropertyValues_Test()
{
var unitInfo = new UnitInfo();
Assert.AreEqual(SlotType.Unknown, unitInfo.SlotType);
Assert.IsTrue(unitInfo.DownloadTime.IsUnknown());
Assert.IsTrue(unitInfo.DueTime.IsUnknown());
Assert.IsTrue(unitInfo.UnitStartTimeStamp.IsZero());
Assert.IsTrue(unitInfo.FinishedTime.IsUnknown());
Assert.IsTrue(unitInfo.CoreVersion == 0);
Assert.IsTrue(unitInfo.ProteinName.Length == 0);
Assert.IsTrue(unitInfo.ProteinTag.Length == 0);
Assert.AreEqual(WorkUnitResult.Unknown, unitInfo.UnitResult);
Assert.IsNull(unitInfo.LogLines);
Assert.IsNull(unitInfo.UnitFrames);
Assert.AreEqual(Constants.DefaultCoreID, unitInfo.CoreID);
}
开发者ID:harlam357,项目名称:hfm-net,代码行数:16,代码来源:UnitInfoTests.cs
示例15: GenerateUnitInfoDataFromLogs
private UnitInfo[] GenerateUnitInfoDataFromLogs()
{
var parsedUnits = new UnitInfo[2];
_unitLogLines = new IList<LogLine>[2];
if (_logInterpreterLegacy.PreviousWorkUnitLogLines != null)
{
_unitLogLines[0] = _logInterpreterLegacy.PreviousWorkUnitLogLines;
parsedUnits[0] = BuildUnitInfo(null, LogReader.GetFahLogDataFromLogLines(_logInterpreterLegacy.PreviousWorkUnitLogLines), null);
}
bool matchOverride = false;
_unitLogLines[1] = _logInterpreterLegacy.CurrentWorkUnitLogLines;
if (_unitLogLines[1] == null)
{
matchOverride = true;
_unitLogLines[1] = _logInterpreterLegacy.CurrentClientRunLogLines;
}
parsedUnits[1] = BuildUnitInfo(null, LogReader.GetFahLogDataFromLogLines(_unitLogLines[1]), GetUnitInfoLogData(), matchOverride);
return parsedUnits;
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:23,代码来源:LegacyDataAggregator.cs
示例16: BuildUnitInfo
private UnitInfo BuildUnitInfo(QueueEntry queueEntry, FahLogUnitData fahLogUnitData, UnitInfoLogData unitInfoLogData, bool matchOverride)
{
// queueEntry can be null
Debug.Assert(fahLogUnitData != null);
// unitInfoLogData can be null
var unit = new UnitInfo();
unit.UnitStartTimeStamp = fahLogUnitData.UnitStartTimeStamp;
unit.FramesObserved = fahLogUnitData.FramesObserved;
unit.CoreVersion = fahLogUnitData.CoreVersion;
unit.UnitResult = fahLogUnitData.UnitResult;
if (queueEntry != null)
{
PopulateUnitInfoFromQueueEntry(queueEntry, unit);
SearchFahLogUnitDataProjects(unit, fahLogUnitData);
PopulateUnitInfoFromLogs(CurrentClientRun, fahLogUnitData, unitInfoLogData, unit);
if (ProjectsMatch(unit, fahLogUnitData) ||
ProjectsMatch(unit, unitInfoLogData) ||
matchOverride)
{
// continue parsing the frame data
ParseFrameData(fahLogUnitData.FrameDataList, unit);
}
else
{
return null;
}
}
else
{
PopulateUnitInfoFromLogs(CurrentClientRun, fahLogUnitData, unitInfoLogData, unit);
ParseFrameData(fahLogUnitData.FrameDataList, unit);
}
return unit;
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:38,代码来源:LegacyDataAggregator.cs
示例17: SearchFahLogUnitDataProjects
private static void SearchFahLogUnitDataProjects(UnitInfo unit, FahLogUnitData fahLogUnitData)
{
Debug.Assert(unit != null);
Debug.Assert(fahLogUnitData != null);
for (int i = 0; i < fahLogUnitData.ProjectInfoList.Count; i++)
{
if (ProjectsMatch(unit, fahLogUnitData.ProjectInfoList[i]))
{
fahLogUnitData.ProjectInfoIndex = i;
}
}
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:13,代码来源:LegacyDataAggregator.cs
示例18: ProjectsMatch
private static bool ProjectsMatch(UnitInfo unit, IProjectInfo projectInfo)
{
Debug.Assert(unit != null);
if (unit.ProjectIsUnknown() || projectInfo == null) return false;
return (unit.ProjectID == projectInfo.ProjectID &&
unit.ProjectRun == projectInfo.ProjectRun &&
unit.ProjectClone == projectInfo.ProjectClone &&
unit.ProjectGen == projectInfo.ProjectGen);
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:11,代码来源:LegacyDataAggregator.cs
示例19: PopulateUnitInfoFromQueueEntry
private static void PopulateUnitInfoFromQueueEntry(QueueEntry entry, UnitInfo unit)
{
Debug.Assert(entry != null);
Debug.Assert(unit != null);
// convert to enum
var queueEntryStatus = (QueueEntryStatus)entry.EntryStatus;
if ((queueEntryStatus.Equals(QueueEntryStatus.Unknown) ||
queueEntryStatus.Equals(QueueEntryStatus.Empty) ||
queueEntryStatus.Equals(QueueEntryStatus.Garbage) ||
queueEntryStatus.Equals(QueueEntryStatus.Abandonded)) == false)
{
/* Tag (Could be read here or through the unitinfo.txt file) */
unit.ProteinTag = entry.WorkUnitTag;
/* DownloadTime (Could be read here or through the unitinfo.txt file) */
unit.DownloadTime = entry.BeginTimeUtc;
/* DueTime (Could be read here or through the unitinfo.txt file) */
unit.DueTime = entry.DueTimeUtc;
/* FinishedTime */
if (queueEntryStatus.Equals(QueueEntryStatus.Finished) ||
queueEntryStatus.Equals(QueueEntryStatus.ReadyForUpload))
{
unit.FinishedTime = entry.EndTimeUtc;
}
/* Project (R/C/G) */
unit.ProjectID = entry.ProjectID;
unit.ProjectRun = entry.ProjectRun;
unit.ProjectClone = entry.ProjectClone;
unit.ProjectGen = entry.ProjectGen;
/* FoldingID and Team from Queue Entry */
unit.FoldingID = entry.FoldingID;
unit.Team = (int) entry.TeamNumber;
/* Core ID */
unit.CoreID = entry.CoreNumberHex.ToUpperInvariant();
}
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:43,代码来源:LegacyDataAggregator.cs
示例20: PopulateUnitInfoFromLogs
private static void PopulateUnitInfoFromLogs(ClientRun currentClientRun, FahLogUnitData fahLogUnitData,
UnitInfoLogData unitInfoLogData, UnitInfo unit)
{
Debug.Assert(currentClientRun != null);
Debug.Assert(fahLogUnitData != null);
// unitInfoLogData can be null
Debug.Assert(unit != null);
/* Project (R/C/G) (Could have already been read through Queue) */
if (unit.ProjectIsUnknown())
{
unit.ProjectID = fahLogUnitData.ProjectID;
unit.ProjectRun = fahLogUnitData.ProjectRun;
unit.ProjectClone = fahLogUnitData.ProjectClone;
unit.ProjectGen = fahLogUnitData.ProjectGen;
}
if (fahLogUnitData.Threads > 1)
{
unit.SlotType = SlotType.CPU;
}
if (unitInfoLogData != null)
{
unit.ProteinName = unitInfoLogData.ProteinName;
/* Tag (Could have already been read through Queue) */
if (unit.ProteinTag.Length == 0)
{
unit.ProteinTag = unitInfoLogData.ProteinTag;
}
/* DownloadTime (Could have already been read through Queue) */
if (unit.DownloadTime.IsUnknown())
{
unit.DownloadTime = unitInfoLogData.DownloadTime;
}
/* DueTime (Could have already been read through Queue) */
if (unit.DueTime.IsUnknown())
{
unit.DueTime = unitInfoLogData.DueTime;
}
/* FinishedTime (Not available in unitinfo log) */
/* Project (R/C/G) (Could have already been read through Queue) */
if (unit.ProjectIsUnknown())
{
unit.ProjectID = unitInfoLogData.ProjectID;
unit.ProjectRun = unitInfoLogData.ProjectRun;
unit.ProjectClone = unitInfoLogData.ProjectClone;
unit.ProjectGen = unitInfoLogData.ProjectGen;
}
}
/* FoldingID and Team from Last Client Run (Could have already been read through Queue) */
if (unit.FoldingID.Equals(Constants.DefaultFoldingID) &&
!String.IsNullOrEmpty(currentClientRun.FoldingID))
{
unit.FoldingID = currentClientRun.FoldingID;
}
if (unit.Team == Constants.DefaultTeam)
{
unit.Team = currentClientRun.Team;
}
// Possibly check the currentClientRun from the log file.
// The queue will have the ID and Team that was set when the work unit was received.
//if (unit.FoldingID.Equals(Default.FoldingID) ||
// !unit.FoldingID.Equals(currentClientRun.FoldingID))
//{
// unit.FoldingID = currentClientRun.FoldingID;
//}
//if (unit.Team == Default.Team ||
// unit.Team != currentClientRun.Team)
//{
// unit.Team = currentClientRun.Team;
//}
}
开发者ID:kszysiu,项目名称:hfm-net,代码行数:80,代码来源:LegacyDataAggregator.cs
注:本文中的HFM.Core.DataTypes.UnitInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论