Commit aee8b770 authored by JiangYixing's avatar JiangYixing

zwt code

parents
File added
# ignore vs
*.suo
.vs/
*.~vsd*
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CFET2APP", "CFET2APP\CFET2APP.csproj", "{384C50B6-4E84-4C49-A5D5-864FB07D4CF0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModbusTCP", "ModbusTCP\ModbusTCP.csproj", "{C78D6456-14DF-48F9-BC1F-889DEC4A93EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZWT-ModbusTCP", "ZWT-ModbusTCP\ZWT-ModbusTCP.csproj", "{3CDF8649-16BC-4902-806A-AB0C66CF9EB9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZWTOLDModbusTCP", "ZWTOLDModbusTCP\ZWTOLDModbusTCP.csproj", "{52E8D8D1-0FC5-4120-AFCE-EC5183BAC2F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{384C50B6-4E84-4C49-A5D5-864FB07D4CF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{384C50B6-4E84-4C49-A5D5-864FB07D4CF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{384C50B6-4E84-4C49-A5D5-864FB07D4CF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{384C50B6-4E84-4C49-A5D5-864FB07D4CF0}.Release|Any CPU.Build.0 = Release|Any CPU
{C78D6456-14DF-48F9-BC1F-889DEC4A93EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C78D6456-14DF-48F9-BC1F-889DEC4A93EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C78D6456-14DF-48F9-BC1F-889DEC4A93EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C78D6456-14DF-48F9-BC1F-889DEC4A93EA}.Release|Any CPU.Build.0 = Release|Any CPU
{3CDF8649-16BC-4902-806A-AB0C66CF9EB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CDF8649-16BC-4902-806A-AB0C66CF9EB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CDF8649-16BC-4902-806A-AB0C66CF9EB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CDF8649-16BC-4902-806A-AB0C66CF9EB9}.Release|Any CPU.Build.0 = Release|Any CPU
{52E8D8D1-0FC5-4120-AFCE-EC5183BAC2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52E8D8D1-0FC5-4120-AFCE-EC5183BAC2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52E8D8D1-0FC5-4120-AFCE-EC5183BAC2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52E8D8D1-0FC5-4120-AFCE-EC5183BAC2F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EE1EEBDC-8778-4E5E-9BCA-80F8819406CD}
EndGlobalSection
EndGlobal
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net461</TargetFrameworks>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ApplicationIcon>bitbug_favicon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Content Include="bitbug_favicon.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="5.2.0" />
<PackageReference Include="CFET2Core" Version="2.0.10" />
<PackageReference Include="CommandLineParser" Version="1.9.71" />
<PackageReference Include="MessagePack" Version="2.3.85" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.7" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.7.0" />
<PackageReference Include="Nancy" Version="2.0.0" />
<PackageReference Include="Nancy.Hosting.Self" Version="2.0.0" />
<PackageReference Include="Nancy.Viewengines.Razor" Version="2.0.0" />
<PackageReference Include="NancyHttpCommunicationModule" Version="1.0.8" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.4" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.7.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="websocket" Version="1.0.0" />
<PackageReference Include="WebsocketEventThing" Version="1.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.NETCore.App">
<Version>2.2.8</Version>
</PackageReference>
</ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugFramework>net461</ActiveDebugFramework>
<ActiveDebugProfile>CFET2APP</ActiveDebugProfile>
<_LastSelectedProfileId>E:\wfy\code\CFET2Core\Code\CFET2APP\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp2.1|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
\ No newline at end of file
using Jtext103.CFET2.CFET2App.cli;
using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jtext103.CFET2.CFET2App
{
partial class Cfet2Program:CFET2Host
{
static void Main(string[] args)
{
//dynamic load:
//load config file from args=>LoadConfig
//Loader.LoadLog(LoadConfig.Log);
//Loader.LoadCommunication(LoadConfig.Communication,host);
//Loader.LoadThing(LoadConfig.Things,host);
//very first thing to do is congfig logger
//初始化 LogManager
NlogProvider.Config();
Cfet2LogManager.SetLogProvider(new NlogProvider());
//inject and init the host app module
var host = new Cfet2Program();
HubMaster.InjectHubToModule(host);
//add communication module
//var comm= new NancyCM("http://localhost:13345");
//var comm = new AspNetCoreCommunicatonModule();
//host.MyHub.TryAddCommunicationModule(comm);
//todo lock comminication so no more communication can be added
//add things
host.AddThings(); //this is defined in a partial file of this class f12 to modify
//start communication modules
host.MyHub.StartCommunication();
//start all thins
host.MyHub.StartThings();
//start cli loop
var cli = new CliParser(host);
cli.Host = host;
Console.WriteLine("Cfet2 host Cli started");
while (true)
{
Console.Write("Cfet2> ");
var command=Console.ReadLine();
try
{
cli.Execute(command);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
if (cli.MySesstion.ShouldExit)
{
//quit the app
break;
}
}
}
}
}
using Jtext103.CFET2.CFET2App.ExampleThings;
using Jtext103.CFET2.Core;
using Jtext103.CFET2.NancyHttpCommunicationModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Jtext103.CFET2.Core.BasicThings;
using Nancy.Conventions;
using Nancy;
using Jtext103.CFET2.Core.Middleware.Basic;
using Jtext103.CFET2.CFET2App.DynamicLoad;
using Jtext103.CFET2.Core.Config;
using Jtext103.CFET2.WebsocketEvent;
namespace Jtext103.CFET2.CFET2App
{
public partial class Cfet2Program : CFET2Host
{
private void AddThings()
{
//------------------------------Pipeline------------------------------//
MyHub.Pipeline.AddMiddleware(new ResourceInfoMidware());
MyHub.Pipeline.AddMiddleware(new NavigationMidware());
GlobalConfig.Populate("./GlobalConfig.json");
//------------------------------Nancy HTTP通信模块------------------------------//
var nancyCM = new NancyCommunicationModule(GlobalConfig.HostUri, GlobalConfig.Accept);
MyHub.TryAddCommunicationModule(nancyCM);
//you can add Thing by coding here
//------------------------------Custom View------------------------------//
var customView = new CustomViewThing();
MyHub.TryAddThing(customView, "/", "customView", "./CustomView");
var remoteHub = new WebsocketEventThing();
MyHub.TryAddThing(remoteHub, @"/", "WsEvent", GlobalConfig.HostUri);
MyHub.EventHub.RemoteEventHubs.Add(remoteHub);
//If you don't want dynamic load things, please comment out the line below
var loader = new DynamicThingsLoader(this);
//var fakeai = new FakeAIThing();
//MyHub.TryAddThing(fakeai, "/", "fakeai", 16);
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;
using System.Reflection;
using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Log;
namespace Jtext103.CFET2.CFET2App.DynamicLoad
{
public class DynamicThingsLoader
{
private string dynamicThingsRootPath;
private string dynamicDllsFilePath;
private string separator;
private List<ThingModel> thingModels;
private List<string> thingDlls;
private Cfet2Program cfetHost;
Dictionary<string, Type> dllsDic = new Dictionary<string, Type>();
private string thingDllPath = "./thingDll";
private string thingConfigPath = "./thingConfig";
private ICfet2Logger logger = Cfet2LogManager.GetLogger("DynamicLoad");
public DynamicThingsLoader(Cfet2Program host)
{
cfetHost = host;
separator = Path.DirectorySeparatorChar.ToString();
//dynamicThingsRootPath = "." + separator + "DynamicLoad" + separator + "DynamicThing";
//dynamicDllsFilePath = "." + separator + "DynamicLoad" + separator + "DynamicDll";
thingModels = new List<ThingModel>();
thingDlls = new List<string>();
LoadAllThings(thingConfigPath);
LoadAndCopyDllsInDir(thingDllPath);
SetDlls();
AddAllThings();
}
//获取并存储一个文件夹下所有dll的路径并拷贝到执行目录,不会递归查找
private void LoadAndCopyDllsInDir(string dirPath)
{
DirectoryInfo root = new DirectoryInfo(dirPath);
foreach (FileInfo file in root.GetFiles())
{
if (file.Extension.ToLower() == ".dll")
{
try
{
File.Copy(file.FullName, "." + separator + file.Name);
}
catch
{
//Console.WriteLine("Please note a dll copy failed: " + file.FullName);
}
}
}
}
//递归加载所有的Thing
private void LoadAllThings(string rootPath)
{
DirectoryInfo root = new DirectoryInfo(rootPath);
//搜索这一层所有文件
foreach (FileInfo file in root.GetFiles())
{
//判断为一个Thing
if (file.Name == "Config.json")
{
var newThing = new ThingModel();
if (newThing.LoadConfig(file.FullName))
{
thingModels.Add(newThing);
}
else
{
Console.WriteLine("Failed to load Thing: " + root.Name + "!");
}
//如果有dll文件夹,加载其中的内容到dlls中
if (Directory.Exists(rootPath + separator + "dll"))
{
LoadAndCopyDllsInDir(rootPath + separator + "dll");
}
}
}
//递归搜索子文件夹
foreach (DirectoryInfo dir in root.GetDirectories())
{
LoadAllThings(dir.FullName);
}
}
private void SetDlls()
{
DirectoryInfo root = new DirectoryInfo("./");
foreach (FileInfo file in root.GetFiles())
{
if (file.Extension.ToLower() == ".dll")
{
thingDlls.Add(file.FullName);
}
}
}
//将所有Thing实例化并挂载到CFET
private void AddAllThings()
{
var builder = new ContainerBuilder();
//添加所有dll
foreach (var dll in thingDlls)
{
try
{
var assembly = Assembly.LoadFrom(dll);
builder.RegisterAssemblyTypes(assembly);
builder.RegisterAssemblyTypes(assembly).AsImplementedInterfaces();
}
catch
{
Console.WriteLine("Please note a dll load failed: " + dll);
}
}
IContainer container;
ILifetimeScope scope;
try
{
container = builder.Build();
scope = container.BeginLifetimeScope();
}
catch (Exception e)
{
throw new Exception(e.ToString());
}
foreach (var dll in thingDlls)
{
Type[] types = null;
try
{
types = Assembly.LoadFrom(dll).GetTypes();
}
catch (Exception e)
{
throw new Exception(e.ToString()+" "+ dll.ToString());
}
foreach (var type in types)
{
dllsDic[type.FullName] = type;
}
}
//添加每个Thing
foreach (var thing in thingModels)
{
Type type = null;
Console.WriteLine(thing.Config.Type);
type = dllsDic[thing.Config.Type];
try
{
dynamic ins = scope.Resolve(type);
//type.GetType();
//添加配置文件路径
cfetHost.MyHub.TryAddThing(ins, thing.MountPath, thing.Name,thing.Config.InitObj,thingConfigPath);
logger.Info("AddThing:"+ thing.Name);
}
catch (Exception e)
{
throw new Exception(e.ToString());
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Jtext103.CFET2.CFET2App.DynamicLoad
{
public class ThingModel
{
/// <summary>
/// Thing在CFET下的挂载路径
/// </summary>
public string MountPath { get; set; }
/// <summary>
/// Thing的名字
/// </summary>
public string Name { get; set; }
/// <summary>
/// 存在Config.json中的内容
/// </summary>
public ConfigModel Config { get; set; }
public ThingModel()
{
Config = new ConfigModel();
}
/// <summary>
/// 读取Thing的文件夹下的Config.json文件内容
/// </summary>
/// <param name="configFilePath">Config.json文件的完整路径</param>
/// <returns>成功返回true失败返回false</returns>
public bool LoadConfig(string configFilePath)
{
bool result = true;
try
{
JsonConvert.PopulateObject(File.ReadAllText(configFilePath, Encoding.Default), Config);
int startIndex = configFilePath.IndexOf("thingConfig")+ "thingConfig".Length;
int endIndex = configFilePath.IndexOf("Config.json");
string fullThingPath = configFilePath.Substring(startIndex, endIndex - startIndex - 1).Replace(Path.DirectorySeparatorChar, '/');
int breakIndex = fullThingPath.LastIndexOf('/');
MountPath = fullThingPath.Substring(0, breakIndex + 1);
Name = fullThingPath.Substring(breakIndex + 1, fullThingPath.Length - breakIndex - 1);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
result = false;
}
return result;
}
}
public class ConfigModel
{
/// <summary>
/// Thing的类型,需要有完整的命名空间+类名
/// </summary>
public string Type { get; set; }
/// <summary>
/// Thing挂载时传入的参数
/// </summary>
public object InitObj { get; set; }
}
}

using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Attributes;
using Jtext103.CFET2.Core.Event;
using Jtext103.CFET2.Core.Extension;
using Jtext103.CFET2.Core.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jtext103.CFET2.CFET2App.ExampleThings
{
public class EventListener:Thing
{
//the regex expression, if you don't understand you can use exact match, or learn regex
private ListenerConfig config =new ListenerConfig { Source= @"(\/(\w)+)*\/base", EventType="changed"} ;
Token token;
private ICfet2Logger logger;
public override void TryInit(object initObj)
{
base.TryInit(initObj);
//get a logger
logger = Cfet2LogManager.GetLogger("Event");
if (initObj != null)
{
config = (ListenerConfig)initObj.TryConvertTo(typeof(ListenerConfig));
}
token=MyHub.EventHub.Subscribe(new EventFilter(config.Source, config.EventType), handler);
}
private void handler(EventArg e)
{
//Console.WriteLine($"{e.Source} has {e.EventType} to {e.Sample}");
logger.Debug($"{e.Source} has {e.EventType} to {e.Sample}");
}
[Cfet2Method]
public void UnSub()
{
token.Dispose();
}
}
class ListenerConfig
{
public string Source { get; set; }
public string EventType { get; set; }
}
}
using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Attributes;
using Jtext103.CFET2.Core.Event;
using Jtext103.CFET2.Core.Extension;
using Jtext103.CFET2.Core.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Jtext103.CFET2.CFET2App.ExampleThings
{
public class FakeAIThing : Thing
{
private FakeAICard myFakeAICard;
public override void TryInit(object channelCount = null)
{
//myFakeAICard = new FakeAICard((int)channelCount);
myFakeAICard = new FakeAICard(2);
}
[Cfet2Config(ConfigActions = ConfigAction.Set, Name = "ChannelCountConfig")]
public void ChannelCountConfigSet(int channelCount)
{
myFakeAICard.ChannelCount = channelCount;
}
[Cfet2Config(ConfigActions = ConfigAction.Get, Name = "ChannelCountConfig")]
public int ChannelCountConfigGet()
{
return myFakeAICard.ChannelCount;
}
[Cfet2Status]
public int ChannelCount()
{
return myFakeAICard.ChannelCount;
}
[Cfet2Status]
public Status AIState()
{
return myFakeAICard.AIState;
}
[Cfet2Status]
public double[] LatestData()
{
return myFakeAICard.LatestData;
}
[Cfet2Method]
public void TryArm()
{
myFakeAICard.TryArm();
}
[Cfet2Method]
public void TryStop()
{
myFakeAICard.TryStop();
}
}
public class FakeAICard
{
public int ChannelCount { get; set; }
public double[] LatestData { get; private set; }
public Status AIState { get; private set; }
private Thread myAcuqisition;
public FakeAICard(int channelCount)
{
ChannelCount = channelCount;
}
public void TryArm()
{
if(AIState == Status.Idle)
{
LatestData = new double[ChannelCount];
myAcuqisition = new Thread(FakeAcquisition);
myAcuqisition.Start();
AIState = Status.Running;
}
}
private void FakeAcquisition()
{
Random rd = new Random();
while(true)
{
for(int i = 0; i < LatestData.Length; i++)
{
LatestData[i] = rd.NextDouble() + i;
}
Thread.Sleep(100);
}
}
public void TryStop()
{
if(AIState == Status.Running)
{
myAcuqisition.Abort();
myAcuqisition.DisableComObjectEagerCleanup();
AIState = Status.Idle;
}
}
}
public enum Status
{
Idle = 0,
Running = 2
}
}
using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jtext103.CFET2.CFET2App.ExampleThings
{
public class ObjParam : Thing
{
[Cfet2Config]
public Ract MyRact { get; set; } = new Ract();
[Cfet2Status("defaultStatus")]
public string GetDefaultStatus()
{
return this.Path + @"/defaultStatus";
}
[Cfet2Method]
public Ract Replace(float x ,float y, float h, float w)
{
MyRact.X = x;
MyRact.Y = y;
MyRact.H = h;
MyRact.W = w;
return MyRact;
}
[Cfet2Method]
public Ract Scale(float xFactor,float yFactor)
{
MyRact.W = xFactor;
MyRact.H = yFactor;
return MyRact;
}
public override void TryInit(object initObj)
{
base.TryInit(initObj);
if (initObj != null)
{
MyRact=initObj as Ract;
}
Console.WriteLine($"useless init with : { MyRact.ToString()}");
}
public override void Start()
{
base.Start();
Console.WriteLine($"useless start with : { MyRact.ToString()}");
}
}
public class Ract
{
public string Name { get; set; } = "";
public float W { get; set; }
public float H { get; set; }
public float X { get; set; }
public float Y { get; set; }
public override string ToString()
{
return $"Name: {Name}, X: {X}, Y: {Y}, H: {H}, W: {W}";
}
}
}
using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Attributes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jtext103.CFET2.CFET2App.ExampleThings
{
public class PcMonitorThing:Thing
{
//status
[Cfet2Status("ram")]
public float GetRam()
{
var ramCounter = new PerformanceCounter("Memory", "Available MBytes", true);
return ramCounter.NextValue();
}
[Cfet2Status("defaultStatus")]
public string GetDefaultStatus()
{
return this.Path + @"/defaultStatus";
}
}
}
using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Attributes;
using Jtext103.CFET2.Core.Event;
using Jtext103.CFET2.Core.Extension;
using Jtext103.CFET2.Core.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Jtext103.CFET2.CFET2App.ExampleThings
{
/// <summary>
/// 可以用于请求另一台主机上的资源
/// </summary>
public class RemoteRequester : Thing
{
[Cfet2Status]
public object Status(string requestUri)
{
//object result = MyHub.TryGetResourceSampleWithUri(requestUri);
object val = MyHub.TryGetResourceSampleWithUri(requestUri).ObjectVal;
return val;
}
[Cfet2Method]
public object Method(string requestUri)
{
//object result = MyHub.TryInvokeSampleResourceWithUri(requestUri);
object val = MyHub.TryInvokeSampleResourceWithUri(requestUri).ObjectVal;
return val;
}
[Cfet2Config(ConfigActions = ConfigAction.Get, Name = "Config")]
public object ConfigGetYourMother(string requestUri)
{
//object result = MyHub.TryGetResourceSampleWithUri(requestUri);
object val = MyHub.TryGetResourceSampleWithUri(requestUri).ObjectVal;
return val;
}
[Cfet2Config(ConfigActions = ConfigAction.Set, Name = "Config")]
public void ConfigSetYourSon(string requestUri, string param)
{
//object result = MyHub.TrySetResourceSampleWithUri(requestUri);
object val = MyHub.TrySetResourceSampleWithUri(requestUri + "/" + param).ObjectVal;
//return val;
}
}
}
using Jtext103.CFET2.Core;
using Jtext103.CFET2.Core.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Jtext103.CFET2.CFET2App.ExampleThings
{
public class UseLessThing:Thing
{
private string staticConfig="default";
private int _base;
[Cfet2Status("defaultStatus")]
public string GetDefaultStatus()
{
return this.Path + @"/defaultStatus";
}
[Cfet2Config]
public int Base
{
get
{
return _base;
}
set
{
if (_base != value)
{
_base = value;
//exsample of publis event
MyHub.EventHub.Publish(GetPathFor("Base"), "changed", _base);
}
}
}
[Cfet2Status]
public int Value(int input) => input* Base;
[Cfet2Status]
public int OtherBase(string otherBaseUri)
{
var otherBaseValue =(int) MyHub.TryGetResourceSampleWithUri(otherBaseUri).ObjectVal;
return Base * otherBaseValue;
}
[Cfet2Method]
public void Say(string msg)
{
if (msg == "gg")
{
throw new Exception("gg, intended exception");
}
Console.WriteLine("you said: "+msg);
}
public override void TryInit(object initObj)
{
base.TryInit(initObj);
if (initObj != null)
{
staticConfig = initObj.ToString();
}
//Console.WriteLine("useless init with : "+ staticConfig);
}
public override void Start()
{
base.Start();
//Console.WriteLine("useless start with : " + staticConfig);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net6.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<History>True|2021-12-30T08:39:28.1827982Z;False|2021-12-30T16:38:32.2234828+08:00;True|2021-12-21T09:12:48.5151764+08:00;</History>
</PropertyGroup>
</Project>
\ No newline at end of file
This diff is collapsed.
{
"RegularMatches":
{
}
}
\ No newline at end of file
{
"IP":"http://localhost",
"Port":"8001",
"Accept":"Json"
}
\ No newline at end of file
This diff is collapsed.
2022/10/27 09:11:22.347 ResourceThing Info
tryinit:customView
2022/10/27 09:11:22.389 ResourceThing Info
tryinit:WsEvent
2022/10/27 09:11:24.777 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:11:24.777 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:11:24.784 ResourceThing Info
tryinit:ZWTNewThing
2022/10/27 09:11:24.784 DynamicLoad Info
AddThing:ZWTNewThing
2022/10/27 09:11:24.784 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:11:24.784 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:11:24.784 ResourceThing Info
tryinit:ZWTOldThing
2022/10/27 09:11:24.784 DynamicLoad Info
AddThing:ZWTOldThing
2022/10/27 09:11:24.784 NancyModule Info
NancyTaskRun
2022/10/27 09:11:24.795 Hub Info
customView Started.
2022/10/27 09:11:24.815 Hub Info
WsEvent Started.
2022/10/27 09:11:24.815 CFET2TCP Info
CFET2TCP
2022/10/27 09:11:24.815 Hub Info
TCPThing Started.
2022/10/27 09:11:24.815 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 0
2022/10/27 09:11:24.830 ZWTModbusTCP Info
ZWT ModbusTCP
2022/10/27 09:11:24.890 Hub Info
ZWTNewThing Started.
2022/10/27 09:11:24.890 CFET2TCP Info
CFET2TCP
2022/10/27 09:11:24.890 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 0
2022/10/27 09:11:24.890 Hub Info
TCPThing Started.
2022/10/27 09:11:24.890 ZWTOLDModbusTCP Info
ZWTOLD ModbusTCP
2022/10/27 09:11:24.890 Hub Info
ZWTOldThing Started.
2022/10/27 09:11:24.890 ResourceThing Info
tryinit:root
2022/10/27 09:13:00.072 ResourceThing Info
tryinit:customView
2022/10/27 09:13:00.113 ResourceThing Info
tryinit:WsEvent
2022/10/27 09:13:02.169 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:13:02.169 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:13:02.169 ResourceThing Info
tryinit:ZWTNewThing
2022/10/27 09:13:02.169 DynamicLoad Info
AddThing:ZWTNewThing
2022/10/27 09:13:02.169 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:13:02.169 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:13:02.169 ResourceThing Info
tryinit:ZWTOldThing
2022/10/27 09:13:02.169 DynamicLoad Info
AddThing:ZWTOldThing
2022/10/27 09:13:02.185 NancyModule Info
NancyTaskRun
2022/10/27 09:13:02.185 Hub Info
customView Started.
2022/10/27 09:13:02.206 Hub Info
WsEvent Started.
2022/10/27 09:13:02.206 CFET2TCP Info
CFET2TCP
2022/10/27 09:13:02.206 Hub Info
TCPThing Started.
2022/10/27 09:13:02.206 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 0
2022/10/27 09:13:02.218 ZWTModbusTCP Info
ZWT ModbusTCP
2022/10/27 09:13:02.218 Hub Info
ZWTNewThing Started.
2022/10/27 09:13:02.218 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 0
2022/10/27 09:13:02.218 CFET2TCP Info
CFET2TCP
2022/10/27 09:13:02.218 Hub Info
TCPThing Started.
2022/10/27 09:13:02.233 ZWTOLDModbusTCP Info
ZWTOLD ModbusTCP
2022/10/27 09:13:02.233 Hub Info
ZWTOldThing Started.
2022/10/27 09:13:02.233 ResourceThing Info
tryinit:root
2022/10/27 09:13:12.237 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 1
2022/10/27 09:13:12.237 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 1
2022/10/27 09:13:16.494 ResourceThing Info
tryinit:customView
2022/10/27 09:13:16.534 ResourceThing Info
tryinit:WsEvent
2022/10/27 09:13:18.473 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:13:18.473 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:13:18.473 ResourceThing Info
tryinit:ZWTNewThing
2022/10/27 09:13:18.473 DynamicLoad Info
AddThing:ZWTNewThing
2022/10/27 09:13:18.481 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:13:18.481 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:13:18.481 ResourceThing Info
tryinit:ZWTOldThing
2022/10/27 09:13:18.481 DynamicLoad Info
AddThing:ZWTOldThing
2022/10/27 09:13:18.481 NancyModule Info
NancyTaskRun
2022/10/27 09:13:18.481 Hub Info
customView Started.
2022/10/27 09:13:18.508 Hub Info
WsEvent Started.
2022/10/27 09:13:18.514 CFET2TCP Info
CFET2TCP
2022/10/27 09:13:18.514 Hub Info
TCPThing Started.
2022/10/27 09:13:18.514 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 0
2022/10/27 09:13:18.514 ZWTModbusTCP Info
ZWT ModbusTCP
2022/10/27 09:13:18.514 Hub Info
ZWTNewThing Started.
2022/10/27 09:13:18.514 CFET2TCP Info
CFET2TCP
2022/10/27 09:13:18.528 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 0
2022/10/27 09:13:18.528 Hub Info
TCPThing Started.
2022/10/27 09:13:18.528 ZWTOLDModbusTCP Info
ZWTOLD ModbusTCP
2022/10/27 09:13:18.528 Hub Info
ZWTOldThing Started.
2022/10/27 09:13:18.528 ResourceThing Info
tryinit:root
2022/10/27 09:13:28.538 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 1
2022/10/27 09:13:28.554 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 1
2022/10/27 09:13:38.563 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 2
2022/10/27 09:13:38.579 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 2
2022/10/27 09:16:03.682 ResourceThing Info
tryinit:customView
2022/10/27 09:16:03.716 ResourceThing Info
tryinit:WsEvent
2022/10/27 09:16:04.966 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:16:04.966 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:16:04.966 ResourceThing Info
tryinit:ZWTNewThing
2022/10/27 09:16:04.966 DynamicLoad Info
AddThing:ZWTNewThing
2022/10/27 09:16:04.966 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:16:04.966 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:16:04.966 ResourceThing Info
tryinit:ZWTOldThing
2022/10/27 09:16:04.966 DynamicLoad Info
AddThing:ZWTOldThing
2022/10/27 09:16:04.966 NancyModule Info
NancyTaskRun
2022/10/27 09:16:04.966 Hub Info
customView Started.
2022/10/27 09:16:04.995 Hub Info
WsEvent Started.
2022/10/27 09:16:04.998 CFET2TCP Info
CFET2TCP
2022/10/27 09:16:04.998 Hub Info
TCPThing Started.
2022/10/27 09:16:04.998 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 0
2022/10/27 09:16:04.998 ZWTModbusTCP Info
ZWT ModbusTCP
2022/10/27 09:16:04.998 Hub Info
ZWTNewThing Started.
2022/10/27 09:16:04.998 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 0
2022/10/27 09:16:04.998 CFET2TCP Info
CFET2TCP
2022/10/27 09:16:04.998 Hub Info
TCPThing Started.
2022/10/27 09:16:04.998 ZWTOLDModbusTCP Info
ZWTOLD ModbusTCP
2022/10/27 09:16:04.998 Hub Info
ZWTOldThing Started.
2022/10/27 09:16:04.998 ResourceThing Info
tryinit:root
2022/10/27 09:16:32.426 ResourceThing Info
tryinit:customView
2022/10/27 09:16:32.460 ResourceThing Info
tryinit:WsEvent
2022/10/27 09:16:33.716 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:16:33.716 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:16:33.716 ResourceThing Info
tryinit:ZWTNewThing
2022/10/27 09:16:33.716 DynamicLoad Info
AddThing:ZWTNewThing
2022/10/27 09:16:33.716 ResourceThing Info
tryinit:TCPThing
2022/10/27 09:16:33.716 DynamicLoad Info
AddThing:TCPThing
2022/10/27 09:16:33.716 ResourceThing Info
tryinit:ZWTOldThing
2022/10/27 09:16:33.716 DynamicLoad Info
AddThing:ZWTOldThing
2022/10/27 09:16:33.716 NancyModule Info
NancyTaskRun
2022/10/27 09:16:33.716 Hub Info
customView Started.
2022/10/27 09:16:33.746 Hub Info
WsEvent Started.
2022/10/27 09:16:33.748 CFET2TCP Info
CFET2TCP
2022/10/27 09:16:33.748 Hub Info
TCPThing Started.
2022/10/27 09:16:33.748 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 0
2022/10/27 09:16:33.748 ZWTModbusTCP Info
ZWT ModbusTCP
2022/10/27 09:16:33.748 Hub Info
ZWTNewThing Started.
2022/10/27 09:16:33.748 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 0
2022/10/27 09:16:33.748 CFET2TCP Info
CFET2TCP
2022/10/27 09:16:33.748 Hub Info
TCPThing Started.
2022/10/27 09:16:33.748 ZWTOLDModbusTCP Info
ZWTOLD ModbusTCP
2022/10/27 09:16:33.748 Hub Info
ZWTOldThing Started.
2022/10/27 09:16:33.748 ResourceThing Info
tryinit:root
2022/10/27 09:16:43.776 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.200:502 Reconnect time is 1
2022/10/27 09:16:43.776 CFET2TCP Info
Try connect ,which server ipport is 192.168.1.201:502 Reconnect time is 1
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment