using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using KVS_IIOT_NET_Interface1;
using KVS_IIOT_NET_Interface1.Attribute;
using KVS_IIOT_NET_Interface1.Transmit;
namespace Actuator
{
public class ClassDevice : Interface1
{
#region Interface1接口实现
public string Name => "执行器";
public string Description => "描述";
public string Version => Assembly.GetExecutingAssembly().GetName().Version.ToString();
public void Delete()
{
}
public void Reload()
{
}
#endregion
#region 事件
[AttInterfaceEvent(Name = "电源状态改变事件")]
public event ClassDelegate.DelegateBoolean EventPowerChanged;
#endregion
#region 字段&属性
private PowerSourceIn _powerSourceIn = new PowerSourceIn();
[AttInterfaceProperty(Name = "设置供电", IsPort = true)]
public PowerSource SetPowerSource
{
set
{
_powerSourceIn.PowerSource = value;
}
}
#endregion
#region 构造函数
public ClassDevice()
{
_powerSourceIn.EventPowerChanged += _powerSourceIn_EventPowerChanged;
}
private void _powerSourceIn_EventPowerChanged(bool value, string eventName)
{
EventPowerChanged?.Invoke(value, "EventPowerChanged");
}
#endregion
}
}
首先再申明对象时要执行构造函数,然后构造函数会调用_powerSourceIn_EventPowerChanged,至于其他的执行要看对象调用的顺序了,只看类无法确定执行顺序