Merge branch 'master' of https://gitee.com/bnu_mixly/mixly3
This commit is contained in:
@@ -52,7 +52,15 @@
|
|||||||
"yMin": 0,
|
"yMin": 0,
|
||||||
"pointNum": 100,
|
"pointNum": 100,
|
||||||
"rts": false,
|
"rts": false,
|
||||||
"dtr": true
|
"dtr": true,
|
||||||
|
"micropython:esp32:mixgo": {
|
||||||
|
"rts": true,
|
||||||
|
"dtr": true
|
||||||
|
},
|
||||||
|
"micropython:esp32:mpython": {
|
||||||
|
"rts": true,
|
||||||
|
"dtr": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"lib": {
|
"lib": {
|
||||||
"mixly": {
|
"mixly": {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import json
|
|||||||
|
|
||||||
|
|
||||||
class Ollama():
|
class Ollama():
|
||||||
def __init__(self, url="", model=""):
|
def __init__(self, url="", model="", max_history_num=0):
|
||||||
self._heads = {
|
self._heads = {
|
||||||
"Accept": "text/event-stream",
|
"Accept": "text/event-stream",
|
||||||
# "Cache-Control": "no-cache",
|
# "Cache-Control": "no-cache",
|
||||||
@@ -13,7 +13,7 @@ class Ollama():
|
|||||||
}
|
}
|
||||||
self._url = url
|
self._url = url
|
||||||
self._max_retries = 1
|
self._max_retries = 1
|
||||||
self._max_history_num = 0
|
self._max_history_num = max_history_num
|
||||||
self._timeout = 10000
|
self._timeout = 10000
|
||||||
self._messages = []
|
self._messages = []
|
||||||
self._data = {
|
self._data = {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -52,7 +52,15 @@
|
|||||||
"yMin": 0,
|
"yMin": 0,
|
||||||
"pointNum": 100,
|
"pointNum": 100,
|
||||||
"rts": false,
|
"rts": false,
|
||||||
"dtr": true
|
"dtr": true,
|
||||||
|
"micropython:esp32:mixgo": {
|
||||||
|
"rts": true,
|
||||||
|
"dtr": true
|
||||||
|
},
|
||||||
|
"micropython:esp32:mpython": {
|
||||||
|
"rts": true,
|
||||||
|
"dtr": true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"lib": {
|
"lib": {
|
||||||
"mixly": {
|
"mixly": {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -458,13 +458,11 @@ class StatusBarSerial extends PageBase {
|
|||||||
|
|
||||||
async open() {
|
async open() {
|
||||||
await this.#serial_.open(this.#config_.baud);
|
await this.#serial_.open(this.#config_.baud);
|
||||||
if (goog.isElectron || Env.hasSocketServer) {
|
await this.#serial_.sleep(200);
|
||||||
await this.#serial_.sleep(200);
|
try {
|
||||||
try {
|
await this.#serial_.setDTRAndRTS(this.#config_.dtr, this.#config_.rts);
|
||||||
await this.#serial_.setDTRAndRTS(this.#config_.dtr, this.#config_.rts);
|
} catch (error) {
|
||||||
} catch (error) {
|
Debug.error(error);
|
||||||
Debug.error(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (SELECTED_BOARD?.serial?.ctrlCBtn) {
|
if (SELECTED_BOARD?.serial?.ctrlCBtn) {
|
||||||
await this.#serial_.sleep(500);
|
await this.#serial_.sleep(500);
|
||||||
|
|||||||
@@ -1236,6 +1236,7 @@
|
|||||||
"Mustache",
|
"Mustache",
|
||||||
"Mixly.Ampy",
|
"Mixly.Ampy",
|
||||||
"Mixly.Env",
|
"Mixly.Env",
|
||||||
|
"Mixly.Msg",
|
||||||
"Mixly.Serial",
|
"Mixly.Serial",
|
||||||
"Mixly.Electron"
|
"Mixly.Electron"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ goog.require('path');
|
|||||||
goog.require('Mustache');
|
goog.require('Mustache');
|
||||||
goog.require('Mixly.Ampy');
|
goog.require('Mixly.Ampy');
|
||||||
goog.require('Mixly.Env');
|
goog.require('Mixly.Env');
|
||||||
|
goog.require('Mixly.Msg');
|
||||||
goog.require('Mixly.Serial');
|
goog.require('Mixly.Serial');
|
||||||
goog.require('Mixly.Electron');
|
goog.require('Mixly.Electron');
|
||||||
goog.provide('Mixly.Electron.Ampy');
|
goog.provide('Mixly.Electron.Ampy');
|
||||||
@@ -11,6 +12,7 @@ goog.provide('Mixly.Electron.Ampy');
|
|||||||
const {
|
const {
|
||||||
Ampy,
|
Ampy,
|
||||||
Env,
|
Env,
|
||||||
|
Msg,
|
||||||
Serial,
|
Serial,
|
||||||
Electron
|
Electron
|
||||||
} = Mixly;
|
} = Mixly;
|
||||||
@@ -102,7 +104,7 @@ class AmpyExt extends Ampy {
|
|||||||
async exec(port, command) {
|
async exec(port, command) {
|
||||||
const portsName = Serial.getCurrentPortsName();
|
const portsName = Serial.getCurrentPortsName();
|
||||||
if (!portsName.includes(port)) {
|
if (!portsName.includes(port)) {
|
||||||
throw new Error('无可用串口');
|
throw new Error(Msg.Lang['statusbar.serial.noPort']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { mainStatusBarTabs } = Mixly;
|
const { mainStatusBarTabs } = Mixly;
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ class AmpyExt extends Ampy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nowTime - startTime >= timeout) {
|
if (nowTime - startTime >= timeout) {
|
||||||
throw new Error(ending + '查找失败');
|
return '';
|
||||||
}
|
}
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('数据读取中断');
|
throw new Error(Msg.Lang['ampy.dataReadInterrupt']);
|
||||||
}
|
}
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async get(filename, timeout = 5000) {
|
async get(filename, timeout = 5000) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
const code = Mustache.render(AmpyExt.GET, {
|
const code = Mustache.render(AmpyExt.GET, {
|
||||||
path: filename
|
path: filename
|
||||||
@@ -205,7 +205,7 @@ class AmpyExt extends Ampy {
|
|||||||
await this.exec(code);
|
await this.exec(code);
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
if (!await this.readUntil('ok', true, timeout)) {
|
if (!await this.readUntil('ok', true, timeout)) {
|
||||||
throw new Error('无法执行python代码');
|
throw new Error(Msg.Lang['ampy.executePythonCodeFailed']);
|
||||||
}
|
}
|
||||||
let str = await this.readUntil('>', false, timeout);
|
let str = await this.readUntil('>', false, timeout);
|
||||||
str = str.replace('\x04\x04', '');
|
str = str.replace('\x04\x04', '');
|
||||||
@@ -218,7 +218,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async put(filename, code) {
|
async put(filename, code) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
let str = `file = open('${filename}', 'wb')\n`;
|
let str = `file = open('${filename}', 'wb')\n`;
|
||||||
const buffer = this.#device_.encode(code);
|
const buffer = this.#device_.encode(code);
|
||||||
@@ -241,7 +241,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async ls(directory = '/', longFormat = true, recursive = false, timeout = 5000) {
|
async ls(directory = '/', longFormat = true, recursive = false, timeout = 5000) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
let code = '';
|
let code = '';
|
||||||
if (longFormat) {
|
if (longFormat) {
|
||||||
@@ -260,7 +260,7 @@ class AmpyExt extends Ampy {
|
|||||||
await this.exec(code);
|
await this.exec(code);
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
if (!await this.readUntil('ok', true, timeout)) {
|
if (!await this.readUntil('ok', true, timeout)) {
|
||||||
throw new Error('无法执行python代码');
|
throw new Error(Msg.Lang['ampy.executePythonCodeFailed']);
|
||||||
}
|
}
|
||||||
let str = await this.readUntil('>', false, timeout);
|
let str = await this.readUntil('>', false, timeout);
|
||||||
let info = null;
|
let info = null;
|
||||||
@@ -273,7 +273,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async mkdir(directory, timeout = 5000) {
|
async mkdir(directory, timeout = 5000) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
const code = Mustache.render(AmpyExt.MKDIR, {
|
const code = Mustache.render(AmpyExt.MKDIR, {
|
||||||
path: directory
|
path: directory
|
||||||
@@ -281,7 +281,7 @@ class AmpyExt extends Ampy {
|
|||||||
await this.exec(code);
|
await this.exec(code);
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
if (!await this.readUntil('ok', true, timeout)) {
|
if (!await this.readUntil('ok', true, timeout)) {
|
||||||
throw new Error('无法执行python代码');
|
throw new Error(Msg.Lang['ampy.executePythonCodeFailed']);
|
||||||
}
|
}
|
||||||
let str = await this.readUntil('>', false, timeout);
|
let str = await this.readUntil('>', false, timeout);
|
||||||
if (str.indexOf('OSError') === -1) {
|
if (str.indexOf('OSError') === -1) {
|
||||||
@@ -292,7 +292,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async mkfile(file, timeout = 5000) {
|
async mkfile(file, timeout = 5000) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
const code = Mustache.render(AmpyExt.MKFILE, {
|
const code = Mustache.render(AmpyExt.MKFILE, {
|
||||||
path: file
|
path: file
|
||||||
@@ -300,7 +300,7 @@ class AmpyExt extends Ampy {
|
|||||||
await this.exec(code);
|
await this.exec(code);
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
if (!await this.readUntil('ok', true, timeout)) {
|
if (!await this.readUntil('ok', true, timeout)) {
|
||||||
throw new Error('无法执行python代码');
|
throw new Error(Msg.Lang['ampy.executePythonCodeFailed']);
|
||||||
}
|
}
|
||||||
let str = await this.readUntil('>', false, timeout);
|
let str = await this.readUntil('>', false, timeout);
|
||||||
if (str.indexOf('OSError') === -1) {
|
if (str.indexOf('OSError') === -1) {
|
||||||
@@ -311,7 +311,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async rename(oldname, newname, timeout = 5000) {
|
async rename(oldname, newname, timeout = 5000) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
const code = Mustache.render(AmpyExt.RENAME, {
|
const code = Mustache.render(AmpyExt.RENAME, {
|
||||||
oldPath: oldname,
|
oldPath: oldname,
|
||||||
@@ -320,7 +320,7 @@ class AmpyExt extends Ampy {
|
|||||||
await this.exec(code);
|
await this.exec(code);
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
if (!await this.readUntil('ok', true, timeout)) {
|
if (!await this.readUntil('ok', true, timeout)) {
|
||||||
throw new Error('无法执行python代码');
|
throw new Error(Msg.Lang['ampy.executePythonCodeFailed']);
|
||||||
}
|
}
|
||||||
let str = await this.readUntil('>', false, timeout);
|
let str = await this.readUntil('>', false, timeout);
|
||||||
if (str.indexOf('OSError') === -1) {
|
if (str.indexOf('OSError') === -1) {
|
||||||
@@ -331,7 +331,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async rm(filename, timeout = 5000) {
|
async rm(filename, timeout = 5000) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
const code = Mustache.render(AmpyExt.RM, {
|
const code = Mustache.render(AmpyExt.RM, {
|
||||||
path: filename
|
path: filename
|
||||||
@@ -339,7 +339,7 @@ class AmpyExt extends Ampy {
|
|||||||
await this.exec(code);
|
await this.exec(code);
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
if (!await this.readUntil('ok', true, timeout)) {
|
if (!await this.readUntil('ok', true, timeout)) {
|
||||||
throw new Error('无法执行python代码');
|
throw new Error(Msg.Lang['ampy.executePythonCodeFailed']);
|
||||||
}
|
}
|
||||||
let str = await this.readUntil('>', false, timeout);
|
let str = await this.readUntil('>', false, timeout);
|
||||||
if (str.indexOf('OSError') === -1) {
|
if (str.indexOf('OSError') === -1) {
|
||||||
@@ -350,7 +350,7 @@ class AmpyExt extends Ampy {
|
|||||||
|
|
||||||
async rmdir(directory, timeout = 5000) {
|
async rmdir(directory, timeout = 5000) {
|
||||||
if (!this.isActive()) {
|
if (!this.isActive()) {
|
||||||
throw new Error('串口未打开');
|
throw new Error(Msg.Lang['ampy.portIsNotOpen']);
|
||||||
}
|
}
|
||||||
const code = Mustache.render(AmpyExt.RMDIR, {
|
const code = Mustache.render(AmpyExt.RMDIR, {
|
||||||
path: directory
|
path: directory
|
||||||
@@ -358,7 +358,7 @@ class AmpyExt extends Ampy {
|
|||||||
await this.exec(code);
|
await this.exec(code);
|
||||||
await this.#device_.sleep(100);
|
await this.#device_.sleep(100);
|
||||||
if (!await this.readUntil('ok', true, timeout)) {
|
if (!await this.readUntil('ok', true, timeout)) {
|
||||||
throw new Error('无法执行python代码');
|
throw new Error(Msg.Lang['ampy.executePythonCodeFailed']);
|
||||||
}
|
}
|
||||||
let str = await this.readUntil('>', false, timeout);
|
let str = await this.readUntil('>', false, timeout);
|
||||||
if (str.indexOf('OSError') === -1) {
|
if (str.indexOf('OSError') === -1) {
|
||||||
|
|||||||
@@ -317,6 +317,9 @@
|
|||||||
"ampy.enterRawREPLFailed": "Unable to enter Raw REPL",
|
"ampy.enterRawREPLFailed": "Unable to enter Raw REPL",
|
||||||
"ampy.exitRawREPLFailed": "Unable to exit Raw REPL",
|
"ampy.exitRawREPLFailed": "Unable to exit Raw REPL",
|
||||||
"ampy.exitREPLFailed": "Unable to exit REPL",
|
"ampy.exitREPLFailed": "Unable to exit REPL",
|
||||||
|
"ampy.portIsNotOpen": "Serial port is not open",
|
||||||
|
"ampy.executePythonCodeFailed": "Unable to execute python code",
|
||||||
|
"ampy.dataReadInterrupt": "Data reading interrupted",
|
||||||
"editor.contextMenu.cut": "Cut",
|
"editor.contextMenu.cut": "Cut",
|
||||||
"editor.contextMenu.copy": "Copy",
|
"editor.contextMenu.copy": "Copy",
|
||||||
"editor.contextMenu.paste": "Paste",
|
"editor.contextMenu.paste": "Paste",
|
||||||
|
|||||||
@@ -317,6 +317,9 @@
|
|||||||
"ampy.enterRawREPLFailed": "无法进入Raw REPL",
|
"ampy.enterRawREPLFailed": "无法进入Raw REPL",
|
||||||
"ampy.exitRawREPLFailed": "无法退出Raw REPL",
|
"ampy.exitRawREPLFailed": "无法退出Raw REPL",
|
||||||
"ampy.exitREPLFailed": "无法退出REPL",
|
"ampy.exitREPLFailed": "无法退出REPL",
|
||||||
|
"ampy.portIsNotOpen": "串口未打开",
|
||||||
|
"ampy.executePythonCodeFailed": "无法执行python代码",
|
||||||
|
"ampy.dataReadInterrupt": "数据读取中断",
|
||||||
"editor.contextMenu.cut": "剪切",
|
"editor.contextMenu.cut": "剪切",
|
||||||
"editor.contextMenu.copy": "复制",
|
"editor.contextMenu.copy": "复制",
|
||||||
"editor.contextMenu.paste": "粘贴",
|
"editor.contextMenu.paste": "粘贴",
|
||||||
|
|||||||
@@ -317,6 +317,9 @@
|
|||||||
"ampy.enterRawREPLFailed": "無法進入Raw REPL",
|
"ampy.enterRawREPLFailed": "無法進入Raw REPL",
|
||||||
"ampy.exitRawREPLFailed": "無法退出Raw REPL",
|
"ampy.exitRawREPLFailed": "無法退出Raw REPL",
|
||||||
"ampy.exitREPLFailed": "無法退出REPL",
|
"ampy.exitREPLFailed": "無法退出REPL",
|
||||||
|
"ampy.portIsNotOpen": "串列埠未開啟",
|
||||||
|
"ampy.executePythonCodeFailed": "無法執行python程式碼",
|
||||||
|
"ampy.dataReadInterrupt": "資料讀取中斷",
|
||||||
"editor.contextMenu.cut": "剪下",
|
"editor.contextMenu.cut": "剪下",
|
||||||
"editor.contextMenu.copy": "複製",
|
"editor.contextMenu.copy": "複製",
|
||||||
"editor.contextMenu.paste": "貼上",
|
"editor.contextMenu.paste": "貼上",
|
||||||
|
|||||||
Reference in New Issue
Block a user