public Graph() { OsClock = new PerformanceCounter(); _proc = new GraphProcessor(this); _attrWorkingDirMask = new AttributeValueString(this, "WorkingDirMask"); _attrWorkingDirMask.Changed += (o, e) => _ctx.WorkingDirectoryMask = _attrWorkingDirMask.TypedGet(); _attrFileMask = new AttributeValueString(this, "FileMask"); _attrFileMask.Changed += (o, e) => _ctx.FileMask = _attrFileMask.TypedGet(); }
public override void EditStart() { _box.Text = _attr.TypedGet(); }
private void _attrFuncName_Changed(object sender, AttributeChangedEventArgs e) { for (int i = InputPorts.Count - 1; i >= 0; i--) { RemovePort(InputPorts[i]); } for (int i = OutputPorts.Count - 1; i >= 0; i--) { RemovePort(OutputPorts[i]); } if (string.IsNullOrEmpty(_attrFuncName.TypedGet())) { return; } if (_matlab == null) { if (!TryFindMatlab()) { Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, "No matlab instance found. Make sure to enable the automation server:\nenableservice('AutomationServer', true)")); return; } } var funcHeader = FindFunction(); if (funcHeader == null) { Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, $"Function {_attrFuncName.TypedGet()} not found or uses unsupported syntax in function header")); return; } foreach (var param in funcHeader.Parameters) { if (param.StartsWith("data")) { var port = new NodeSystemLib2.FormatData1D.InputPortData1D(this, param.Substring("data".Length)); port.SamplerateChanged += Port_SamplerateChanged; } else if (param.StartsWith("value")) { new NodeSystemLib2.FormatValue.InputPortValueDouble(this, param.Substring("value".Length)); } else { Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, $"Unknown type of port: {param}")); } } foreach (var param in funcHeader.ReturnValues) { if (param.StartsWith("data")) { new NodeSystemLib2.FormatData1D.OutputPortData1D(this, param.Substring("data".Length)); } else if (param.StartsWith("value")) { new NodeSystemLib2.FormatValue.OutputPortValueDouble(this, param.Substring("value".Length)); } else if (param.StartsWith("used_")) { // used count } else { Parent.Context.Notify(new GraphNotification(GraphNotification.NotificationType.Warning, $"Unknown type of return value: {param}")); } } }