WCF Link - Further Functions |
The code below shows some examples of using miscellaneous functions exposed by the IRelaxISWCFLink WCF interface.
The functions generally first construct a RelaxISWCFLinkProxy object by calling GetDefaultProxy. This proxy object is then used to call the functions. This will then execute the functions in the RelaxIS instance that has an active WCF Link.
Reference to the RelaxIS_SDK.dll
Reference to System.ServiceModel.dll
.NET Framework 4.7.2 target (class library)
Recommended: Development environment with compiler e.g. RelaxIS SDK Code Editor, Microsoft Visual Studio
The first example demonstrates how to use the WCF Link to read data from a file using the built-in file formats. The spectra are then added to the current project.
The second examples shows how to list various plugins and tools loaded in RelaxIS. The results are written to the console.
// <copyright file="WCFMiscFunctions.cs" company="rhd instruments GmbH and Co. KG"> // Copyright (c) rhd instruments GmbH and Co. KG. All rights reserved. // Licensed under the MIT No Attribution (MIT-0) license. See section 'License' in the 'SDK Examples / Tutorials' topic for full license information. // </copyright> namespace RelaxIS_SDK_Examples.WCFInterface { using System; using RelaxIS_SDK.RelaxISWCFLink; /// <summary> /// Implements examples for working with spectrum data via the WCF link. /// </summary> public static class WCFMiscFunctions { /// <summary> /// An example of using the built-in file formats to read impedance spectra from a file. /// </summary> /// <param name="filename">The filename of the file to load.</param> public static void LoadSpectraFromFile(string filename) { using (var wcf = RelaxISWCFLinkProxy.GetDefaultProxy()) { var spectra = wcf.ReadEISDataFile(filename); if (spectra == null || spectra.Count == 0) { Console.WriteLine("The file did not contain any known data."); return; } foreach (var s in spectra) { wcf.AddSpectra(spectra); } } } /// <summary> /// Lists the currently available tools and fields in RelaxIS. /// </summary> public static void ListTools() { using (var wcf = RelaxISWCFLinkProxy.GetDefaultProxy()) { var transferFunctions = wcf.GetTransferFunctions(); var currentTransferFunction = wcf.GetCurrentTransferFunction(); var weightModes = wcf.GetWeightModes(); var currentWeightMode = wcf.GetCurrentWeightingMode(); var possibleMetadata = wcf.GetMetadataFields(); Console.WriteLine(string.Format("The current transfer function is: {0}", currentTransferFunction)); Console.WriteLine("Available transfer functions:"); foreach (var tf in transferFunctions) { Console.WriteLine(tf); } Console.WriteLine(); Console.WriteLine(string.Format("The current weight mode is: {0}", currentWeightMode)); Console.WriteLine("Available weight modes:"); foreach (var w in weightModes) { Console.WriteLine(w); } Console.WriteLine(); Console.WriteLine("Available metadata fields:"); foreach (var m in possibleMetadata) { Console.WriteLine(m); } } } } }