Documentation ¶
Index ¶
- Constants
- Variables
- func CombStatus(field, content string, first ...bool) string
- func Count() int
- func GetMsgName(id TMsgId) string
- func Init(conf ...*util.LogConf)
- func NewReportMarkdown(msg string, mentioned ...string) ([]byte, error)
- func NewReportText(msg string, mentioned ...string) ([]byte, error)
- func Overview() string
- func Report(errlogLv util.ELogLevel, send func(msg string))
- func Run(exec func(), conf ...*util.LogConf)
- func SetMsgName(id TMsgId, name string)
- func Uninstall(id TCtrlId) error
- func Wait(sleep ...util.TDurt)
- func Work() error
- type ControlBase
- func (this *ControlBase) HandleGore() *Gore
- func (this *ControlBase) HandleInit()
- func (this *ControlBase) HandleLaun()
- func (this *ControlBase) HandleStat() string
- func (this *ControlBase) HandleSusp()
- func (this *ControlBase) HandleTerm()
- func (this *ControlBase) HandleTick(now time.Time)
- func (this *ControlBase) HandleWake()
- type EContrlState
- type Gore
- type IControler
- type ICtrlHandler
- type IMLocker
- type IMRWLocker
- type IMTimer
- type IModuler
- type IMsger
- type IOControler
- type MCMsgHandFunc
- type MLock
- type MRWLock
- type MTimer
- func (this *MTimer) DayerHandler(asyn bool, after0 time.Duration, tickFun TimerHandFunc, right ...bool)
- func (this *MTimer) Init() *MTimer
- func (this *MTimer) TickTimer()
- func (this *MTimer) TimerHandler(asyn bool, d time.Duration, tickFun TimerHandFunc, right ...bool)
- func (this *MTimer) UnTimHandler(tickFun func() bool)
- type TCtrlId
- type TMsgId
- type TimerHandFunc
Constants ¶
const ( DEF_CONTROL_RATE = 10 // 控制器更新频率 DEF_CONTROL_CAPY = 250 // 控制器通道的默认大小 )
------------------------------------------------------------------------------ ====================================常量定义===================================== ------------------------------------------------------------------------------ Common Consts
Variables ¶
var ( ErrTimeOut = errors.New("TimeOut") ErrExitNormal = errors.New("NormalExit") ErrBusyTimeOut = errors.New("BusyTimeOut") ErrControlNotRunning = errors.New("ControlNotRunning") ErrSettingLoadNil = errors.New("SettingLoadNil") )
Common Errors
var MCGoreDef = Gore{0, DEF_CONTROL_CAPY}
内置 CtrlGore
var MCGoreHig = Gore{DEF_CONTROL_RATE * 2, DEF_CONTROL_CAPY * 2}
var MCGoreLow = Gore{DEF_CONTROL_RATE / 2, DEF_CONTROL_CAPY}
Functions ¶
Types ¶
type ControlBase ¶
type ControlBase struct { IOControler // 用继承的方式又有嵌入之意 } //
------------------------------------------------------------------------------ =================================默认空控制定义=================================== ------------------------------------------------------------------------------
func (*ControlBase) HandleGore ¶
func (this *ControlBase) HandleGore() *Gore
func (*ControlBase) HandleInit ¶
func (this *ControlBase) HandleInit()
func (*ControlBase) HandleLaun ¶
func (this *ControlBase) HandleLaun()
func (*ControlBase) HandleStat ¶
func (this *ControlBase) HandleStat() string
func (*ControlBase) HandleSusp ¶
func (this *ControlBase) HandleSusp()
func (*ControlBase) HandleTerm ¶
func (this *ControlBase) HandleTerm()
func (*ControlBase) HandleTick ¶
func (this *ControlBase) HandleTick(now time.Time)
func (*ControlBase) HandleWake ¶
func (this *ControlBase) HandleWake()
type EContrlState ¶
type EContrlState int32 //
=> 控制器运行状态
const ( ECS_Declare EContrlState = iota ECS_Initing ECS_Suspend // 不影响命令的执行 ECS_Running ECS_Closeup )
func (EContrlState) String ¶
func (e EContrlState) String() string
type IControler ¶
type IControler interface { // 线程ID[0:没启动loop] GoId() int // 控制器名称 Name() string // 控制器状态 State() EContrlState // 控制器状况 Status() string // 线程暂停 ThreadSusp() error // 线程唤醒 ThreadWake() error // 投递消息 PostMsg(msg IMsger) error // contains filtered or unexported methods }
=> Control开放接口
type ICtrlHandler ¶
type ICtrlHandler interface { // 控制器参数 - [重载--重写] 控制器初始化参数 [不重写则使用默认值] HandleGore() *Gore // 控制器准备 - [基类->派生] 当控制器创建后调用 初始数据 HandleInit() // 控制器销毁 - [派生->基类] 当控制器销毁时调用 清理数据 HandleTerm() // 控制器首次 - [基类->派生] 当控制器运行时最先调用且调用一次 HandleLaun() // 控制器更新 - [基类->派生] 当控制器tick时调用 定时更新 HandleTick(now time.Time) // 控制器暂停 - [基类->派生] 当控制器被暂停时调用 HandleSusp() // 控制器恢复 - [基类->派生] 当控制器被恢复时调用 HandleWake() // 运行状况 - [基类->派生] 当调用Status时调用 建议JSON格式 HandleStat() string // contains filtered or unexported methods }
=> Control代理接口
type IMLocker ¶
type IMLocker interface { // 主锁 Lock() interface{} UnLock(i interface{}) }
------------------------------------------------------------------------------ =================================Defer Lock 接口================================= ------------------------------------------------------------------------------
type IMRWLocker ¶
type IMRWLocker interface { // 写锁 WLock() interface{} WUnLock(i interface{}) // 读锁 RLock() interface{} RUnLock(i interface{}) }
------------------------------------------------------------------------------ =================================Defer RWLock 接口================================= ------------------------------------------------------------------------------
type IMTimer ¶
type IMTimer interface { // 添加定时器[当tickFun返回false时自动删除此TimerHandler] TimerHandler(asyn bool, d time.Duration, tickFun TimerHandFunc, right ...bool) // 添加每天一次的定时器[同上](after0:每天超过零点多少时间) DayerHandler(asyn bool, after0 time.Duration, tickFun TimerHandFunc, right ...bool) // 移除定时器 UnTimHandler(tickFun func() bool) }
type IModuler ¶
type IModuler interface { // 模块名称 Name() string // 模块加载 Load(timer IMTimer) error // 模块运行 Tick() // 模块销毁 Term() }
------------------------------------------------------------------------------ ====================================Module接口=================================== ------------------------------------------------------------------------------
type IOControler ¶
type IOControler interface { // 继承接口 util.ILogMe // 继承接口 IMTimer // 继承接口 IMRWLocker // 继承接口 IControler // 获取Handler Handler() ICtrlHandler // 注册消息处理函数 SetCMHandle(mid TMsgId, handle MCMsgHandFunc) }
=> Control自主接口
type MCMsgHandFunc ¶
type MCMsgHandFunc func(IMsger)
------------------------------------------------------------------------------ ===================================Control接口================================== ------------------------------------------------------------------------------
type MTimer ¶
type MTimer struct {
// contains filtered or unexported fields
}
func (*MTimer) DayerHandler ¶
func (*MTimer) TimerHandler ¶
func (*MTimer) UnTimHandler ¶
type TMsgId ¶
type TMsgId int //
=> 控制器消息类型
type TimerHandFunc ¶
------------------------------------------------------------------------------ =================================MTimer开放接口================================= ------------------------------------------------------------------------------