本文整理汇总了C#中Commands.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# Commands.Flatten方法的具体用法?C# Commands.Flatten怎么用?C# Commands.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commands
的用法示例。
在下文中一共展示了Commands.Flatten方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Program
public Program(string name, RobotSystem robotSystem, IEnumerable<IEnumerable<Target>> targets, Commands.Group initCommands = null, IEnumerable<int> multiFileIndices = null, double stepSize = 1.0)
{
if (targets.SelectMany(x => x).Count() == 0)
throw new Exception(" The program has to contain at least 1 target");
int targetCount = targets.First().Count();
foreach (var subTargets in targets)
{
if (subTargets.Count() != targetCount) throw new Exception(" All sub programs have to contain the same number of targets");
}
this.Name = name;
this.RobotSystem = robotSystem;
this.InitCommands = new Commands.Group();
if (initCommands != null) this.InitCommands.AddRange(initCommands.Flatten());
if (multiFileIndices != null && multiFileIndices.Count() > 0)
{
multiFileIndices = multiFileIndices.Where(x => x < targetCount);
this.MultiFileIndices = multiFileIndices.ToList();
this.MultiFileIndices.Sort();
if (this.MultiFileIndices.Count == 0 || this.MultiFileIndices[0] != 0) this.MultiFileIndices.Insert(0, 0);
}
else
this.MultiFileIndices = new int[1].ToList();
var cellTargets = new List<CellTarget>(targetCount);
int targetIndex = 0;
foreach (var subTargets in targets.Transpose())
{
var programTargets = subTargets.Select((x, i) => new ProgramTarget(subTargets[i], i));
var cellTarget = new CellTarget(programTargets, targetIndex);
cellTargets.Add(cellTarget);
targetIndex++;
}
var checkProgram = new CheckProgram(this, cellTargets, stepSize);
int indexError = checkProgram.indexError;
if (indexError != -1) cellTargets = cellTargets.GetRange(0, indexError + 1).ToList();
this.Targets = cellTargets;
this.simulation = new Simulation(this, checkProgram.keyframes);
if (Errors.Count == 0)
Code = RobotSystem.Code(this);
}