1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/lishilei0523-h-opc

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Это зеркальный репозиторий, синхронизируется ежедневно с исходного репозитория.
Клонировать/Скачать
Program.cs 2.4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Lee Отправлено 6 лет назад 3dc9593
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using Hylasoft.Opc.Common;
using Hylasoft.Opc.Da;
using Hylasoft.Opc.Ua;
namespace Hylasoft.Opc.Cli
{
public static class Program
{
public static void Main(string[] args)
{
try
{
var assembly = Assembly.GetExecutingAssembly();
var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
var version = fvi.FileVersion;
Console.WriteLine("h-opc-cli v" + version);
Initialize(args);
}
catch (Exception e)
{
// GLOBAL EXCEPTION HANDLER
Console.WriteLine("The application ended unexpectedly.");
Console.WriteLine(e);
Console.WriteLine("To file an issue, visit http://github.com/hylasoft-usa/h-opc/issues");
}
}
private static void Initialize(string[] args)
{
if (args.Count() != 2)
{
Console.WriteLine("Usage: h-opc-cli [Type] [serverurl]");
Console.WriteLine("Supported types: " + GetSupportedTypes());
return;
}
SupportedTypes type;
try
{
type = GetOpcType(args[0]);
}
catch (ArgumentException)
{
Console.WriteLine(args[0] + " is not a supported type");
Console.WriteLine("Supported types: " + GetSupportedTypes());
return;
}
IOpcClient client;
try
{
client = GetClient(args[1], type);
client.Connect();
}
catch (Exception)
{
Console.WriteLine("An error occured when trying connecting to the server");
throw;
}
var repl = new Repl(client);
repl.Start();
}
private static SupportedTypes GetOpcType(string s)
{
SupportedTypes result;
if (!Enum.TryParse(s, true, out result))
throw new ArgumentException("Type not supported");
return result;
}
private static string GetSupportedTypes()
{
return string.Join(", ", Enum.GetNames(typeof(SupportedTypes)));
}
private static IOpcClient GetClient(string url, SupportedTypes type)
{
switch (type)
{
case SupportedTypes.Ua:
return new UaClient(new Uri(url));
case SupportedTypes.Da:
return new DaClient(new Uri(url));
default:
throw new ArgumentOutOfRangeException("type");
}
}
}
public enum SupportedTypes
{
Ua,
Da
}
}

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/lishilei0523-h-opc.git
git@gitlife.ru:oschina-mirror/lishilei0523-h-opc.git
oschina-mirror
lishilei0523-h-opc
lishilei0523-h-opc
master