Building a C# app that uses the Conval COM Server
- Start Visual Studio and create a project (e.g. Console Application)
- Add Reference to COMConval10 to project. You can find "References" right under the project in the Solution Explorer. This creates a "Interop.COMConval10.dll"
- In code try:
// Create Conval COM Server instance:
var conval = new Conval10();
// Create a ControlValve calculation and get access to the parameters:
var cd = conval.NewCalculation(2).CalculationData;
// Set some parameters
cd.ParamByName["T1"].Value = 10;
cd.ParamByName["P1"].Value = 10;
cd.ParamByName["FluidName"].Text = "Water";
// get some parameters:
Console.WriteLine("T1 = {0} {1}", cd.ParamByName["T1"].Value, cd.ParamByName["T1"].CalcUnit.UnitName);
Console.WriteLine("P1 = {0} {1}", cd.ParamByName["P1"].Value, cd.ParamByName["P1"].CalcUnit.UnitName);
Console.WriteLine("Rho1 = {0} {1}", cd.ParamByName["Rho1"].Value, cd.ParamByName["Rho1"].CalcUnit.UnitName);
// change a unit of measurement:
cd.ParamByName["T1"].CalcUnit.UnitName = "K";
Console.WriteLine("T1 = {0} {1}", cd.ParamByName["T1"].Value, cd.ParamByName["T1"].CalcUnit.UnitName);
// the end:
Console.ReadLine();
conval.Exit();
This is just a simple example. To get more information about using the COM Server, please refer to the COMServer documentation.
- Zum Verfassen von Kommentaren bitte Anmelden oder Registrieren.