datachange

package
v0.0.0-...-212a885 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

* @Author: Wangjun * @Date: 2022-01-06 16:46:05 * @LastEditTime: 2022-02-14 10:52:32 * @LastEditors: Wangjun * @Description: * @FilePath: \plc_state_fand:\go\src\gitee.com\haodreams\golib\datachange\group.go * hnxr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataChange

type DataChange struct {
	ID     int //ID 识别码
	Memory     //内存数据

	Relation DataChanger //关联接口
}

func (*DataChange) Push

func (m *DataChange) Push(now int64, value int64, force bool)

*

  • @description: 填入数据
  • @param {int64} now 当前时间
  • @param {int64} value
  • @param {int64} force 是否强制推送
  • @return {*}

type DataChanger

type DataChanger interface {
	OnDataChange(dc *DataChange, now, currentValue int64)
}

*

  • @description: 数据改变的回调服务
  • @param {*}
  • @return {*}

type DataGroup

type DataGroup struct {
	// contains filtered or unexported fields
}

func NewDataGroup

func NewDataGroup(path string) *DataGroup

*

  • @description: 生成一个datagroup
  • @param {string} path 内存数据保存的路径
  • @return {*}

func (*DataGroup) Add

func (m *DataGroup) Add(dc *DataChange)

*

  • @description: 添加一个数据变位事件
  • @param {*DataChange} dc
  • @return {*}

func (*DataGroup) Fresh

func (m *DataGroup) Fresh() (err error)

*

  • @description: 更新内存的数据,并把文件中缓存的数据更新到内存
  • @param {*}
  • @return {*}

func (*DataGroup) GetDataChange

func (m *DataGroup) GetDataChange(id int) (dc *DataChange)

*

  • @description: 获取dataChange
  • @param {int} id
  • @return {*}

func (*DataGroup) Load

func (m *DataGroup) Load() (err error)

*

  • @description: 加载文件数据到内存,必须在Fresh之后使用
  • @param {*}
  • @return {*}

func (*DataGroup) Reset

func (m *DataGroup) Reset()

*

  • @description: 数据复位
  • @param {*}
  • @return {*}

func (*DataGroup) Save

func (m *DataGroup) Save() (err error)

*

  • @description: 保存缓存的数据
  • @param {*}
  • @return {*}

func (*DataGroup) Setup

func (m *DataGroup) Setup(path string)

*

  • @description: 初始化设置
  • @param {string} path 缓存文件保存的路径
  • @return {*}

type Memory

type Memory struct {
	Key   string //主键
	Value int64  //变化的值
	Time  int64  //变化时的时间
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL