frame

package
v0.0.0-...-205ef5e Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: MIT Imports: 51 Imported by: 0

Documentation

Overview

* ===========================================================================

  • 大脑 -> 公共方法集合
  • Brain -> public method collection

===========================================================================

* ===========================================================================

  • 行为树 BehaviorTree -> 包含BehaviorTask的队列
  • 行为任务 BehaviorTask -> 包含BehaviorAction的队列
  • 行为动作 BehaviorAction -> 包含具体行为Function队列Tag
  • {
  • "Tag": "TreeTag",
  • "Task": [
  • {
  • "Tag": "TaskTag",
  • "Action": [
  • {
  • "Tag": "Action_1",
  • "Command": "",
  • "Params": "",
  • "Callback": ""
  • },
  • {
  • "Tag": "Action_2",
  • "Command": "",
  • "Params": "",
  • "Callback": ""
  • }
  • ]
  • }
  • ]
  • }

===========================================================================

* ===========================================================================

  • 基于Socket协议的服务器

===========================================================================

* ===========================================================================

  • Mysql数据库服务

===========================================================================

* ===========================================================================

  • Redis数据库服务

===========================================================================

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BehaviorTreeS

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

func (*BehaviorTreeS) Branch2Tree

func (mBehaviorTree *BehaviorTreeS) Branch2Tree(tree *model.BehaviorTreeS, task *model.BehaviorTaskS, action *model.BehaviorActionS) *model.BehaviorTreeS

* Branch转BehaviorTree */

func (*BehaviorTreeS) FetchBranch

func (mBehaviorTree *BehaviorTreeS) FetchBranch(hub *model.QueueS, needShift ...bool) (*model.BehaviorTreeS, *model.BehaviorTaskS, *model.BehaviorActionS)

* 获取当前行为动作 */

func (*BehaviorTreeS) FindAction

func (mBehaviorTree *BehaviorTreeS) FindAction(task *model.BehaviorTaskS, tag string) *model.BehaviorActionS

* 删除行为动作 */

func (*BehaviorTreeS) FindTask

func (mBehaviorTree *BehaviorTreeS) FindTask(tree *model.BehaviorTreeS, tag string) *model.BehaviorTaskS

* 查询行为任务 */

func (*BehaviorTreeS) Json2Tree

func (mBehaviorTree *BehaviorTreeS) Json2Tree(json []byte) (int, interface{})

* 反序列化行为树 */

func (*BehaviorTreeS) NewAction

func (mBehaviorTree *BehaviorTreeS) NewAction(tag string, command string, params ...string) *model.BehaviorActionS

* 添加行为动作 */

func (*BehaviorTreeS) NewForest

func (mBehaviorTree *BehaviorTreeS) NewForest(tags ...string) model.BehaviorForestS

* 新建行为森林 */

func (*BehaviorTreeS) NewTask

func (mBehaviorTree *BehaviorTreeS) NewTask(tag string) *model.BehaviorTaskS

* 添加行为任务 */

func (*BehaviorTreeS) NewTree

func (mBehaviorTree *BehaviorTreeS) NewTree(tags ...string) *model.BehaviorTreeS

* 新建行为树 */

func (*BehaviorTreeS) Ontology

func (mBehaviorTree *BehaviorTreeS) Ontology(neuron *NeuronS) *BehaviorTreeS

* 构造本体 */

func (*BehaviorTreeS) Tree2Json

func (mBehaviorTree *BehaviorTreeS) Tree2Json(tree *model.BehaviorTreeS) (int, interface{})

* 序列化行为树 */

type BrainS

type BrainS struct {
	Const     model.Const
	Container struct {
		CommanderHub   model.SyncMapHub /* map[IP]SocketClient */
		CommanderQueue *model.QueueS
		CommanderReply *model.QueueS
	}
	// contains filtered or unexported fields
}

func (*BrainS) After

func (brain *BrainS) After(callback func(), i ...int) *time.Timer

* 方法等待 */

func (*BrainS) AnalyzeMessage

func (brain *BrainS) AnalyzeMessage(msgs string, splits ...string) []*model.GMessageS

* * 解析指令 * param: * msg => 指令体[string] * return: * object => [ * id => 指令编号 * head => 指挥头,判断是指令(?)/消息(!)/对象(~)[string] * tag => 指挥者,判断来自哪个模块[string] * cmd_array => 指令体,获取指令集[array] * ]

func (*BrainS) ArrayGetId

func (brain *BrainS) ArrayGetId(array []interface{}, data interface{}) int

* 获取数组内容下标 */

func (*BrainS) Base64Decoder

func (brain *BrainS) Base64Decoder(data string) []byte

func (*BrainS) Base64Encoder

func (brain *BrainS) Base64Encoder(data []byte) string

* Base64 */

func (*BrainS) BetweenPercent

func (brain *BrainS) BetweenPercent(price float64, average float64, percent float64) bool

* 判断是否在两个百分数之间 */

func (*BrainS) BfDecode

func (brain *BrainS) BfDecode(data []byte) []byte

* BlowFish解密 */

func (*BrainS) BfEncode

func (brain *BrainS) BfEncode(data []byte) []byte

* BlowFish加密 */

func (*BrainS) Bool2Int

func (brain *BrainS) Bool2Int(b bool) int

* 返回bool类型的int对应 */

func (*BrainS) Bytes2File

func (brain *BrainS) Bytes2File(FileName string, b []byte) (int, interface{})

* 持久化结构体存储 -> Bytes */

func (*BrainS) Bytes2PrivateKey

func (brain *BrainS) Bytes2PrivateKey(priv []byte) *rsa.PrivateKey

func (*BrainS) Bytes2PublicKey

func (brain *BrainS) Bytes2PublicKey(pub []byte) *rsa.PublicKey

func (*BrainS) CRC

func (brain *BrainS) CRC(b []byte) byte

* 获取CRC校验 */

func (*BrainS) CheckIsNull

func (brain *BrainS) CheckIsNull(i interface{}) bool

* 判断是否为空 */

func (*BrainS) CheckIsType

func (brain *BrainS) CheckIsType(i interface{}, typ string) bool

* 判断是否是对应数据类型 */

func (*BrainS) CheckTimeArrived

func (brain *BrainS) CheckTimeArrived(datetime string, interval int) bool

* 判断现在是否到达特定时间 */ * * param: * timestamp_check => 时间戳[timestamp] * interval => 间隔时间[int] * return: * boolean => [ * true => arrived * flase => not arrived * ]

func (*BrainS) ClearInterval

func (brain *BrainS) ClearInterval(stopC chan bool)

* 结束永久循环 */

func (*BrainS) EmojiUnicodeClear

func (brain *BrainS) EmojiUnicodeClear(s string) string

* Emoji表情清除 */

func (*BrainS) EmojiUnicodeDecode

func (brain *BrainS) EmojiUnicodeDecode(s string) string

* Emoji表情反序列化 */

func (*BrainS) EmojiUnicodeEncode

func (brain *BrainS) EmojiUnicodeEncode(s string) string

* Emoji表情序列化 */

func (*BrainS) Eval

func (brain *BrainS) Eval(service interface{}, function string, args ...interface{})

* 反射执行内部代码 */

func (*BrainS) File2Bytes

func (brain *BrainS) File2Bytes(FileName string) (int, interface{})

* 持久化结构体读取 -> Bytes */

func (*BrainS) File2Struct

func (brain *BrainS) File2Struct(FileName string) (int, interface{})

* 持久化结构体读取 -> 输出结构体JSONString[需套用结构解析] */

func (*BrainS) FileAppend

func (brain *BrainS) FileAppend(filePath string, data []byte) (int, interface{})

* 文件追加 */

func (*BrainS) FileMove

func (brain *BrainS) FileMove(filePath string, newPath string) (int, interface{})

* 文件重命名 */

func (*BrainS) FilePath2AbsPath

func (brain *BrainS) FilePath2AbsPath(dirPath string) string

* 相对路径转绝对路径 */

func (*BrainS) FileReader

func (brain *BrainS) FileReader(filePath string) (int, interface{})

* 文件读 */

func (*BrainS) FileRemovAll

func (brain *BrainS) FileRemovAll(DirPath string) (int, interface{})

* 文件夹删除 */

func (*BrainS) FileRemove

func (brain *BrainS) FileRemove(filePath string) (int, interface{})

* 文件删除 */

func (*BrainS) FileRename

func (brain *BrainS) FileRename(filePath string, filename string) (int, interface{})

* 文件重命名 */

func (*BrainS) FileWriter

func (brain *BrainS) FileWriter(filePath string, data []byte) (int, interface{})

* 文件写 */

func (*BrainS) GenerateMessage

func (brain *BrainS) GenerateMessage(head string, tag string, cmds []interface{}, id ...string) *bytes.Buffer

* 生成指令 */

* param: * <ID>#<head><tag>#<cmds>** * 123#?SYSINFO#token#** * return: * [string]

func (*BrainS) GenerateRSAKey

func (brain *BrainS) GenerateRSAKey(bitss ...int) *rsa.PrivateKey

* 生成新的RSAKey */

func (*BrainS) GetDateTime

func (brain *BrainS) GetDateTime(datetime string, changeDuration ...time.Duration) *model.TimeS

* 获取格式化时间 */ * * param: * datetime => similar to '2012-12-12 00:00:00'[string] * dateformat => just like '/' & '-' * timeformat => just like ':' * return: * object => [ * YMD => yyyy-MM-dd[string] * week => weekday[string] * time => HH:mm:ss[string] * timestamp => timestamp[timestamp] * datetime => datetime[datetime] * ]

func (*BrainS) GetFuncName

func (brain *BrainS) GetFuncName(i interface{}) string

* 反射获取方法名 */

func (*BrainS) GetLanIp

func (brain *BrainS) GetLanIp(ipRoute ...string) (int, interface{})

* 获取局域网内ip地址 -> ipRoute为IP查询段 */

func (*BrainS) GoldPoint

func (brain *BrainS) GoldPoint(price float64) (float64, float64)

* 获取黄金分割点 */

func (*BrainS) GzipDecoder

func (brain *BrainS) GzipDecoder(in []byte) ([]byte, error)

* Gzip Decoder */

func (*BrainS) GzipEncoder

func (brain *BrainS) GzipEncoder(in []byte) ([]byte, error)

* Gzip Encoder */

func (*BrainS) HEXDecoder

func (brain *BrainS) HEXDecoder(s string) []byte

func (*BrainS) HEXEncoder

func (brain *BrainS) HEXEncoder(b []byte) string

* HEX转化 */

func (*BrainS) HmacSha256Encode

func (brain *BrainS) HmacSha256Encode(data []byte, key string) string

* Sha256加密 */

func (*BrainS) HuffmanDecoder

func (brain *BrainS) HuffmanDecoder(in []byte) []byte

* Huffman Decoder */

func (*BrainS) HuffmanEncoder

func (brain *BrainS) HuffmanEncoder(in []byte, levels ...int) []byte

* Huffman Encoder */

func (*BrainS) Interface2Bytes

func (brain *BrainS) Interface2Bytes(i interface{}) []byte

* 通用数据类型转[]byte */

func (*BrainS) JsonChecker

func (brain *BrainS) JsonChecker(data []byte) bool

* Json -> CheckIsRight */

func (*BrainS) JsonDecoder

func (brain *BrainS) JsonDecoder(data []byte, structS ...interface{}) interface{}

* Json -> String2Object */

func (*BrainS) JsonEncoder

func (brain *BrainS) JsonEncoder(data interface{}, indent ...bool) []byte

* Json -> Object2String */

func (*BrainS) LogGenerater

func (brain *BrainS) LogGenerater(logtype int, model string, function string, content interface{})

* 结构化日志记录 */

func (*BrainS) MD5Encode

func (brain *BrainS) MD5Encode(data []byte) string

* MD5加密 */

func (*BrainS) Map2KeyArray

func (brain *BrainS) Map2KeyArray(data map[string]interface{}) []string

* 获取Map中的所有key */

func (*BrainS) Map2Struct

func (brain *BrainS) Map2Struct(m interface{}, structS interface{}) interface{}

* Map转结构体 */

func (*BrainS) MessageHandler

func (brain *BrainS) MessageHandler(tag string, function string, code int, data interface{}) model.MessageS

* 信息处理 */

func (*BrainS) NumPadZero

func (brain *BrainS) NumPadZero(num int, n int) int

* 质朴长存法补0 */

func (*BrainS) ObjectMerge

func (brain *BrainS) ObjectMerge(s ...[]interface{}) (slice []interface{})

* 合并对象 */

func (*BrainS) Ontology

func (brain *BrainS) Ontology() *BrainS

* 构造本体 */

func (*BrainS) PathAbs

func (brain *BrainS) PathAbs(dirPath string) string

* 构造绝对路径 */

func (*BrainS) PathAbs2PathBaseExt

func (brain *BrainS) PathAbs2PathBaseExt(dirPath string) (string, string, string)

* 获取绝对路径中的文件路径 */

func (*BrainS) PathCreate

func (brain *BrainS) PathCreate(dirPath string) (int, interface{})

* 创建文件夹 */

func (*BrainS) PathExists

func (brain *BrainS) PathExists(dirPath string) bool

* 查询文件夹 */

func (*BrainS) PathList

func (brain *BrainS) PathList(dirPath string) (int, interface{})

* 列出文件夹 */

func (*BrainS) PrivateKey2Bytes

func (brain *BrainS) PrivateKey2Bytes(key *rsa.PrivateKey) []byte

* PrivateKey流转化 */

func (*BrainS) PublicKey2Bytes

func (brain *BrainS) PublicKey2Bytes(key *rsa.PublicKey) []byte

* PublicKey流转化 */

func (*BrainS) RSADecrypt

func (brain *BrainS) RSADecrypt(cipher []byte, priv *rsa.PrivateKey) []byte

* RSA -> 解密 */

func (*BrainS) RSADecryptOAEP

func (brain *BrainS) RSADecryptOAEP(cipher []byte, priv *rsa.PrivateKey, salts ...[]byte) []byte

* RSA -> OAEP解密 */

func (*BrainS) RSAEncrypt

func (brain *BrainS) RSAEncrypt(plain []byte, pub *rsa.PublicKey) []byte

* RSA -> 加密 */

func (*BrainS) RSAEncryptOAEP

func (brain *BrainS) RSAEncryptOAEP(plain []byte, pub *rsa.PublicKey, salts ...[]byte) []byte

* RSA -> OAEP加密 */

func (*BrainS) RSASign

func (brain *BrainS) RSASign(priv *rsa.PrivateKey, plain []byte) []byte

* RSA -> 签名 */

func (*BrainS) RSASignPSS

func (brain *BrainS) RSASignPSS(priv *rsa.PrivateKey, plain []byte) []byte

* RSA -> PSS签名 */

func (*BrainS) RSAVerify

func (brain *BrainS) RSAVerify(pub *rsa.PublicKey, plain, signature []byte) bool

* RSA -> 验证 */

func (*BrainS) RSAVerifyPSS

func (brain *BrainS) RSAVerifyPSS(pub *rsa.PublicKey, plain, signature []byte) bool

* RSA -> PSS验证 */

func (*BrainS) RandomChar

func (brain *BrainS) RandomChar(n int) string

* 时间戳随机生成字符串 */

func (*BrainS) RandomInt

func (brain *BrainS) RandomInt(max int, seeds ...int64) int

* 时间戳随机生成正数 */

func (*BrainS) Request

func (brain *BrainS) Request(params model.RequestParamS, callback func(code int, data interface{}), proxyUrls ...*url.URL)
  • HTTP Request */ 构造Post方法 -> [ host, path := express.Url2HostPath(u) postData := url.Values{} postData.Add("key", "value") header := brain.Const.HTTPRequest.DefaultHeader header["Content-Type"] = []string{"application/x-www-form-urlencoded"} brain.Request(model.RequestParamS{PostData: postData.Encode(), Host: host, Path: path, Header: header}, func(code int, data interface{}) {})

]

func (*BrainS) RequestMultipartFile

func (brain *BrainS) RequestMultipartFile(params model.RequestParamS, filePathHub map[string]string, callback func(code int, data interface{}))

* MultipartFile Request */

func (*BrainS) RequestSync

func (brain *BrainS) RequestSync(param model.RequestParamS, proxyUrls ...*url.URL) (int, interface{})

* 同步执行Request */

func (*BrainS) RequestSync4Cookies

func (brain *BrainS) RequestSync4Cookies(param model.RequestParamS, proxyUrls ...*url.URL) (int, interface{})

* RequestSync -> 取Cookies */

func (*BrainS) Retry

func (brain *BrainS) Retry(times int, next func() (int, interface{}), callback func(code int, data interface{}), millisecond ...int) (code int, data interface{})

* 方法重试 */

times -> 尝试次数 next -> 尝试方法 callback -> 尝试方法回调 Return -> 最终返回值[正确区间为100-199]

func (*BrainS) SafeFunction

func (brain *BrainS) SafeFunction(next func(), callback ...func(err interface{}))

* TryCatch实现 */

func (*BrainS) SelectIterator

func (brain *BrainS) SelectIterator(hubLen int, lastIndex int) int

* 选择迭代器 */

func (*BrainS) SetInterval

func (brain *BrainS) SetInterval(next func() (int, interface{}), callback func(code int, data interface{}), interval int, stopC chan bool, needTimeDevides ...bool)

func (*BrainS) SetTimeoutInterval

func (brain *BrainS) SetTimeoutInterval(next func() (int, interface{}), callback func(code int, data interface{}), interval int, timeout int)

* 超时循环 */

<<<<<<< HEAD

104 -> 超时

======= 104 -> 超时 >>>>>>> 91cdc91

func (*BrainS) Sha1Encode

func (brain *BrainS) Sha1Encode(data []byte) string

* Sha1加密 */

func (*BrainS) ShowObject

func (brain *BrainS) ShowObject(obj interface{})

* 展示对象内容 */

func (*BrainS) SplitBySize

func (brain *BrainS) SplitBySize(plain []byte, size int) [][]byte

* 根据长度切割字节 */

func (*BrainS) String2Unicode

func (brain *BrainS) String2Unicode(unicode string) string

* 文字转Unicode */

func (*BrainS) Struct2File

func (brain *BrainS) Struct2File(FileName string, s interface{}) (int, interface{})

* 持久化结构体存储 -> 直接输入结构体 */

func (*BrainS) Struct2Map

func (brain *BrainS) Struct2Map(structS interface{}) map[string]interface{}

* 结构体转Map */

func (*BrainS) SystemDecrypt

func (brain *BrainS) SystemDecrypt(encryptData []byte) []byte

* 系统默认解密方法 */

func (*BrainS) SystemEncrypt

func (brain *BrainS) SystemEncrypt(decryptData []byte) []byte

* 系统默认加密方法 */

func (*BrainS) SystemExec

func (brain *BrainS) SystemExec(callback func(cmd *exec.Cmd) (int, interface{}), osCommand map[string]string, params ...string) (int, interface{})
  • 执行系统指令 */ example:
var osCommand = map[string]string{
    "windows": "start",
    "darwin":  "open",
    "linux":   "xdg-open",
}

func (*BrainS) SystemKey

func (brain *BrainS) SystemKey() []byte

* 获取系统秘钥 */

func (*BrainS) SystemSalt

func (brain *BrainS) SystemSalt() []byte

* 获取混淆秘钥 */

func (*BrainS) SystemService

func (brain *BrainS) SystemService(stopC chan bool, osCommand map[string]string, params ...string) (int, interface{})

* 启动一个操作系统服务 */

func (*BrainS) SystemSplit

func (brain *BrainS) SystemSplit(str string) []string

* 根据NeuronSplit分割字符串 */

func (*BrainS) TableGetData

func (brain *BrainS) TableGetData(column []string, data interface{}, directArray []interface{}) interface{}

* 获取对应表格行下标内容 */

func (*BrainS) TerminalInput

func (brain *BrainS) TerminalInput(notices ...string) (int, interface{})

* 获取一个Terminal指令 */

func (*BrainS) UUID

func (brain *BrainS) UUID(split ...string) string

* 生成UUID */

func (*BrainS) Unicode2String

func (brain *BrainS) Unicode2String(str string) string

* Unicode转文字 */

func (*BrainS) XMLDecoder

func (brain *BrainS) XMLDecoder(data []byte, dataType interface{}) interface{}

* XML -> String2Object */

func (*BrainS) XMLEncoder

func (brain *BrainS) XMLEncoder(data interface{}, indent ...bool) []byte

* XML -> Object2String */

func (*BrainS) YV12ToRGB24

func (brain *BrainS) YV12ToRGB24(yv12 []byte, width int, height int) (int, interface{})

func (*BrainS) ZlibDecoder

func (brain *BrainS) ZlibDecoder(in []byte) ([]byte, error)

* Zlib Decoder */

func (*BrainS) ZlibEncoder

func (brain *BrainS) ZlibEncoder(in []byte) ([]byte, error)

* Zlib Encoder */

type CommanderS

type CommanderS struct {
	Const struct {
		// contains filtered or unexported fields
	}
	Container   struct{}
	Connection  struct{}
	StopChannel struct {
		CommanderLooperSC chan bool
	}
	// contains filtered or unexported fields
}

* ================================ DEFINE ================================ */

func (*CommanderS) GMessageHandler

func (mCommander *CommanderS) GMessageHandler(clientI interface{}, msgI interface{})

func (*CommanderS) IsStarted

func (mCommander *CommanderS) IsStarted() bool

* 返回开关量 */

func (*CommanderS) Log

func (mCommander *CommanderS) Log(title string, content ...interface{})

* 打印信息 */

func (*CommanderS) Ontology

func (mCommander *CommanderS) Ontology(neuron *NeuronS, mux *http.ServeMux, root string) *CommanderS

* 构造本体 */

func (*CommanderS) StartService

func (mCommander *CommanderS) StartService()

* 启动服务 */

func (*CommanderS) StopService

func (mCommander *CommanderS) StopService()

* 停止服务 */

func (*CommanderS) WSHub

func (mCommander *CommanderS) WSHub() model.SyncMapHub

type DBConfS

type DBConfS struct {
	Host     string
	User     string
	Pass     string
	Database string
}

type ExpressS

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

func (*ExpressS) CodeResponse

func (express *ExpressS) CodeResponse(res http.ResponseWriter, code int, data ...interface{})

* Response -> 通用JSON格式 */

func (*ExpressS) CommanderEval

func (express *ExpressS) CommanderEval(neuronId, service, function string, params ...[]byte) string

* 通过CommanderQueue发送命令 */

behaviorTreeQ -> map[UUID]*BehaviorTreeS

func (*ExpressS) ConstructInterface

func (express *ExpressS) ConstructInterface(res http.ResponseWriter, req *http.Request, isStarted bool, next func(), callbacks ...func(err interface{}))

* REQ&RES -> 构建通用接口 */

func (*ExpressS) ConstructService

func (express *ExpressS) ConstructService(service model.ExpressI, servicePath string, res http.ResponseWriter, req *http.Request)

* Service -> 构建通用服务 */

func (*ExpressS) ErrorResponse

func (express *ExpressS) ErrorResponse(res http.ResponseWriter, code int)

* Response -> 通用错误格式 */

func (*ExpressS) GMessageHandler

func (express *ExpressS) GMessageHandler(clientI interface{}, msgI interface{})

func (*ExpressS) Middleware

func (express *ExpressS) Middleware(res http.ResponseWriter, req *http.Request, next func())

* Request Middleware */

Method:GET
URL:/Commander/Channel
Proto:HTTP/1.1
ProtoMajor:1
ProtoMinor:1
Header:map[Connection:[Upgrade] Origin:[http://127.0.0.1:8800] Sec-Websocket-Key:[MI05HZpoEfjdNsND2/Evug==]
Sec-Websocket-Version:[13]
Upgrade:[websocket]]
Body:{}
GetBody:<nil>
ContentLength:0
TransferEncoding:[]
Close:false
Host:127.0.0.1:8800
Form:map[]
PostForm:map[]
MultipartForm:<nil>
Trailer:map[]
RemoteAddr:127.0.0.1:60800
RequestURI:/Commander/Channel
TLS:<nil>
Cancel:<nil>
Response:<nil>
ctx:0xc00002f4c0

func (*ExpressS) Ontology

func (express *ExpressS) Ontology(neuron *NeuronS) *ExpressS

* 构造本体 */

func (*ExpressS) ReceiverEval

func (express *ExpressS) ReceiverEval(conn *websocket.Conn, msgId, service, function string, params ...[]byte) error

* Receiver返回命令 */

func (*ExpressS) Req2Query

func (express *ExpressS) Req2Query(req *http.Request) url.Values

* 通用Request数据包解析 */

func (*ExpressS) Req2Url

func (express *ExpressS) Req2Url(req *http.Request) string

* 获取Requst中的地址 */

func (*ExpressS) Req2UrlNoQuery

func (express *ExpressS) Req2UrlNoQuery(req *http.Request) string

* 获取Requst中的地址不带参数 */

func (*ExpressS) StaticHandler

func (express *ExpressS) StaticHandler(res http.ResponseWriter, req *http.Request)

* StaticHandler配置 */

func (*ExpressS) TCP2UDPForward

func (express *ExpressS) TCP2UDPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)

* TCP转UDP */

func (*ExpressS) TCPClient

func (express *ExpressS) TCPClient(u string, mTrigger trigger.Trigger, heartIntervals ...int)

* TCP客户端 */

func (*ExpressS) TCPForward

func (express *ExpressS) TCPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)

* TCP端口转发[local] */

func (*ExpressS) TCPServer

func (express *ExpressS) TCPServer(u string, mTrigger trigger.Trigger, stopC chan bool, hub model.SyncMapHub, heartIntervals ...int)

* TCP服务端主程序 */

func (*ExpressS) UART2UDPForward

func (express *ExpressS) UART2UDPForward(localHost string, remoteOption serial.OpenOptions, stopC chan bool, tags ...string)

* UART转UDP */

func (*ExpressS) UARTClient

func (express *ExpressS) UARTClient(option serial.OpenOptions, mTrigger trigger.Trigger)

* 新建串口连接 */

func (*ExpressS) UDP2TCPForward

func (express *ExpressS) UDP2TCPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)

* UDP转TCP */

func (*ExpressS) UDPClient

func (express *ExpressS) UDPClient(u string, mTrigger trigger.Trigger, heartIntervals ...int)

* UDP客户端[*net.UDPConn] */

func (*ExpressS) UDPForward

func (express *ExpressS) UDPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)

* UDP端口转发 */

func (*ExpressS) UDPServer

func (express *ExpressS) UDPServer(u string, mTrigger trigger.Trigger, stopC chan bool, hub model.ConnQHub, heartIntervals ...int)

* UDP服务端主程序 */

func (*ExpressS) Url2HostPath

func (express *ExpressS) Url2HostPath(uStr string) (string, string)

* 分离Url中的Host和Params */

func (*ExpressS) Url2Struct

func (express *ExpressS) Url2Struct(ustr string) *url.URL

* URL对象转化 */

func (*ExpressS) WSBroadcast

func (express *ExpressS) WSBroadcast(callback func(rank int, ip string, neuronId string, conn *websocket.Conn), wsHubs ...model.SyncMapHub)

* Websocket广播 */

func (*ExpressS) WSClient

func (express *ExpressS) WSClient(u string, mTrigger trigger.Trigger, heartIntervals ...int)

* Websocket客户端 */

func (*ExpressS) WSHandler

func (express *ExpressS) WSHandler(ws *websocket.Conn, wsI model.WebsocketI)

* Websocket Handler */

func (*ExpressS) WSHub

func (express *ExpressS) WSHub() model.SyncMapHub

type MysqlS

type MysqlS struct {
	Pool           model.SyncMapHub /* map[Token]*sql.DB */
	DefaultDBToken string
	// contains filtered or unexported fields
}

func (*MysqlS) ExecQuery

func (mMysql *MysqlS) ExecQuery(sqlStr string, callback func(code int, data interface{}), tokens ...string)

* 执行查询 */

func (*MysqlS) ExecTrans

func (mMysql *MysqlS) ExecTrans(sqlArray []string, callback func(code int, data interface{}), tokens ...string)

* 执行事务(可查询) */

*
* @param sql_task => 任务信息[Object]
* example:{
* task_a : 'select count(*) from table_a',
* task_b : 'select count(*) from table_b',
* task_c : 'select count(*) from table_c',
* }
* @param callback => 结果回调[code, result]

func (*MysqlS) GetPool

func (mMysql *MysqlS) GetPool(token string) *sql.DB

* 获取连接池 */

func (*MysqlS) Ontology

func (mMysql *MysqlS) Ontology(neuron *NeuronS) *MysqlS

* 构造本体 */

func (*MysqlS) SetPool

func (mMysql *MysqlS) SetPool(dbConf DBConfS) string

* 新建连接池 */

type NeuronS

type NeuronS struct {
	Brain        *BrainS
	Express      *ExpressS
	Redis        *RedisS
	Mysql        *MysqlS
	BehaviorTree *BehaviorTreeS
}

* ================================ DEFINE ================================ */

func (*NeuronS) Ontology

func (neuron *NeuronS) Ontology() *NeuronS

* 构造本体 */

type ProxyS

type ProxyS struct {
	Const struct {
		// contains filtered or unexported fields
	}
	Container struct {
		// contains filtered or unexported fields
	}
	Connection  struct{}
	StopChannel struct {
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

* ================================ DEFINE ================================ */

func (*ProxyS) IsStarted

func (mProxy *ProxyS) IsStarted() bool

* 返回开关量 */

func (*ProxyS) Log

func (mProxy *ProxyS) Log(title string, content ...interface{})

* 打印信息 */

func (*ProxyS) Ontology

func (mProxy *ProxyS) Ontology(neuron *NeuronS, mux *http.ServeMux, root string) *ProxyS

* 构造本体 */

func (*ProxyS) StartService

func (mProxy *ProxyS) StartService()

* 启动服务 */

func (*ProxyS) StopService

func (mProxy *ProxyS) StopService()

* 停止服务 */

type ReceiverS

type ReceiverS struct {
	Const struct {
		// contains filtered or unexported fields
	}
	Container  struct{}
	Connection struct {
		// contains filtered or unexported fields
	}
	StopChannel struct {
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

* ================================ DEFINE ================================ */

func (*ReceiverS) IsStarted

func (mReceiver *ReceiverS) IsStarted() bool

* 返回开关量 */

func (*ReceiverS) Log

func (mReceiver *ReceiverS) Log(title string, content ...interface{})

* 打印信息 */

func (*ReceiverS) Ontology

func (mReceiver *ReceiverS) Ontology(neuron *NeuronS, mux *http.ServeMux, root string) *ReceiverS

* 构造本体 */

func (*ReceiverS) StartService

func (mReceiver *ReceiverS) StartService()

* 启动服务 */

func (*ReceiverS) StopService

func (mReceiver *ReceiverS) StopService()

* 停止服务 */

type RedisS

type RedisS struct {
	Pool *redis.Pool
	// contains filtered or unexported fields
}

func (*RedisS) Ontology

func (mRedis *RedisS) Ontology(neuron *NeuronS) *RedisS

* 构造本体 */

type SystemS

type SystemS struct {
	Const struct {
		// contains filtered or unexported fields
	}
	Container   struct{}
	Connection  struct{}
	StopChannel struct {
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

* ================================ DEFINE ================================ */

func (*SystemS) ConfigInit

func (mSystem *SystemS) ConfigInit()

* 重新读取配置文件 */

func (*SystemS) DBToken

func (mSystem *SystemS) DBToken()

* 显示数据库默认Token */

func (*SystemS) Decrypt

func (mSystem *SystemS) Decrypt(sha1Key, b64 string)

* 使用系统方法解密 */

func (*SystemS) Encrypt

func (mSystem *SystemS) Encrypt(sha1Key, str string)

* 使用系统方法加密 */

func (*SystemS) Funclist

func (mSystem *SystemS) Funclist()

* 显示所有系统方法 */

func (*SystemS) IsStarted

func (mSystem *SystemS) IsStarted() bool

* 返回开关量 */

func (*SystemS) Log

func (mSystem *SystemS) Log(title string, content ...interface{})

* 打印信息 */

func (*SystemS) Ontology

func (mSystem *SystemS) Ontology(neuron *NeuronS, mux *http.ServeMux, root string) *SystemS

* 构造本体 */

func (*SystemS) Sha1Encode

func (mSystem *SystemS) Sha1Encode(s string)

* Sha1加密 */

func (*SystemS) StartService

func (mSystem *SystemS) StartService()

* 启动服务 */

func (*SystemS) StopService

func (mSystem *SystemS) StopService()

* 停止服务 */

Jump to

Keyboard shortcuts

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