private Style GetStyleForOutputType(IOutputItem OI) { if (OI is oi_MarlinResponse) { return(this.FindResource("MarlinResponseTextStyle") as Style); } else if (OI is oi_PrinterCommand) { return(this.FindResource("PrinterCommandTextStyle") as Style); } else if (OI is oi_ApplicationMessage) { return(this.FindResource("ApplicationMessageTextStyle") as Style); } else if (OI is pr_M503orM501_Config) { return(this.FindResource("ProcessedResponseTextStyle") as Style); } else if (OI is pr_G29T_MeshMap) { return(this.FindResource("ProcessedResponseTextStyle") as Style); } else if (OI is pr_M20_PrintableFile) { return(this.FindResource("PrintableFileTextStyle") as Style); } else { return(this.FindResource("FallthroughTextStyle") as Style); } }
public DecoratorLinear(IIdentifiable identifiable, IOutputItem decorated, IInputItem target) : base(identifiable, new Describable("Linear: Ax + B", "Linear transformation y = Ax + B"), decorated, target) { _arguments.Add(new Argument("A", "1.0", false, "A in y = Ax + B")); _arguments.Add(new Argument("B", "0.0", false, "B in y = Ax + B")); }
public DecoratorBase(IIdentifiable identifiable, IDescribable descibable, IOutputItem decorated, IInputItem target) { _identifiable = identifiable; _describable = descibable; _decorated = decorated; _target = target; }
public void UBL_G29_T1_Creates_Correct_G29T_MeshMap_OBject() { List <string> cl = new List <string>(@"Bed Topography Report for CSV: 0.185 0.175 0.170 0.000 -0.070 -0.140 -0.120 -0.195 -0.205 -0.255 0.080 0.110 0.065 -0.005 -0.115 -0.110 -0.115 -0.185 -0.180 -0.195 0.085 0.005 0.055 -0.010 -0.095 -0.060 -0.065 -0.085 -0.145 -0.165 0.295 0.110 0.080 0.150 0.005 -0.050 -0.030 -0.115 -0.130 -0.150 0.295 0.210 0.030 -0.030 0.100 -0.015 -0.020 -0.095 -0.150 -0.085 0.355 0.350 0.210 0.165 0.025 0.085 0.005 -0.005 -0.045 -0.165 0.305 0.335 0.240 0.160 0.125 0.025 0.075 0.030 0.020 0.010 0.250 0.260 0.225 0.145 0.115 0.020 -0.030 -0.095 0.015 0.005 0.230 0.210 0.150 0.005 -0.010 -0.005 -0.130 -0.050 -0.145 -0.115 0.290 0.230 0.165 0.090 0.025 0.000 0.005 0.000 0.040 0.030".Split("\r\n")); IOutputItem o = pr_G29T_MeshMap.BuildProcessedResponseG29T(cl)[0]; Assert.IsTrue(o is pr_G29T_MeshMap); pr_G29T_MeshMap mm = o as pr_G29T_MeshMap; Assert.IsTrue(mm.MeshValues[0, 0] == 0.290); Assert.IsTrue(mm.MeshValues[9, 9] == -0.255); Assert.IsTrue(mm.MeshValues[9, 0] == 0.030); Assert.IsTrue(mm.MeshValues[0, 9] == 0.185); Assert.IsTrue(mm.MeshValues[4, 2] == 0.115); Assert.IsTrue(mm.MeshValues[1, 2] == 0.260); }
public DecoratorWave(IIdentifiable identifiable, IOutputItem decorated, IInputItem target) : base(identifiable, new Describable("Wave: A*sin(F*t + P)", "Wave transformation y = Amplitude * sin(frequancy * time) + phase"), decorated, target) { _arguments.Add(new Argument("Amplitude", "0.0", false, "A in A*sin(F*t + P)")); _arguments.Add(new Argument("Phase", "0.0", false, "P in y = A*sin(F*t + P)")); _arguments.Add(new Argument("Frequency", "0.0", false, "F in y = A*sin(F*t + P)")); }
public List <IOutputItem> ProcessAndReturnOutputItems(IOutputItem outputItem) { if (!_isProcessing) { // Only look for Start Triggers since we're not already processing TriggerTestResult result = IsStartTrigger(outputItem); if (result == TriggerTestResult.TriggerAndInclude) { AddLineToFullResponse(outputItem.Value); } if (result != TriggerTestResult.NotTriggered) { _startId = outputItem.Id; _FullResponse.Clear(); _isProcessing = true; return(new List <IOutputItem>()); } // In all cases, we do not have a decoration return return(new List <IOutputItem>()); } else // _isProcessing == true { if (IsAbortTrigger(outputItem)) { // Not the response we were looking for. Cancel out. _startId = -1; _isProcessing = false; return(new List <IOutputItem>()); } TriggerTestResult result = IsEndTrigger(outputItem); if (result == TriggerTestResult.TriggerAndInclude) { _endId = outputItem.Id; _isProcessing = false; AddLineToFullResponse(outputItem.Value); return(_FunctionBuilder(_FullResponse)); } else if (result == TriggerTestResult.TriggerAndExclude) { // _endId = We leave this value as is. It'll have been set with the previous processed line. _isProcessing = false; return(_FunctionBuilder(_FullResponse)); } else // (result == TriggerTestResult.NotTriggered) { _endId = outputItem.Id; //Keep running count AddLineToFullResponse(outputItem.Value); return(new List <IOutputItem>()); } } }
private List <IOutputItem> GetProcessedResponses(IOutputItem outputItem) { List <IOutputItem> outputItems = new List <IOutputItem>(); foreach (IResponseProcessor i in _responseProcessors) { outputItems.AddRange(i.ProcessAndReturnOutputItems(outputItem)); } return(outputItems); }
public bool IsAbortTrigger(IOutputItem outputItem) { // If we come across a new command, then abort. We've clearly not processed an expected result. if (outputItem is oi_PrinterCommand) { return(true); } if (_AbortStrings.Contains(outputItem.Value)) { return(true); } return(false); }
/// <summary> /// Adds an item to the _OutputItems collection, which listOutput is bound to. /// Autoscrolls the list to the newly added item. /// </summary> /// <param name="item"></param> private void AddItemToOutputCollection(IOutputItem OI) { Dispatcher.Invoke(() => { Paragraph p = FlowDocumentFactory.GetFlowDocumentParagraphContent(OI); p.DataContext = OI; p.Style = GetStyleForOutputType(OI); AddEventHandlersForOutputType(p, OI); p.DataContext = OI; listOutput.Document.Blocks.Add(p); listOutput.ScrollToEnd(); listOutput.Document.Blocks.LastBlock.BringIntoView(); }); }
private void AddEventHandlersForOutputType(Paragraph p, IOutputItem OI) { if (OI is pr_M503orM501_Config) { p.MouseLeftButtonDown += P_MouseLeftButtonDownDrag; } else if (OI is pr_G29T_MeshMap) { p.MouseDown += P_MouseLeftButtonDownMeshDoubleClick; } else if (OI is pr_M20_PrintableFile) { p.MouseDown += P_MouseLeftButtonDownFileDoubleClick; } }
public TriggerTestResult IsStartTrigger(IOutputItem outputItem) { if (_StartAndIncludeStrings.Contains(outputItem.Value)) { Debug.WriteLine($"[{Name}] start trigger found on \"{outputItem.Value}\""); return(TriggerTestResult.TriggerAndInclude); } else if (_StartAndExcludeStrings.Contains(outputItem.Value)) { Debug.WriteLine($"[{Name}] start trigger found on \"{outputItem.Value}\""); return(TriggerTestResult.TriggerAndExclude); } else { return(TriggerTestResult.NotTriggered); } }
public TriggerTestResult IsEndTrigger(IOutputItem outputItem) { // We end on a Marlin Response that matches one of our end triggers. if (outputItem is oi_MarlinResponse && _EndAndIncludeStrings.Contains(outputItem.Value)) { Debug.WriteLine($"[{Name}] end trigger found on \"{outputItem.Value}\""); return(TriggerTestResult.TriggerAndInclude); } else if (outputItem is oi_MarlinResponse && _EndAndExcludeStrings.Contains(outputItem.Value)) { Debug.WriteLine($"[{Name}] end trigger found on \"{outputItem.Value}\""); return(TriggerTestResult.TriggerAndExclude); } else { return(TriggerTestResult.NotTriggered); } }
public IIdentifiable[] GetAvailableOutputDecorators(IOutputItem decoratedItem, IInputItem targetItem) { return(new List <IIdentifiable>(_ids.Keys).ToArray()); }
public void ProcessMarlinResult(IOutputItem OI) { AddItemToOutputCollection(OI); GetProcessedResponses(OI).ForEach(p => AddItemToOutputCollection(p)); }
public static Paragraph GetFlowDocumentParagraphContent(IOutputItem OI) { return(CreateParagraphFromString(OI.Value)); }
public IOutputItemDecorator CreateOutputItemDecorator(IIdentifiable decoratorIdentifier, IOutputItem decoratedItem, IInputItem targetItem) { throw new NotImplementedException(); }
public IIdentifiable[] GetAvailableOutputDecorators(IOutputItem decoratedItem, IInputItem targetItem) { throw new NotImplementedException(); }
public static ModelReference <T> ToModel <T>(this IOutputItem domainItem) where T : IOutputItem { return(new ModelReference <T>(domainItem.Id, domainItem.DisplayName)); }
public IOutputItemDecorator CreateOutputItemDecorator(IIdentifiable decoratorIdentifier, IOutputItem decoratedItem, IInputItem targetItem) { if (!_ids.ContainsKey(decoratorIdentifier)) { throw new NotImplementedException(); } switch (_ids[decoratorIdentifier].Caption) { case "Linear": return(new DecoratorLinear(decoratorIdentifier, decoratedItem, targetItem)); case "Wave": return(new DecoratorWave(decoratorIdentifier, decoratedItem, targetItem)); default: break; } throw new NotImplementedException(); }