Samples | Measurement Creating, accessing and handling diagrams Several diagrams can exist in parallel in a scope configuration. To add diagrams to an existing scope project, simply use the CreateChild() method from the IMeasurementScope interface. The following code snippet assumes that a TwinCAT Measurement project has already been created and that a reference to this project has been saved in the "scopeProject" object. Code snippet (C#):
Project MeasurementProject = dte.Solution.Projects.Item(1); ProjectItem ScopeProjectItem = MeasurementProject.ProjectItems.Item(1); IMeasurementScope ScopeObj = (IMeasurementScope)ScopeProjectItem.Object; ScopeObj.CreateChild(out object chartObj); // Erzeugen eines neuen YT-Charts im Scope ProjectItem piChart = chartObj as ProjectItem; IMeasurementScope imsChart = piChart.Object as IMeasurementScope; imsChart.ChangeName("New Chart"); imsChart.CreateChild(out object axisObj); // Erzeugen einer neuen Achsengruppe unterhalb des Charts ProjectItem piAxis = axisObj as ProjectItem; IMeasurementScope imsAxis = piAxis.Object as IMeasurementScope; imsAxis.ChangeName("New Axis"); imsAxis.CreateChild(out object channelObj); // Erzeugen eines neuen Kanals unterhalb der Achsengruppe ProjectItem piChannel = channelObj as ProjectItem; IMeasurementScope imsChannel = piChannel.Object as IMeasurementScope; imsChannel.ChangeName("New Channel"); IMeasurementScope DataPoolObj = (IMeasurementScope)ScopeProjectItem.ProjectItems.Item(1).Object; DataPoolObj.CreateChild(out object acqObj); // Erzeugen einer neuen Acquisition im DataPool ProjectItem piAcq = acqObj as ProjectItem; IMeasurementScope imsAcq = piAcq.Object as IMeasurementScope; imsAcq.ChangeName("New Acq"); foreach (Property prop in piChannel.Properties) { Debug.WriteLine(prop.Name + " - " + prop.Value); // Wir geben einmal alle Properties mit Nammen und aktuellem Wert aus um uns einen Ьberblick zu verschaffen.
if (prop.Name == "Y-Data.Acquisition") prop.Value = imsAcq; // Wir setzen die Acquisition des Channels auf die zuvor angelegte Acquisition im DataPool } Starting and stopping recordings The corresponding methods of the IMeasurementScope interface can be used to start/stop a configured scope recording: Code snippet (C#): ScopeObj.StartRecord() ScopeObj.StopRecord(); 6.9.2 Creating and handling TwinCAT Analytics projects | Creating and handling TwinCAT Analytics projects The TwinCAT Automation Interface provides methods and properties to create and access TwinCAT Measurement projects.
The following chapter describes how some basic tasks can be solved with a TwinCAT project and includes information on the following topics: Requirements Creating a TwinCAT Measurement project Creating, accessing and handling a TwinCAT Analytics configuration Creating, accessing and handling networks Creating, accessing and handling functions Starting and stopping an analysis Further information on TwinCAT Measurement can be found on the corresponding webpage in our information system . TE1000 288 Version: 1.7.0