/// <summary> /// 获取指定管脚路径的外部管脚变量。 /// </summary> public IConnector GetExternalConnector(string connPath) { if (string.IsNullOrEmpty(connPath)) { return(null); } string cpuName = ViConnType.RetrieveCpuName(connPath); string planName = ViConnType.RetrievePlanName(connPath); string blockName = ViConnType.RetrieveBlockName(connPath); string connName = ViConnType.RetrieveConnectorName(connPath); if (string.IsNullOrEmpty(cpuName) || string.IsNullOrEmpty(planName)) { return(null); } if (!this.CPU.Key.Equals(cpuName, StringComparison.OrdinalIgnoreCase)) { return(null); } ICfcEditorInfo editor = this.GetCfcEditor(planName, true) as ICfcEditorInfo; if (editor == null) { return(null); } return(editor.GetConnector(connPath)); }
/// <summary> /// 注册 CFC 管脚。 /// </summary> /// <param name="connector">注册目标</param> /// <param name="doConnect">注册前是否需要进行跨CFC连线?</param> public void RegisterConnector(IConnector connector, bool doConnect = true) { if (doConnect && this.RegisteredConnector != null) { if (this.RegisteredConnector.CanConnectToExtConnector(connector)) { this.ConnectToExtConn(connector); } else if (connector != null && !ViConnType.RetrievePlanName(connector.Path).Equals(ViConnType.RetrievePlanName(this.RegisteredConnector.Path), StringComparison.OrdinalIgnoreCase)) { string file1 = ViConnType.RetrievePlanName(this.RegisteredConnector.Path); ICfcEditorInfo editor = this.GetCfcEditor(file1, false) as ICfcEditorInfo; editor.DisSelectConnector(this.RegisteredConnector); } } this.RegisteredConnector = connector; }
/// <summary> /// 取消另一个文件中的连接信息。 /// </summary> /// <param name="uuid">夸CFC连线变量ID</param> /// <param name="planName">发起请求的文件名称</param> public void DisConnectTo(string uuid, string requestFileName) { if (string.IsNullOrEmpty(requestFileName)) { return; } ExternalConnection extConn = this.ExtConnList.GetGlobalVariable(uuid) as ExternalConnection; if (extConn == null) { return; } string targetConnPath = string.Empty; string targetFile = string.Empty; if (string.Compare(requestFileName, extConn.GetSourceProgramName(), true) == 0) { targetConnPath = extConn.TargetPath; targetFile = extConn.GetTargetProgramName(); } else { targetConnPath = extConn.SourcePath; targetFile = extConn.GetSourceProgramName(); } ICfcEditorInfo targetEditor = this.GetCfcEditor(targetFile, true) as ICfcEditorInfo; if (targetEditor != null) { this.ExtConnList.RemoveGlobalVariable(uuid); IConnector targetConn = targetEditor.GetConnector(targetConnPath); if (targetConn != null) { targetConn.DisConnectToExtConnector(extConn); } } else { extConn.ValidState = false; } }