[关闭]
@chendbdb 2018-03-19T10:48:15.000000Z 字数 10972 阅读 9004

XXTouch中控 手册

XXTouch中控 XXTouch



请访问XXT 局域网中控进行获取最新版本以及更新的提示

中控环境

中控使用注意

疑难杂症的解答

Q:脚本启动后提示“中控访问超时”?
A:设备端无法连接中控锁监听的端口引起的问题。
R:确保使用中控启动且加入通讯API,且检查电脑端防火墙是否关闭。


Q:中控出现错误提示“基础链接已关闭,无法链接到远程服务器”?
A:一些用户在安装一些软件或是系统做某些修改后,采集器就没无登录或是无法获取到网页。
R:在开始键入 cmd,右键单击“cmd.exe”,单击“以管理员身份运行”,然后按“继续”。
在命令提示符处键入 netsh winsock reset,然后按 Enter。


Q:为什么有些电脑无法启动中控?
A:因为中控的开发使用 .NET 基础库,所以需使用中控也要同样的运行库。
R:请下载 .NET 4.0 版本,此处是下载地址


Q:点击“搜索设备”特别卡?
A:网络环境搭建有问题。
R:可以考虑点击“搜索设备”旁的小三角“网段扫描”,点选“IP段列表”内对应IP,之后点击“TCP扫描”等待设备刷新出来进行解决。
PS:避免每次启动中控都需要扫描,当扫描妥当后,可勾选所有设备,点击“中控功能”内“导出勾选IP地址”项,下次重启中控后使用虑点击“搜索设备”旁的小三角“IP地址扫描”针对性添加设备。


Q:扫描设备扫描不全?
A:当设备没有点亮屏幕时,设备很有可能 Wifi 处于休眠状态。
R:请确保设备点亮屏幕。


Q:打开中控出现“配置系统未能初始化”错误提示框?
A:程序相对的配置文件“user.config”损坏引发的问题。
R:删除“C:\Users[用户名]\AppData\Local\XXTouch团队”或“C:\Documents and Settings[用户名]\Local Settings\Application Data\XXTouch团队”解决。


中控结构

在无数据库的情况下会提示创建数据库与配置文件

目录或文件 类型 用途
1ferver 目录 项目目录用于与设备端“1ferver”目录进行同步
data 目录 存放与设备进行交互的文件
CC.mdb 文件 数据库操作API进行访问对应数据库文件
config.ini 文件 缓存中控相关配置文件

1ferver目录 详解

  • 结构例子会在以后中控中内置
  • 针对目录的同步进行适配的文件夹.
  • 脚本选择位置针对 "根目录" 相对的 "\1ferver\lua\scripts\" 文件夹下的脚本文件进行遍历,结构以 "项目名\main.xxt""项目名\main.lua" , 方可在中控端地址栏中进行点击 "地址栏" 中小三角进行选择为 "项目:项目名" 的脚本文件,启动统一按照 "main.xxt""main.lua" 为准.
  • 可使用 "发送脚本" 旁小三角内菜单内 "同步目录" 按钮进行触发单向同步目录操作.
  • 当选择 "根目录" 相对的 "\1ferver\lua\scripts\" 文件夹下项目脚本时(以"项目:"为开头的选择脚本的结构), "发送脚本" 按钮即改为 "同步文件" 此时点击也可以触发单向同步目录操作.
  • 当点击发送脚本旁小三角内的同步目录后,此目录会和设备端的 "/1ferver" 目录进行同步,同步以中控端的结构为准.
  • 同步规则如下:
设备端文件 中控端文件 同步规则
存在 存在 检测 "文件修改时间" 决定是否同步
存在 不存在 不同步且不删除
不存在 存在 同步

CC.mdb文件 详解

  • 数据库是Access 数据库(如无操作过数据库经验不推荐折腾).
  • 表结构需要以第一项"ID"为递增值,其他项为字符串(长度限制255).
  • 以下是操作数据库的相关介绍.

config.ini文件 详解

  • 根据自己需要进行调整.
  • 新版中控默认会隐藏数据表("[Hide] Db_Tab=true").
  1. [Hide]
  2. Db_Tab=true
  3. ;用于隐藏数据表
  4. API_Tab=false
  5. ;用于隐藏API
  6. MadeUI_Tab=false
  7. ;用于隐藏UI制作
  8. UI=false
  9. ;用于隐藏UI功能

API文档解释

命令 解释 返回 示例
CC.log(data) 中控日志
  1. CC.log('日志列展示内容')
  2. CC.log(
  3. {
  4. ['列标题'] = '对应内容'
  5. }
  6. )
CC.web_file.update_file(CCfile, localfile) 上传文件
  1. CC.web_file.update_file('timg.jpg','/User/Media/1ferver/res/timg.jpg')
CC.web_file.down_file(CCfile, localfile) 下载文件
  1. CC.web_file.down_file('timg.jpg','/User/Media/1ferver/res/timg.jpg')
data = CC.web_file.take_line(CCfile) 获取中控端文件第一行数据并删除 获取的第一行数据
  1. CC.web_file.take_line('1.txt')
info = CC.web_file.exists(CCfile) 用于判断一个路径是文件还是目录还是不存在 "file" 或 "directory" 或 nil
  1. info = CC.web_file.exists('1.txt')
success = CC.web_file.delete(CCfile) 删除中控端文件 布尔型
成功:true
失败:false
  1. success = CC.web_file.delete('1.txt')
list = CC.web_file.list(CCpath) 获取中控端目录所有文件名列表 顺序表型 | nil
成功:目录文件列表
失败:nil
  1. list = CC.web_file.list('文件夹1')
fsize = CC.web_file.size(CCfile) 获得中控端一个文件的尺寸 整数型 | nil
成功:文件尺寸(单位: 字节)
失败:nil
  1. fsize = CC.web_file.size('1.txt')
data = CC.web_file.reads(CCfile) 获得中控端一个文件中所有数据 字符串型 | nil
成功:文件的数据
失败:nil
  1. data = CC.web_file.reads('1.txt')
success = CC.web_file.writes(CCfile, data) 将数据覆盖写入到中控端文件 布尔型
成功:true
失败:false
  1. success = CC.web_file.writes('1.txt', '测试写入')
success = CC.web_file.appends(CCfile, data) 将数据追加写入到中控端文件 布尔型
成功:true
失败:false
  1. success = CC.web_file.appends('1.txt', '测试写入')
linecount = CC.web_file.line_count(CCfile) 统计一个文本文件的总行数 整数型 | nil
成功:文件总行数
失败:nil
  1. linecount = CC.web_file.line_count('1.txt')
line = CC.web_file.get_line(CCfile, line_number) 获取一个文本文件指定行的数据 字符串型 | nil
成功:内容
失败:nil
  1. line = CC.web_file.get_line('1.txt', 2)
success = CC.web_file.set_line(CCfile, line_number, data) 设置文本文件指定行的内容 布尔型
成功:true
失败:false
  1. success = CC.web_file.set_line('1.txt', 2, '123123')
success = CC.web_file.insert_line(CCfile, line_number, data) 在文本文件指定行前插入内容 布尔型
成功:true
失败:false
  1. success = CC.web_file.insert_line('1.txt', 2, '123123')
success = CC.web_file.remove_line(CCfile, line_number) 移除文件中指定行 布尔型
成功:true
失败:false
  1. success = CC.web_file.get_lines('1.txt', 2)
lines = CC.web_file.get_lines(CCfile) 获取一个文本文件的所有行 顺序表型 | nil
返回一个顺序表,文件不存在返回 nil
  1. lines = CC.web_file.get_lines('1.txt')
success = CC.web_file.appends(CCfile, line_number, lines) 将一个顺序表转换逐行插入到文件指定行前 布尔型
成功:true
失败:false
  1. success = CC.web_file.appends('1.txt', 2, {'被插入的内容'})
info = CC.web_directory.exists(CCdirectory) 判断文件夹是否存在 布尔型
成功:true
失败:false
  1. info = CC.web_directory.exists("文件夹1")
success = CC.web_directory.create(CCdirectory) 在中控端创建一个文件夹 布尔型
成功:true
失败:false
  1. success = CC.web_directory.create("文件夹1")
success = CC.web_directory.delete(CCdirectory) 在中控端删除一个文件夹 布尔型
成功:true
失败:false
  1. success = CC.web_directory.delete("文件夹1")
CC.getui() 获取当前中控UI的配置信息 string
  1. local data = CC.getui()
  2. local config = json.decode(data)
CC.db.add(table_name, {table_data}) 添加数据库数据 table
  1. v = CC.db.add(
  2. '账号表',
  3. {
  4. {
  5. ['账号']='新添加项目aaaaa',
  6. ['密码']='test',
  7. ['区']='test233'
  8. }
  9. }
  10. )
  11. nLog(json.encode(v))
  12. if v[1].state then
  13. --添加成功
  14. end
CC.db.del(table_name, {table_data}) 删除数据库数据 table
  1. v = CC.db.del(
  2. '账号表',
  3. {
  4. {
  5. ['id'] = 6 --删除id6的项
  6. }
  7. }
  8. )
  9. nLog(json.encode(v))
  10. if v[1].state then
  11. --删除成功
  12. end
CC.db.edit(table_name, {table_data}) 修改数据库内项 table
  1. v = CC.db.edit(
  2. '账号表',
  3. {
  4. { --修改 id8项的 密码 xxxxxxxxxx
  5. ['id'] = 8,
  6. ['密码'] = 'xxxxxxxxxx'
  7. }
  8. }
  9. )
  10. nLog(json.encode(v))
  11. if v[1] then
  12. --账号内容 v[1]
  13. end
CC.db.list(table_name, {select_table}) 获取当前中控UI的配置信息 table
  1. v = CC.db.list(
  2. '账号表',
  3. {
  4. {
  5. ['账号'] = '新添加项目'
  6. }
  7. }
  8. )
  9. sys.alert(json.encode(v))
CC.db.get(table_name, {select_table}) 获取数据库数据(一项) table
  1. v = CC.db.get(
  2. '账号表',
  3. {
  4. { --以此要求索引
  5. ['密码']='test'
  6. },
  7. { --索引完毕后及时改掉
  8. ['密码']='test1'
  9. }
  10. }
  11. )
  12. --获取 密码为 test 的一项 把密码 改为 test1
  13. --CC.db.get(db,{{过滤要求},{获取后修改为}})
  14. nLog(json.encode(v))
  15. if v[1] then
  16. --账号内容 v[1]
  17. end

中控通讯API基础库

  1. local CC = {}
  2. do
  3. server_ip = ''
  4. server_port = 0
  5. log_list = {}
  6. local post = function(_mode, mode, data)
  7. while true do
  8. local code, header, body = http.post(
  9. string.format(
  10. 'http://%s:%s/%s/%s',
  11. server_ip, server_port, _mode, mode
  12. ),30,{},((type(data) == 'table' and json.encode(data)) or data)
  13. )
  14. if code == 200 then
  15. return ((type(json.decode(body) == 'table') and json.decode(body)) or body)
  16. elseif code ~= -1 then
  17. sys.toast('中控异常提示:' .. body)
  18. else
  19. sys.toast('中控访问超时')
  20. end
  21. end
  22. end
  23. local encodeURI = function(s)
  24. return string.gsub(string.gsub(s, '([^%w%.%- ])', function(c) return string.format('%%%02X', string.byte(c)) end), ' ', '+')
  25. end
  26. local send_cc = function(db,m,t)
  27. local r = post('db', m, json.encode({db=db, data=t}))
  28. if r.state == 0 then return r.data;else sys.alert(r.message,5);return r.data;end
  29. end
  30. CC.set_server_ip = function(...)
  31. local ip_list = {}
  32. if type(select(1,...)) == 'table' then
  33. ip_list = select(1, ...)
  34. elseif type(select(1,...)) == 'string' then
  35. ip_list = {select(1, ...)}
  36. else
  37. error('提交的服务器IP不正确',2)
  38. end
  39. server_port = select(2, ...) or 27010
  40. local socket = require('socket')
  41. local s = socket.tcp()
  42. s:settimeout(2)
  43. for k,v in ipairs(ip_list) do
  44. local s = socket.tcp()
  45. s:settimeout(2)
  46. if s:connect(string.format('%s',v), server_port) == 1 then
  47. server_ip = v
  48. end
  49. end
  50. if server_ip == '' then
  51. error('尝试提交的列表中未找到可连接的中控服务',2)
  52. end
  53. end
  54. CC.set_sever_ip = CC.set_server_ip
  55. CC.log = function(t)
  56. if type(t) == 'string' then
  57. log_list['日志'] = t
  58. elseif type(t) == 'table' then
  59. for key, value in pairs(t) do
  60. log_list[key] = value
  61. end
  62. end
  63. http.post(
  64. string.format(
  65. 'http://%s:%s/log',
  66. server_ip,
  67. server_port
  68. ),
  69. 5,
  70. {},
  71. json.encode(log_list)
  72. )
  73. end
  74. CC.getui = function()
  75. while true do
  76. local r = {http.get(string.format('http://%s:%s/getui', server_ip, server_port))}
  77. if r[1] == 200 then return json.decode(r[3]) end
  78. sys.sleep(2)
  79. sys.toast('中控访问超时')
  80. end
  81. end
  82. CC.db = {
  83. add = (function(db,t)
  84. return send_cc(db,'add',t)
  85. end),
  86. del = (function(db,t)
  87. return send_cc(db,'del',t)
  88. end),
  89. edit = (function(db,t)
  90. return send_cc(db,'edit',t)
  91. end),
  92. get = (function(db,t)
  93. return send_cc(db,'get',t)
  94. end),
  95. list = (function(db,t)
  96. return send_cc(db,'list',t or {})
  97. end)
  98. }
  99. CC.web_file = {
  100. take_line = (function(path)
  101. return post('file','take_line',{path=path}).data
  102. end),
  103. exists = function(path)
  104. local r = post('file','exists',{path=path})
  105. if type(r.info) == 'userdata' then
  106. return false
  107. else
  108. return r.info
  109. end
  110. end,
  111. list = (function(path)
  112. return post('file','list',{path=path}).list
  113. end),
  114. size = (function(path)
  115. return post('file','size',{path=path}).fsize
  116. end),
  117. delete = (function(path)
  118. return post('file','delete',{path=path}).success
  119. end),
  120. reads = (function(path)
  121. local r = post('file','reads',{path=path})
  122. if r.success then
  123. return r.data:base64_decode()
  124. else
  125. return nil
  126. end
  127. end),
  128. writes = (function(path,data)
  129. return post('file','writes',{path=path,data=data:base64_encode()}).success
  130. end),
  131. appends = (function(path,data)
  132. return post('file','appends',{path=path,data=data:base64_encode()}).success
  133. end),
  134. line_count = (function(path)
  135. return post('file','line_count',{path=path}).linecount
  136. end),
  137. get_line = (function(path,line_number)
  138. return post('file','get_line',{path=path,line_number=line_number}).line
  139. end),
  140. set_line = (function(path,line_number,data)
  141. return post('file','set_line',{path=path,line_number=line_number,data=data}).success
  142. end),
  143. insert_line = (function(path,line_number,data)
  144. return post('file','insert_line',{path=path,line_number=line_number,data=data}).success
  145. end),
  146. remove_line = (function(path,line_number)
  147. return post('file','remove_line',{path=path,line_number=line_number}).success
  148. end),
  149. get_lines = (function(path)
  150. return post('file','get_lines',{path=path}).lines
  151. end),
  152. insert_lines = (function(path,line_number,lines)
  153. return post('file','insert_lines',{path=path,line_number=line_number,lines=lines}).success
  154. end),
  155. update_file = (function(file,path)
  156. local f, err = io.open(path,'rb')
  157. if not f then error(err,2) end
  158. local s = f:read('*a')
  159. f:close()
  160. return post('file-byte','update?file=' .. encodeURI(file), s) == 'ok'
  161. end),
  162. down_file = (function(file,path)
  163. local code, header, body
  164. while true do
  165. code, header, body = http.get('http://' .. server_ip .. ':' .. server_port .. '/file-byte/down?file=' .. encodeURI(file),30,{})
  166. if code == 200 or code == 404 then break end
  167. end
  168. if code == 404 then
  169. error('文件不存在',2)
  170. else
  171. local f = io.open(path,'wb')
  172. f:write(body)
  173. f:close()
  174. return true
  175. end
  176. end),
  177. }
  178. CC.web_directory = {
  179. exicts = function(path)
  180. local r = post('directory','exicts',{path=path})
  181. if type(r.info) == 'userdata' then
  182. return false
  183. else
  184. return r.info
  185. end
  186. end,
  187. exists = function(path)
  188. local r = post('directory','exists',{path=path})
  189. if type(r.info) == 'userdata' then
  190. return false
  191. else
  192. return r.info
  193. end
  194. end,
  195. create = (function(path)
  196. return post('directory','create',{path=path}).success
  197. end),
  198. delete = (function(path,data)
  199. return post('directory','delete',{path=path}).success
  200. end),
  201. }
  202. end
  203. return CC

示例与实例

发现设备

  • 让设备闪光灯以及屏幕进行闪烁,并发出声音。
  • 此功能主要用于在大批设备中进行定位设备的位置。
  1. now_screen_level=device.brightness();____lalala____={}setmetatable(____lalala____,{__gc=function()webview.destroy();device.set_brightness(now_screen_level);end});device.unlock_screen();device.set_brightness(1);device.set_volume(1);for i=0,25 do;if i%2==0 then;device.vibrator();webview.show{};device.flash_on();else;webview.hide();device.flash_off();end;if i%15==0 then;device.play_sound('/System/Library/Audio/UISounds/sms-received3.caf');end;sys.msleep(200);end

数据库的简单展示

  • 设备写入数据库、获取数据库数据、删除数据库数据。
  1. local CC = require('CC')
  2. do
  3. local args = ((proc_take('spawn_args') ~= "") and proc_take('spawn_args')) or proc_take('CC_args')
  4. proc_put('spawn_args', args);proc_put('CC_args', args)
  5. local _, args_json = pcall(json.decode, args)
  6. if _ and type(args_json) == 'table' then
  7. CC.set_server_ip(
  8. args_json['server_ip'],
  9. args_json['server_port']
  10. )
  11. else
  12. error('请检测启动参数')
  13. end
  14. end
  15. CC.log({['脚本'] = "数据库访问"})
  16. CC.log('开始操作')
  17. -- 添加10条数据
  18. for i = 1, 10 do
  19. local v = CC.db.add(
  20. '账号表',
  21. {
  22. {['账号'] = '测试用的内容 ' .. i .. ' ' .. device.name(), ['密码'] = '假装有内容' .. i, ['区'] = '实际没卵用'}
  23. }
  24. )
  25. if v[1].state then
  26. CC.log({['添加账号'] = '测试用的内容 ' .. i .. ' ' .. device.name()})
  27. else
  28. CC.log('数据库添加失败')
  29. end
  30. sys.sleep(1)
  31. end
  32. CC.log({['添加账号'] = ''})
  33. while true do
  34. local v = CC.db.get('账号表', {{['区'] = '实际没卵用'}, {['区'] = '万一有点用呢'}})
  35. if #v == 0 then
  36. break
  37. else
  38. CC.log({['得到账号'] = v[1]['账号']})
  39. end
  40. sys.sleep(1)
  41. end
  42. CC.log('结束操作')
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注