- added new dotnet example
- fixed problem with garbage collected report handler delegate in .NET APIpull/6/head
parent
ca9cff0c90
commit
74058846b3
@ -0,0 +1,27 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("report_new_dataset")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("mzillgit")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using IEC61850.Common;
|
||||
using IEC61850.Client;
|
||||
using System.Threading;
|
||||
|
||||
namespace report_new_dataset
|
||||
{
|
||||
class ReportNewDataSetExample
|
||||
{
|
||||
private static void reportHandler (Report report, object parameter)
|
||||
{
|
||||
Console.WriteLine ("Received report:\n----------------");
|
||||
|
||||
if (report.HasTimestamp ())
|
||||
Console.WriteLine (" timestamp: " + MmsValue.MsTimeToDateTimeOffset (report.GetTimestamp ()).ToString ());
|
||||
|
||||
MmsValue values = report.GetDataSetValues ();
|
||||
|
||||
Console.WriteLine (" report dataset contains " + values.Size () + " elements");
|
||||
|
||||
for (int i = 0; i < values.Size(); i++) {
|
||||
if (report.GetReasonForInclusion(i) != ReasonForInclusion.REASON_NOT_INCLUDED) {
|
||||
Console.WriteLine(" element " + i + " included for reason " + report.GetReasonForInclusion(i).ToString() + " " + values.GetElement(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool running = true;
|
||||
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
IedConnection con = new IedConnection ();
|
||||
|
||||
string hostname;
|
||||
|
||||
if (args.Length > 0)
|
||||
hostname = args[0];
|
||||
else
|
||||
hostname = "10.0.2.2";
|
||||
//hostname = "localhost";
|
||||
|
||||
Console.WriteLine("Connect to " + hostname);
|
||||
|
||||
try
|
||||
{
|
||||
con.Connect(hostname, 102);
|
||||
|
||||
List<string> serverDirectory = con.GetServerDirectory(false);
|
||||
|
||||
foreach (string entry in serverDirectory)
|
||||
{
|
||||
Console.WriteLine("LD: " + entry);
|
||||
}
|
||||
|
||||
// create a new data set
|
||||
|
||||
List<string> dataSetElements = new List<string>();
|
||||
|
||||
dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn1.mag.f[MX]");
|
||||
dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn2.mag.f[MX]");
|
||||
dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn3.mag.f[MX]");
|
||||
dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn4.mag.f[MX]");
|
||||
|
||||
string dataSetReference = "simpleIOGenericIO/LLN0.ds1";
|
||||
|
||||
// Note: this function will throw an exception when a data set with the same name already exists
|
||||
con.CreateDataSet(dataSetReference, dataSetElements);
|
||||
|
||||
// reconfigure existing RCB with new data set
|
||||
|
||||
string rcbReference = "simpleIOGenericIO/LLN0.RP.EventsRCB01";
|
||||
|
||||
ReportControlBlock rcb = con.GetReportControlBlock(rcbReference);
|
||||
|
||||
rcb.GetRCBValues();
|
||||
|
||||
// note: the second parameter is not required!
|
||||
rcb.InstallReportHandler(reportHandler, rcb);
|
||||
|
||||
string rcbDataSetReference = dataSetReference.Replace('.', '$');
|
||||
|
||||
rcb.SetDataSetReference(rcbDataSetReference);
|
||||
rcb.SetTrgOps(TriggerOptions.DATA_CHANGED | TriggerOptions.INTEGRITY);
|
||||
rcb.SetIntgPd(5000);
|
||||
rcb.SetRptEna(true);
|
||||
|
||||
rcb.SetRCBValues();
|
||||
|
||||
/* run until Ctrl-C is pressed */
|
||||
Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) {
|
||||
e.Cancel = true;
|
||||
running = false;
|
||||
};
|
||||
|
||||
while (running) {
|
||||
Thread.Sleep(1000);
|
||||
Console.WriteLine("Total memory: " + GC.GetTotalMemory(false));
|
||||
}
|
||||
|
||||
// delete the data set
|
||||
con.DeleteDataSet("simpleIOGenericIO/LLN0.ds1");
|
||||
|
||||
con.Abort();
|
||||
}
|
||||
catch (IedConnectionException e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{71485F99-2976-45E6-B73D-4946E594C15C}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>report_new_dataset</RootNamespace>
|
||||
<AssemblyName>report_new_dataset</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IEC61850forCSharp\IEC61850forCSharp.csproj">
|
||||
<Project>{C35D624E-5506-4560-8074-1728F1FA1A4D}</Project>
|
||||
<Name>IEC61850forCSharp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue