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 ¶
- type BehaviorTreeS
- func (mBehaviorTree *BehaviorTreeS) Branch2Tree(tree *model.BehaviorTreeS, task *model.BehaviorTaskS, ...) *model.BehaviorTreeS
- func (mBehaviorTree *BehaviorTreeS) FetchBranch(hub *model.QueueS, needShift ...bool) (*model.BehaviorTreeS, *model.BehaviorTaskS, *model.BehaviorActionS)
- func (mBehaviorTree *BehaviorTreeS) FindAction(task *model.BehaviorTaskS, tag string) *model.BehaviorActionS
- func (mBehaviorTree *BehaviorTreeS) FindTask(tree *model.BehaviorTreeS, tag string) *model.BehaviorTaskS
- func (mBehaviorTree *BehaviorTreeS) Json2Tree(json []byte) (int, interface{})
- func (mBehaviorTree *BehaviorTreeS) NewAction(tag string, command string, params ...string) *model.BehaviorActionS
- func (mBehaviorTree *BehaviorTreeS) NewForest(tags ...string) model.BehaviorForestS
- func (mBehaviorTree *BehaviorTreeS) NewTask(tag string) *model.BehaviorTaskS
- func (mBehaviorTree *BehaviorTreeS) NewTree(tags ...string) *model.BehaviorTreeS
- func (mBehaviorTree *BehaviorTreeS) Ontology(neuron *NeuronS) *BehaviorTreeS
- func (mBehaviorTree *BehaviorTreeS) Tree2Json(tree *model.BehaviorTreeS) (int, interface{})
- type BrainS
- func (brain *BrainS) After(callback func(), i ...int) *time.Timer
- func (brain *BrainS) AnalyzeMessage(msgs string, splits ...string) []*model.GMessageS
- func (brain *BrainS) ArrayGetId(array []interface{}, data interface{}) int
- func (brain *BrainS) Base64Decoder(data string) []byte
- func (brain *BrainS) Base64Encoder(data []byte) string
- func (brain *BrainS) BetweenPercent(price float64, average float64, percent float64) bool
- func (brain *BrainS) BfDecode(data []byte) []byte
- func (brain *BrainS) BfEncode(data []byte) []byte
- func (brain *BrainS) Bool2Int(b bool) int
- func (brain *BrainS) Bytes2File(FileName string, b []byte) (int, interface{})
- func (brain *BrainS) Bytes2PrivateKey(priv []byte) *rsa.PrivateKey
- func (brain *BrainS) Bytes2PublicKey(pub []byte) *rsa.PublicKey
- func (brain *BrainS) CRC(b []byte) byte
- func (brain *BrainS) CheckIsNull(i interface{}) bool
- func (brain *BrainS) CheckIsType(i interface{}, typ string) bool
- func (brain *BrainS) CheckTimeArrived(datetime string, interval int) bool
- func (brain *BrainS) ClearInterval(stopC chan bool)
- func (brain *BrainS) EmojiUnicodeClear(s string) string
- func (brain *BrainS) EmojiUnicodeDecode(s string) string
- func (brain *BrainS) EmojiUnicodeEncode(s string) string
- func (brain *BrainS) Eval(service interface{}, function string, args ...interface{})
- func (brain *BrainS) File2Bytes(FileName string) (int, interface{})
- func (brain *BrainS) File2Struct(FileName string) (int, interface{})
- func (brain *BrainS) FileAppend(filePath string, data []byte) (int, interface{})
- func (brain *BrainS) FileMove(filePath string, newPath string) (int, interface{})
- func (brain *BrainS) FilePath2AbsPath(dirPath string) string
- func (brain *BrainS) FileReader(filePath string) (int, interface{})
- func (brain *BrainS) FileRemovAll(DirPath string) (int, interface{})
- func (brain *BrainS) FileRemove(filePath string) (int, interface{})
- func (brain *BrainS) FileRename(filePath string, filename string) (int, interface{})
- func (brain *BrainS) FileWriter(filePath string, data []byte) (int, interface{})
- func (brain *BrainS) GenerateMessage(head string, tag string, cmds []interface{}, id ...string) *bytes.Buffer
- func (brain *BrainS) GenerateRSAKey(bitss ...int) *rsa.PrivateKey
- func (brain *BrainS) GetDateTime(datetime string, changeDuration ...time.Duration) *model.TimeS
- func (brain *BrainS) GetFuncName(i interface{}) string
- func (brain *BrainS) GetLanIp(ipRoute ...string) (int, interface{})
- func (brain *BrainS) GoldPoint(price float64) (float64, float64)
- func (brain *BrainS) GzipDecoder(in []byte) ([]byte, error)
- func (brain *BrainS) GzipEncoder(in []byte) ([]byte, error)
- func (brain *BrainS) HEXDecoder(s string) []byte
- func (brain *BrainS) HEXEncoder(b []byte) string
- func (brain *BrainS) HmacSha256Encode(data []byte, key string) string
- func (brain *BrainS) HuffmanDecoder(in []byte) []byte
- func (brain *BrainS) HuffmanEncoder(in []byte, levels ...int) []byte
- func (brain *BrainS) Interface2Bytes(i interface{}) []byte
- func (brain *BrainS) JsonChecker(data []byte) bool
- func (brain *BrainS) JsonDecoder(data []byte, structS ...interface{}) interface{}
- func (brain *BrainS) JsonEncoder(data interface{}, indent ...bool) []byte
- func (brain *BrainS) LogGenerater(logtype int, model string, function string, content interface{})
- func (brain *BrainS) MD5Encode(data []byte) string
- func (brain *BrainS) Map2KeyArray(data map[string]interface{}) []string
- func (brain *BrainS) Map2Struct(m interface{}, structS interface{}) interface{}
- func (brain *BrainS) MessageHandler(tag string, function string, code int, data interface{}) model.MessageS
- func (brain *BrainS) NumPadZero(num int, n int) int
- func (brain *BrainS) ObjectMerge(s ...[]interface{}) (slice []interface{})
- func (brain *BrainS) Ontology() *BrainS
- func (brain *BrainS) PathAbs(dirPath string) string
- func (brain *BrainS) PathAbs2PathBaseExt(dirPath string) (string, string, string)
- func (brain *BrainS) PathCreate(dirPath string) (int, interface{})
- func (brain *BrainS) PathExists(dirPath string) bool
- func (brain *BrainS) PathList(dirPath string) (int, interface{})
- func (brain *BrainS) PrivateKey2Bytes(key *rsa.PrivateKey) []byte
- func (brain *BrainS) PublicKey2Bytes(key *rsa.PublicKey) []byte
- func (brain *BrainS) RSADecrypt(cipher []byte, priv *rsa.PrivateKey) []byte
- func (brain *BrainS) RSADecryptOAEP(cipher []byte, priv *rsa.PrivateKey, salts ...[]byte) []byte
- func (brain *BrainS) RSAEncrypt(plain []byte, pub *rsa.PublicKey) []byte
- func (brain *BrainS) RSAEncryptOAEP(plain []byte, pub *rsa.PublicKey, salts ...[]byte) []byte
- func (brain *BrainS) RSASign(priv *rsa.PrivateKey, plain []byte) []byte
- func (brain *BrainS) RSASignPSS(priv *rsa.PrivateKey, plain []byte) []byte
- func (brain *BrainS) RSAVerify(pub *rsa.PublicKey, plain, signature []byte) bool
- func (brain *BrainS) RSAVerifyPSS(pub *rsa.PublicKey, plain, signature []byte) bool
- func (brain *BrainS) RandomChar(n int) string
- func (brain *BrainS) RandomInt(max int, seeds ...int64) int
- func (brain *BrainS) Request(params model.RequestParamS, callback func(code int, data interface{}), ...)
- func (brain *BrainS) RequestMultipartFile(params model.RequestParamS, filePathHub map[string]string, ...)
- func (brain *BrainS) RequestSync(param model.RequestParamS, proxyUrls ...*url.URL) (int, interface{})
- func (brain *BrainS) RequestSync4Cookies(param model.RequestParamS, proxyUrls ...*url.URL) (int, interface{})
- func (brain *BrainS) Retry(times int, next func() (int, interface{}), ...) (code int, data interface{})
- func (brain *BrainS) SafeFunction(next func(), callback ...func(err interface{}))
- func (brain *BrainS) SelectIterator(hubLen int, lastIndex int) int
- func (brain *BrainS) SetInterval(next func() (int, interface{}), callback func(code int, data interface{}), ...)
- func (brain *BrainS) SetTimeoutInterval(next func() (int, interface{}), callback func(code int, data interface{}), ...)
- func (brain *BrainS) Sha1Encode(data []byte) string
- func (brain *BrainS) ShowObject(obj interface{})
- func (brain *BrainS) SplitBySize(plain []byte, size int) [][]byte
- func (brain *BrainS) String2Unicode(unicode string) string
- func (brain *BrainS) Struct2File(FileName string, s interface{}) (int, interface{})
- func (brain *BrainS) Struct2Map(structS interface{}) map[string]interface{}
- func (brain *BrainS) SystemDecrypt(encryptData []byte) []byte
- func (brain *BrainS) SystemEncrypt(decryptData []byte) []byte
- func (brain *BrainS) SystemExec(callback func(cmd *exec.Cmd) (int, interface{}), osCommand map[string]string, ...) (int, interface{})
- func (brain *BrainS) SystemKey() []byte
- func (brain *BrainS) SystemSalt() []byte
- func (brain *BrainS) SystemService(stopC chan bool, osCommand map[string]string, params ...string) (int, interface{})
- func (brain *BrainS) SystemSplit(str string) []string
- func (brain *BrainS) TableGetData(column []string, data interface{}, directArray []interface{}) interface{}
- func (brain *BrainS) TerminalInput(notices ...string) (int, interface{})
- func (brain *BrainS) UUID(split ...string) string
- func (brain *BrainS) Unicode2String(str string) string
- func (brain *BrainS) XMLDecoder(data []byte, dataType interface{}) interface{}
- func (brain *BrainS) XMLEncoder(data interface{}, indent ...bool) []byte
- func (brain *BrainS) YV12ToRGB24(yv12 []byte, width int, height int) (int, interface{})
- func (brain *BrainS) ZlibDecoder(in []byte) ([]byte, error)
- func (brain *BrainS) ZlibEncoder(in []byte) ([]byte, error)
- type CommanderS
- func (mCommander *CommanderS) GMessageHandler(clientI interface{}, msgI interface{})
- func (mCommander *CommanderS) IsStarted() bool
- func (mCommander *CommanderS) Log(title string, content ...interface{})
- func (mCommander *CommanderS) Ontology(neuron *NeuronS, mux *http.ServeMux, root string) *CommanderS
- func (mCommander *CommanderS) StartService()
- func (mCommander *CommanderS) StopService()
- func (mCommander *CommanderS) WSHub() model.SyncMapHub
- type DBConfS
- type ExpressS
- func (express *ExpressS) CodeResponse(res http.ResponseWriter, code int, data ...interface{})
- func (express *ExpressS) CommanderEval(neuronId, service, function string, params ...[]byte) string
- func (express *ExpressS) ConstructInterface(res http.ResponseWriter, req *http.Request, isStarted bool, next func(), ...)
- func (express *ExpressS) ConstructService(service model.ExpressI, servicePath string, res http.ResponseWriter, ...)
- func (express *ExpressS) ErrorResponse(res http.ResponseWriter, code int)
- func (express *ExpressS) GMessageHandler(clientI interface{}, msgI interface{})
- func (express *ExpressS) Middleware(res http.ResponseWriter, req *http.Request, next func())
- func (express *ExpressS) Ontology(neuron *NeuronS) *ExpressS
- func (express *ExpressS) ReceiverEval(conn *websocket.Conn, msgId, service, function string, params ...[]byte) error
- func (express *ExpressS) Req2Query(req *http.Request) url.Values
- func (express *ExpressS) Req2Url(req *http.Request) string
- func (express *ExpressS) Req2UrlNoQuery(req *http.Request) string
- func (express *ExpressS) StaticHandler(res http.ResponseWriter, req *http.Request)
- func (express *ExpressS) TCP2UDPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)
- func (express *ExpressS) TCPClient(u string, mTrigger trigger.Trigger, heartIntervals ...int)
- func (express *ExpressS) TCPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)
- func (express *ExpressS) TCPServer(u string, mTrigger trigger.Trigger, stopC chan bool, hub model.SyncMapHub, ...)
- func (express *ExpressS) UART2UDPForward(localHost string, remoteOption serial.OpenOptions, stopC chan bool, ...)
- func (express *ExpressS) UARTClient(option serial.OpenOptions, mTrigger trigger.Trigger)
- func (express *ExpressS) UDP2TCPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)
- func (express *ExpressS) UDPClient(u string, mTrigger trigger.Trigger, heartIntervals ...int)
- func (express *ExpressS) UDPForward(localHost string, remoteHost string, stopC chan bool, tags ...string)
- func (express *ExpressS) UDPServer(u string, mTrigger trigger.Trigger, stopC chan bool, hub model.ConnQHub, ...)
- func (express *ExpressS) Url2HostPath(uStr string) (string, string)
- func (express *ExpressS) Url2Struct(ustr string) *url.URL
- func (express *ExpressS) WSBroadcast(callback func(rank int, ip string, neuronId string, conn *websocket.Conn), ...)
- func (express *ExpressS) WSClient(u string, mTrigger trigger.Trigger, heartIntervals ...int)
- func (express *ExpressS) WSHandler(ws *websocket.Conn, wsI model.WebsocketI)
- func (express *ExpressS) WSHub() model.SyncMapHub
- type MysqlS
- func (mMysql *MysqlS) ExecQuery(sqlStr string, callback func(code int, data interface{}), tokens ...string)
- func (mMysql *MysqlS) ExecTrans(sqlArray []string, callback func(code int, data interface{}), tokens ...string)
- func (mMysql *MysqlS) GetPool(token string) *sql.DB
- func (mMysql *MysqlS) Ontology(neuron *NeuronS) *MysqlS
- func (mMysql *MysqlS) SetPool(dbConf DBConfS) string
- type NeuronS
- type ProxyS
- type ReceiverS
- type RedisS
- type SystemS
- func (mSystem *SystemS) ConfigInit()
- func (mSystem *SystemS) DBToken()
- func (mSystem *SystemS) Decrypt(sha1Key, b64 string)
- func (mSystem *SystemS) Encrypt(sha1Key, str string)
- func (mSystem *SystemS) Funclist()
- func (mSystem *SystemS) IsStarted() bool
- func (mSystem *SystemS) Log(title string, content ...interface{})
- func (mSystem *SystemS) Ontology(neuron *NeuronS, mux *http.ServeMux, root string) *SystemS
- func (mSystem *SystemS) Sha1Encode(s string)
- func (mSystem *SystemS) StartService()
- func (mSystem *SystemS) StopService()
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) AnalyzeMessage ¶
* * 解析指令 * param: * msg => 指令体[string] * return: * object => [ * id => 指令编号 * head => 指挥头,判断是指令(?)/消息(!)/对象(~)[string] * tag => 指挥者,判断来自哪个模块[string] * cmd_array => 指令体,获取指令集[array] * ]
func (*BrainS) ArrayGetId ¶
* 获取数组内容下标 */
func (*BrainS) Base64Decoder ¶
func (*BrainS) BetweenPercent ¶
* 判断是否在两个百分数之间 */
func (*BrainS) Bytes2File ¶
* 持久化结构体存储 -> Bytes */
func (*BrainS) Bytes2PrivateKey ¶
func (brain *BrainS) Bytes2PrivateKey(priv []byte) *rsa.PrivateKey
func (*BrainS) CheckIsType ¶
* 判断是否是对应数据类型 */
func (*BrainS) CheckTimeArrived ¶
* 判断现在是否到达特定时间 */ * * param: * timestamp_check => 时间戳[timestamp] * interval => 间隔时间[int] * return: * boolean => [ * true => arrived * flase => not arrived * ]
func (*BrainS) EmojiUnicodeClear ¶
* Emoji表情清除 */
func (*BrainS) EmojiUnicodeDecode ¶
* Emoji表情反序列化 */
func (*BrainS) EmojiUnicodeEncode ¶
* Emoji表情序列化 */
func (*BrainS) File2Bytes ¶
* 持久化结构体读取 -> Bytes */
func (*BrainS) File2Struct ¶
* 持久化结构体读取 -> 输出结构体JSONString[需套用结构解析] */
func (*BrainS) FileAppend ¶
* 文件追加 */
func (*BrainS) FilePath2AbsPath ¶
* 相对路径转绝对路径 */
func (*BrainS) FileReader ¶
* 文件读 */
func (*BrainS) FileRemovAll ¶
* 文件夹删除 */
func (*BrainS) FileRemove ¶
* 文件删除 */
func (*BrainS) FileRename ¶
* 文件重命名 */
func (*BrainS) FileWriter ¶
* 文件写 */
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 ¶
* 获取格式化时间 */ * * 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) GzipDecoder ¶
* Gzip Decoder */
func (*BrainS) GzipEncoder ¶
* Gzip Encoder */
func (*BrainS) HEXDecoder ¶
func (*BrainS) HmacSha256Encode ¶
* Sha256加密 */
func (*BrainS) HuffmanDecoder ¶
* Huffman Decoder */
func (*BrainS) HuffmanEncoder ¶
* Huffman Encoder */
func (*BrainS) Interface2Bytes ¶
* 通用数据类型转[]byte */
func (*BrainS) JsonChecker ¶
* Json -> CheckIsRight */
func (*BrainS) JsonDecoder ¶
* Json -> String2Object */
func (*BrainS) JsonEncoder ¶
* Json -> Object2String */
func (*BrainS) LogGenerater ¶
* 结构化日志记录 */
func (*BrainS) Map2KeyArray ¶
* 获取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) ObjectMerge ¶
func (brain *BrainS) ObjectMerge(s ...[]interface{}) (slice []interface{})
* 合并对象 */
func (*BrainS) PathAbs2PathBaseExt ¶
* 获取绝对路径中的文件路径 */
func (*BrainS) PathCreate ¶
* 创建文件夹 */
func (*BrainS) PrivateKey2Bytes ¶
func (brain *BrainS) PrivateKey2Bytes(key *rsa.PrivateKey) []byte
* PrivateKey流转化 */
func (*BrainS) PublicKey2Bytes ¶
* PublicKey流转化 */
func (*BrainS) RSADecrypt ¶
func (brain *BrainS) RSADecrypt(cipher []byte, priv *rsa.PrivateKey) []byte
* RSA -> 解密 */
func (*BrainS) RSADecryptOAEP ¶
* RSA -> OAEP解密 */
func (*BrainS) RSAEncrypt ¶
* RSA -> 加密 */
func (*BrainS) RSAEncryptOAEP ¶
* 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) RSAVerifyPSS ¶
* RSA -> PSS验证 */
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 (*BrainS) SetInterval ¶
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) SplitBySize ¶
* 根据长度切割字节 */
func (*BrainS) String2Unicode ¶
* 文字转Unicode */
func (*BrainS) Struct2File ¶
* 持久化结构体存储 -> 直接输入结构体 */
func (*BrainS) Struct2Map ¶
* 结构体转Map */
func (*BrainS) SystemDecrypt ¶
* 系统默认解密方法 */
func (*BrainS) SystemEncrypt ¶
* 系统默认加密方法 */
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) SystemService ¶
func (brain *BrainS) SystemService(stopC chan bool, osCommand map[string]string, params ...string) (int, interface{})
* 启动一个操作系统服务 */
func (*BrainS) SystemSplit ¶
* 根据NeuronSplit分割字符串 */
func (*BrainS) TableGetData ¶
func (brain *BrainS) TableGetData(column []string, data interface{}, directArray []interface{}) interface{}
* 获取对应表格行下标内容 */
func (*BrainS) TerminalInput ¶
* 获取一个Terminal指令 */
func (*BrainS) Unicode2String ¶
* Unicode转文字 */
func (*BrainS) XMLDecoder ¶
* XML -> String2Object */
func (*BrainS) XMLEncoder ¶
* XML -> Object2String */
func (*BrainS) YV12ToRGB24 ¶
func (*BrainS) ZlibDecoder ¶
* Zlib Decoder */
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) 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) WSHub ¶
func (mCommander *CommanderS) WSHub() model.SyncMapHub
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) 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) ReceiverEval ¶
func (express *ExpressS) ReceiverEval(conn *websocket.Conn, msgId, service, function string, params ...[]byte) error
* Receiver返回命令 */
func (*ExpressS) Req2UrlNoQuery ¶
* 获取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) 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) 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 ¶
* 分离Url中的Host和Params */
func (*ExpressS) Url2Struct ¶
* 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) 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]
type NeuronS ¶
type NeuronS struct { Brain *BrainS Express *ExpressS Redis *RedisS Mysql *MysqlS BehaviorTree *BehaviorTreeS }
* ================================ DEFINE ================================ */
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 ================================ */
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 ================================ */
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 ================================ */