|
@@ -0,0 +1,826 @@
|
|
|
|
|
+import QtQuick
|
|
|
|
|
+import QtQuick.Controls
|
|
|
|
|
+import QtQuick.Layouts
|
|
|
|
|
+import Qt.labs.settings 1.0 as QtLabs
|
|
|
|
|
+import QtQuick.Controls.Material 2.0
|
|
|
|
|
+import QtLocation 5.5
|
|
|
|
|
+import QtPositioning 5.5
|
|
|
|
|
+import QtMultimedia
|
|
|
|
|
+import Qt5Compat.GraphicalEffects
|
|
|
|
|
+import Felgo 4.0
|
|
|
|
|
+import "../controls"
|
|
|
|
|
+import "../common"
|
|
|
|
|
+//import MqttClient 1.0
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+AppPage {
|
|
|
|
|
+ id: controlsPage
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ property string originalString: ""
|
|
|
|
|
+ property string collectString: ""
|
|
|
|
|
+ property string gps_state: "正在定位..."
|
|
|
|
|
+ property string board_version: ""
|
|
|
|
|
+ property bool connect_board: false
|
|
|
|
|
+ property var tt
|
|
|
|
|
+ property bool isonline: false
|
|
|
|
|
+ property var net_list:[]
|
|
|
|
|
+ property var picinfo_list:[]
|
|
|
|
|
+
|
|
|
|
|
+ Material.accent: Theme.tintColor
|
|
|
|
|
+ rightBarItem: IconButtonBarItem {
|
|
|
|
|
+ iconType: IconType.paintbrush
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ themeModal.open()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Component.onCompleted: {
|
|
|
|
|
+ originalString = myClass.deviceid
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 接收并显示日志消息
|
|
|
|
|
+ Connections {
|
|
|
|
|
+ target: mqtt
|
|
|
|
|
+ onConnected: {
|
|
|
|
|
+ console.log("mqtt connect")
|
|
|
|
|
+ mqtt_sta.detailText="MQTT已连接"
|
|
|
|
|
+ }
|
|
|
|
|
+ onDisconnected: {
|
|
|
|
|
+ console.log("mqtt disconnect")
|
|
|
|
|
+ mqtt_sta.detailText="MQTT已断开"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Connections{
|
|
|
|
|
+ target: myClass
|
|
|
|
|
+ }
|
|
|
|
|
+ //串口
|
|
|
|
|
+ Connections{
|
|
|
|
|
+ target: serial
|
|
|
|
|
+ onDataReceived:{
|
|
|
|
|
+ var jsonData = JSON.parse(data)
|
|
|
|
|
+ console.debug("接收到主板数据:",data.toString())
|
|
|
|
|
+ if(jsonData.ext.work_sta==="0"){
|
|
|
|
|
+ if(jsonData.ext.ds==="0"){
|
|
|
|
|
+ work_header.text =qsTr("<b>设备开关:</b> 关机") + "-" + qsTr("<b>工作状态:</b> 待机")
|
|
|
|
|
+ }else{
|
|
|
|
|
+ work_header.text =qsTr("<b>设备开关:</b> 开机") + "-" + qsTr("<b>工作状态:</b> 待机")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }else if(jsonData.ext.work_sta==="1"){
|
|
|
|
|
+
|
|
|
|
|
+ if(jsonData.ext.ds==="0"){
|
|
|
|
|
+ work_header.text = qsTr("<b>设备开关:</b> 关机") + "-" + qsTr("<b>工作状态:</b> 采集")
|
|
|
|
|
+ }else{
|
|
|
|
|
+ work_header.text = qsTr("<b>设备开关:</b> 开机") + "-" + qsTr("<b>工作状态:</b> 采集")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(jsonData.ext.gps==="1"){
|
|
|
|
|
+ gps_state = "成功"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(jsonData.ext.coll_time){
|
|
|
|
|
+ collectString = " [" +jsonData.ext.coll_time[0] + "," + jsonData.ext.coll_time[1] + "," + jsonData.ext.coll_time[2] + "]";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(jsonData.ext.dat_f){
|
|
|
|
|
+ serial.update_dat_f_main(jsonData.ext.dat_f);
|
|
|
|
|
+ }
|
|
|
|
|
+ board_version = jsonData.ext.dver
|
|
|
|
|
+ work_header.detailText = "电压:" + jsonData.ext.vbat + " 电流:" + jsonData.ext.current + " 温度:" + jsonData.ext.at + " 湿度:" + jsonData.ext.ah ;
|
|
|
|
|
+ }
|
|
|
|
|
+ onDisconnect_485:{
|
|
|
|
|
+ work_header.text =qsTr("485未连接,读取数据失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ MediaPlayer{
|
|
|
|
|
+ id: audio
|
|
|
|
|
+ audioOutput: AudioOutput{}
|
|
|
|
|
+ source: Qt.resolvedUrl("../../assets/mp3/button.mp3")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AppFlickable {
|
|
|
|
|
+ id: scroll
|
|
|
|
|
+ anchors.fill: parent
|
|
|
|
|
+ contentHeight: content.height
|
|
|
|
|
+
|
|
|
|
|
+ // remove focus from controls if clicked outside
|
|
|
|
|
+ MouseArea {
|
|
|
|
|
+ anchors.fill: parent
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ scroll.forceActiveFocus()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Column {
|
|
|
|
|
+ id: content
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+
|
|
|
|
|
+ Timer {
|
|
|
|
|
+ interval: 500
|
|
|
|
|
+ running: true
|
|
|
|
|
+ repeat: true
|
|
|
|
|
+ onTriggered: {
|
|
|
|
|
+ menutab.title = Date().toString() + " 设备ID:" + originalString.toLowerCase() + " GPS状态:" + gps_state
|
|
|
|
|
+ if(mqtt.checkLink()){
|
|
|
|
|
+ mqtt_sta.detailText="MQTT已连接"
|
|
|
|
|
+ }else{
|
|
|
|
|
+ mqtt_sta.detailText="MQTT已断开"
|
|
|
|
|
+ }
|
|
|
|
|
+ net_list = mqtt.netMessage()
|
|
|
|
|
+ if(net_list){
|
|
|
|
|
+ if(net_list[0]==="1"){isonline = true}else{isonline = false}
|
|
|
|
|
+ mqtt_sta.text = qsTr("<b>联网状态:</b> %1 (网卡名称:%2) (描述:%3)").arg(isonline? "已联网" : "未联网").arg(net_list[1]).arg(net_list[2])
|
|
|
|
|
+ net_mes.text = qsTr("<b>[MAC] </b> %1").arg(net_list[3]) + qsTr("<b>[IPV4] </b> %1").arg(net_list[4])
|
|
|
|
|
+ mqtt_sta.detailText += "<服务器地址:>" + net_list[5]
|
|
|
|
|
+ mqtt_sta.detailText += "<数据上传间隔:>" + net_list[6] + "(" +net_list[7] + ")" + "分钟";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Section {
|
|
|
|
|
+ id: menutab
|
|
|
|
|
+ title: Date().toString()
|
|
|
|
|
+
|
|
|
|
|
+ //SectionItem {
|
|
|
|
|
+ //title: "运行状态"
|
|
|
|
|
+ //anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
+
|
|
|
|
|
+ AppCard {
|
|
|
|
|
+ id: card
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+// property real resetX: 0
|
|
|
|
|
+// x: resetX
|
|
|
|
|
+
|
|
|
|
|
+ margin: dp(5)
|
|
|
|
|
+ paper.radius: dp(5)
|
|
|
|
|
+
|
|
|
|
|
+ header: SimpleRow {
|
|
|
|
|
+ id: work_header
|
|
|
|
|
+ //imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
|
|
|
|
|
+ text: qsTr("<b>设备开关:</b> 开机") + qsTr("<b>工作状态:</b> 待机")
|
|
|
|
|
+ detailText: "电压:" + jsonData.ext.vbat + " 电流:" + jsonData.ext.current + " 温度:" + jsonData.ext.at + " 湿度:" + jsonData.ext.ah ;
|
|
|
|
|
+ badgeColor: "green"
|
|
|
|
|
+ image.radius: image.width / 2
|
|
|
|
|
+ image.fillMode: Image.PreserveAspectCrop
|
|
|
|
|
+ style: StyleSimpleRow {
|
|
|
|
|
+ showDisclosure: false
|
|
|
|
|
+ backgroundColor: "transparent"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ media: AppImage {
|
|
|
|
|
+ width: card.width
|
|
|
|
|
+ fillMode: Image.PreserveAspectFit
|
|
|
|
|
+ source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ content: AppText{
|
|
|
|
|
+ id: work_apptext
|
|
|
|
|
+ width: card.width
|
|
|
|
|
+ padding: dp(15)
|
|
|
|
|
+ text: "设定采集时间:" + collectString;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ AppCard {
|
|
|
|
|
+ id: card_net
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+
|
|
|
|
|
+ property real resetX: 0
|
|
|
|
|
+ x: resetX
|
|
|
|
|
+ margin: dp(5)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ paper.radius: dp(5)
|
|
|
|
|
+
|
|
|
|
|
+ header: SimpleRow {
|
|
|
|
|
+ id: mqtt_sta
|
|
|
|
|
+ //imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
|
|
|
|
|
+ text: qsTr("<b>联网状态:</b> %1 (%2)").arg(app.isOnline ? "已联网" : "未联网").arg(nativeUtils.connectionType)
|
|
|
|
|
+ detailText: "AppCard detailed text"
|
|
|
|
|
+
|
|
|
|
|
+ image.radius: image.width / 2
|
|
|
|
|
+ image.fillMode: Image.PreserveAspectCrop
|
|
|
|
|
+ style: StyleSimpleRow {
|
|
|
|
|
+ showDisclosure: false
|
|
|
|
|
+ backgroundColor: "transparent"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ media: AppImage {
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+ fillMode: Image.PreserveAspectFit
|
|
|
|
|
+ source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ content: AppText{
|
|
|
|
|
+ id: net_mes
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+ padding: dp(15)
|
|
|
|
|
+ text: "Mac" + "ipv4:";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // ============ 有线网卡 (eth) 状态与配置 ============
|
|
|
|
|
+ // 通过 EnjoySDK 走系统 EthernetService 配置,无需 root。
|
|
|
|
|
+ // 关键:mode=STATIC 必须与 IP 参数**一次性下发** ——
|
|
|
|
|
+ // setEthernetConfig 会校验整个配置,静态模式下 IP/掩码不合法会被拒(-101),
|
|
|
|
|
+ // 所以不能"先只切模式、再填 IP"分两步提交(见 EthernetBridge.setStaticIp)。
|
|
|
|
|
+ AppCard {
|
|
|
|
|
+ id: card_eth
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+ margin: dp(5)
|
|
|
|
|
+ paper.radius: dp(5)
|
|
|
|
|
+
|
|
|
|
|
+ // ---- 状态 ----
|
|
|
|
|
+ property string ethIface: "eth1" // 目标网卡,可切换 eth0/eth1
|
|
|
|
|
+ property int ethLinkState: -1 // 0未连接 1连接中 2已连接 3断开中 4未知
|
|
|
|
|
+ property int ethMode: 0 // 1=DHCP 2=静态 3=PPPOE 4=未知
|
|
|
|
|
+ property bool ethEnabled: false
|
|
|
|
|
+ property string ethMac: ""
|
|
|
|
|
+ property string ethIp: ""
|
|
|
|
|
+ property string ethMask: ""
|
|
|
|
|
+ property string ethGateway: ""
|
|
|
|
|
+ property string ethDns: ""
|
|
|
|
|
+
|
|
|
|
|
+ // ---- 配置输入 ----
|
|
|
|
|
+ // 默认值:与 GigE 相机同网段的 192.168.100.101 + Jumbo 帧 MTU 9000。
|
|
|
|
|
+ // 若网卡已有配置,refresh() 会用实际值覆盖这两项。
|
|
|
|
|
+ property bool useDhcp: true // true=DHCP false=静态
|
|
|
|
|
+ property string ipInput: "192.168.100.101"
|
|
|
|
|
+ property string maskInput: "255.255.255.0"
|
|
|
|
|
+ property string gatewayInput: ""
|
|
|
|
|
+ property string dnsInput: ""
|
|
|
|
|
+ property string mtuInput: "9000"
|
|
|
|
|
+ property string ethMessage: ""
|
|
|
|
|
+ property bool ethBusy: false
|
|
|
|
|
+
|
|
|
|
|
+ // 链路状态文字
|
|
|
|
|
+ readonly property string linkText: {
|
|
|
|
|
+ switch (ethLinkState) {
|
|
|
|
|
+ case 0: return "未连接"
|
|
|
|
|
+ case 1: return "连接中"
|
|
|
|
|
+ case 2: return "已连接"
|
|
|
|
|
+ case 3: return "断开中"
|
|
|
|
|
+ default: return "未知"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ readonly property string linkColor: {
|
|
|
|
|
+ switch (ethLinkState) {
|
|
|
|
|
+ case 2: return "#28a779" // 已连接=绿
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ case 3: return "#e8a33d" // 连接中/断开中=黄
|
|
|
|
|
+ case 0: return "#e74c3c" // 未连接=红
|
|
|
|
|
+ default: return "#999999"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ readonly property string modeText: {
|
|
|
|
|
+ switch (ethMode) {
|
|
|
|
|
+ case 1: return "DHCP"
|
|
|
|
|
+ case 2: return "静态"
|
|
|
|
|
+ case 3: return "PPPOE"
|
|
|
|
|
+ default: return "未知"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 读取指定网卡状态
|
|
|
|
|
+ // keepMode: 为 true 时不覆盖 useDhcp —— 设置模式下发的瞬间系统返回值
|
|
|
|
|
+ // 可能还没刷新,若此时用 r.mode 回写会把用户刚选的模式弹回去。
|
|
|
|
|
+ function refresh(iface, keepMode) {
|
|
|
|
|
+ if (iface !== undefined && iface !== "")
|
|
|
|
|
+ card_eth.ethIface = iface
|
|
|
|
|
+ var r = ethernet.status(card_eth.ethIface)
|
|
|
|
|
+ if (!r || r.ok !== true) {
|
|
|
|
|
+ card_eth.ethMessage = "读取失败: " + (r && r.msg ? r.msg : ethernet.lastError())
|
|
|
|
|
+ card_eth.ethLinkState = -1
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ card_eth.ethLinkState = r.linkState !== undefined ? r.linkState : -1
|
|
|
|
|
+ card_eth.ethMode = r.mode !== undefined ? r.mode : 0
|
|
|
|
|
+ card_eth.ethEnabled = (r.enabled === true)
|
|
|
|
|
+ card_eth.ethMac = r.mac || ""
|
|
|
|
|
+ card_eth.ethIp = r.ip || ""
|
|
|
|
|
+ card_eth.ethMask = r.subnetMask || ""
|
|
|
|
|
+ card_eth.ethGateway = r.gateway || ""
|
|
|
|
|
+ card_eth.ethDns = r.dns || ""
|
|
|
|
|
+ // 用当前实际配置回填输入框
|
|
|
|
|
+ if (r.ip && r.ip !== "0.0.0.0") {
|
|
|
|
|
+ card_eth.ipInput = r.ip
|
|
|
|
|
+ card_eth.maskInput = r.subnetMask || "255.255.255.0"
|
|
|
|
|
+ card_eth.gatewayInput = r.gateway || ""
|
|
|
|
|
+ card_eth.dnsInput = r.dns || ""
|
|
|
|
|
+ }
|
|
|
|
|
+ if (keepMode !== true) {
|
|
|
|
|
+ card_eth.useDhcp = (r.mode === 1)
|
|
|
|
|
+ }
|
|
|
|
|
+ card_eth.ethMessage = ""
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 切换为 DHCP 模式。
|
|
|
|
|
+ // 注意:静态模式**不能**在这里单独下发 —— setEthernetConfig 会校验整个配置,
|
|
|
|
|
+ // 静态模式下 IP/掩码必须合法,只改 mode 会被拒(-101)。
|
|
|
|
|
+ // 所以切静态只改界面状态,等用户填好 IP 后由 applyStaticIp() 一次性下发。
|
|
|
|
|
+ function applyDhcp() {
|
|
|
|
|
+ card_eth.ethBusy = true
|
|
|
|
|
+ var r = ethernet.setDhcp(card_eth.ethIface, true) // true = DHCP
|
|
|
|
|
+ card_eth.ethBusy = false
|
|
|
|
|
+ if (r && r.ok === true) {
|
|
|
|
|
+ card_eth.ethMessage = "已切换为 DHCP 模式"
|
|
|
|
|
+ card_eth.refresh(undefined, true)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ card_eth.ethMessage = "切换失败: " + (r && r.msg ? r.msg : ethernet.lastError())
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 应用静态配置:先 MTU,再静态 IP
|
|
|
|
|
+ // 【顺序很重要】setMtu 内部会 ifconfig down/up,会重置网卡;
|
|
|
|
|
+ // 若先下发 IP 再改 MTU,刚设好的 IP 可能被 down/up 冲掉。
|
|
|
|
|
+ function applyStaticIp() {
|
|
|
|
|
+ if (!card_eth.ipInput) {
|
|
|
|
|
+ card_eth.ethMessage = "请输入 IP 地址"
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ card_eth.ethBusy = true
|
|
|
|
|
+
|
|
|
|
|
+ // 步骤 1:设置 MTU(Jumbo 帧)。
|
|
|
|
|
+ // EnjoySDK 没有 MTU 接口,只能走 ifconfig + su,需要 root;
|
|
|
|
|
+ // 失败不影响后续 IP 下发,单独在提示里说明。
|
|
|
|
|
+ var mtuMsg = ""
|
|
|
|
|
+ var mtu = parseInt(card_eth.mtuInput)
|
|
|
|
|
+ if (!isNaN(mtu) && mtu > 0) {
|
|
|
|
|
+ var m = ethernet.setMtu(card_eth.ethIface, mtu)
|
|
|
|
|
+ if (m && m.ok === true) {
|
|
|
|
|
+ mtuMsg = ",MTU=" + mtu
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var why = ethernet.lastError()
|
|
|
|
|
+ mtuMsg = ",MTU 未生效" + (why ? "(" + why + ")" : "")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 步骤 2:一次性下发 mode=STATIC + IP
|
|
|
|
|
+ // (setStaticIp 内部把 mode 与 IP 字段一起提交;
|
|
|
|
|
+ // 若只切模式再设 IP,静态模式下配置校验不过会被拒 -101)
|
|
|
|
|
+ var r = ethernet.setStaticIp(card_eth.ethIface,
|
|
|
|
|
+ card_eth.ipInput,
|
|
|
|
|
+ card_eth.maskInput,
|
|
|
|
|
+ card_eth.gatewayInput,
|
|
|
|
|
+ card_eth.dnsInput)
|
|
|
|
|
+ card_eth.ethBusy = false
|
|
|
|
|
+ if (!r || r.ok !== true) {
|
|
|
|
|
+ card_eth.ethMessage = "设置失败: " + (r && r.msg ? r.msg : ethernet.lastError())
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ card_eth.useDhcp = false
|
|
|
|
|
+ card_eth.ethMessage = "静态 IP 已应用: " + card_eth.ipInput + mtuMsg
|
|
|
|
|
+ card_eth.refresh(undefined, true)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ header: SimpleRow {
|
|
|
|
|
+ id: eth_sta
|
|
|
|
|
+ text: qsTr("<b>有线网卡:</b> %1 (%2)").arg(card_eth.ethIface).arg(card_eth.linkText)
|
|
|
|
|
+ detailText: qsTr("模式: %1 IP: %2").arg(card_eth.modeText)
|
|
|
|
|
+ .arg(card_eth.ethIp === "" ? "未分配" : card_eth.ethIp)
|
|
|
|
|
+ image.radius: image.width / 2
|
|
|
|
|
+ image.fillMode: Image.PreserveAspectCrop
|
|
|
|
|
+ style: StyleSimpleRow {
|
|
|
|
|
+ showDisclosure: false
|
|
|
|
|
+ backgroundColor: "transparent"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ media: Rectangle {
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+ height: dp(4)
|
|
|
|
|
+ color: card_eth.linkColor
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ content: ColumnLayout {
|
|
|
|
|
+ id: eth_content
|
|
|
|
|
+ width: card_eth.width
|
|
|
|
|
+ spacing: dp(10)
|
|
|
|
|
+
|
|
|
|
|
+ // ---- 网卡选择 ----
|
|
|
|
|
+ RowLayout {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ spacing: dp(10)
|
|
|
|
|
+
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "网卡"
|
|
|
|
|
+ color: Theme.textColor
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 目标网卡:默认 eth1,可切换
|
|
|
|
|
+ RowLayout {
|
|
|
|
|
+ spacing: dp(6)
|
|
|
|
|
+ Repeater {
|
|
|
|
|
+ model: ["eth0", "eth1"]
|
|
|
|
|
+ delegate: AppButton {
|
|
|
|
|
+ // 用 var 而非 string:与下面对象数组的 delegate 保持一致,
|
|
|
|
|
+ // 避免 Qt 版本对 modelData 类型推断的差异
|
|
|
|
|
+ required property var modelData
|
|
|
|
|
+ text: modelData
|
|
|
|
|
+ flat: true
|
|
|
|
|
+ // 用 opacity 而非 visible 表达选中态,避免切换时按钮宽度跳变
|
|
|
|
|
+ opacity: card_eth.ethIface === modelData ? 1 : 0.5
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ card_eth.ethIface = modelData
|
|
|
|
|
+ card_eth.refresh()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Item { Layout.fillWidth: true }
|
|
|
|
|
+
|
|
|
|
|
+ AppButton {
|
|
|
|
|
+ text: "刷新"
|
|
|
|
|
+ onClicked: card_eth.refresh()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // ---- 当前状态明细 ----
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: "MAC: " + (card_eth.ethMac === "" ? "-" : card_eth.ethMac)
|
|
|
|
|
+ color: Theme.textColor
|
|
|
|
|
+ font.pixelSize: sp(12)
|
|
|
|
|
+ elide: Text.ElideMiddle
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: "模式: " + card_eth.modeText
|
|
|
|
|
+ + " 子网掩码: " + (card_eth.ethMask === "" ? "-" : card_eth.ethMask)
|
|
|
|
|
+ + " 网关: " + (card_eth.ethGateway === "" ? "-" : card_eth.ethGateway)
|
|
|
|
|
+ color: Theme.textColor
|
|
|
|
|
+ font.pixelSize: sp(12)
|
|
|
|
|
+ elide: Text.ElideMiddle
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // ---- DHCP / 静态 切换 ----
|
|
|
|
|
+ RowLayout {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ spacing: dp(10)
|
|
|
|
|
+
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "IP 模式"
|
|
|
|
|
+ color: Theme.textColor
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ RowLayout {
|
|
|
|
|
+ spacing: dp(6)
|
|
|
|
|
+ Repeater {
|
|
|
|
|
+ model: [{ label: "DHCP", value: true },
|
|
|
|
|
+ { label: "静态IP", value: false }]
|
|
|
|
|
+ delegate: AppButton {
|
|
|
|
|
+ required property var modelData
|
|
|
|
|
+ text: modelData.label
|
|
|
|
|
+ flat: true
|
|
|
|
|
+ opacity: card_eth.useDhcp === modelData.value ? 1 : 0.5
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ if (card_eth.useDhcp === modelData.value)
|
|
|
|
|
+ return
|
|
|
|
|
+ card_eth.useDhcp = modelData.value
|
|
|
|
|
+ if (modelData.value === true) {
|
|
|
|
|
+ // 切 DHCP:直接下发(DHCP 不需要调用方提供 IP)
|
|
|
|
|
+ card_eth.applyDhcp()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 切静态:只展开参数表单,**暂不下发**。
|
|
|
|
|
+ // 静态模式要求 IP/掩码齐全,单独改 mode 会被系统拒(-101);
|
|
|
|
|
+ // 等用户填好后点「应用静态IP」时 mode+IP 一次性提交。
|
|
|
|
|
+ card_eth.ethMessage = "请填写静态 IP 参数,然后点「应用静态IP」"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Item { Layout.fillWidth: true }
|
|
|
|
|
+
|
|
|
|
|
+ // 网卡开关
|
|
|
|
|
+ AppButton {
|
|
|
|
|
+ text: card_eth.ethEnabled ? "关闭网卡" : "启用网卡"
|
|
|
|
|
+ enabled: !card_eth.ethBusy
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ var r = ethernet.setEnabled(card_eth.ethIface, !card_eth.ethEnabled)
|
|
|
|
|
+ if (r && r.ok === true) {
|
|
|
|
|
+ card_eth.refresh()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ card_eth.ethMessage = "操作失败: " + (r && r.msg ? r.msg : ethernet.lastError())
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // ---- 静态 IP 参数(仅静态模式下可编辑)----
|
|
|
|
|
+ // 这里用 visible(而非 opacity)是有意的:DHCP 模式下要让整块参数
|
|
|
|
|
+ // 真正收起、不占布局空间;用 opacity 隐藏的话输入框仍会占位。
|
|
|
|
|
+ // 下方"模式"按钮与网卡开关是固定行,不受这里影响。
|
|
|
|
|
+ ColumnLayout {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ spacing: dp(6)
|
|
|
|
|
+ visible: !card_eth.useDhcp
|
|
|
|
|
+ enabled: !card_eth.useDhcp && !card_eth.ethBusy
|
|
|
|
|
+
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "静态 IP 参数"
|
|
|
|
|
+ color: Theme.textColor
|
|
|
|
|
+ font.pixelSize: sp(12)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ GridLayout {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ columns: 2
|
|
|
|
|
+ columnSpacing: dp(10)
|
|
|
|
|
+ rowSpacing: dp(8)
|
|
|
|
|
+
|
|
|
|
|
+ AppText { text: "IP 地址"; color: Theme.textColor }
|
|
|
|
|
+ AppTextField {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: card_eth.ipInput
|
|
|
|
|
+ placeholderText: "如 192.168.100.101"
|
|
|
|
|
+ onTextChanged: card_eth.ipInput = text
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AppText { text: "子网掩码"; color: Theme.textColor }
|
|
|
|
|
+ AppTextField {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: card_eth.maskInput
|
|
|
|
|
+ placeholderText: "255.255.255.0"
|
|
|
|
|
+ onTextChanged: card_eth.maskInput = text
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AppText { text: "网关"; color: Theme.textColor }
|
|
|
|
|
+ AppTextField {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: card_eth.gatewayInput
|
|
|
|
|
+ placeholderText: "可留空"
|
|
|
|
|
+ onTextChanged: card_eth.gatewayInput = text
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AppText { text: "DNS"; color: Theme.textColor }
|
|
|
|
|
+ AppTextField {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: card_eth.dnsInput
|
|
|
|
|
+ placeholderText: "可留空"
|
|
|
|
|
+ onTextChanged: card_eth.dnsInput = text
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AppText { text: "MTU"; color: Theme.textColor }
|
|
|
|
|
+ AppTextField {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: card_eth.mtuInput
|
|
|
|
|
+ placeholderText: "如 9000 (Jumbo 帧)"
|
|
|
|
|
+ inputMethodHints: Qt.ImhDigitsOnly
|
|
|
|
|
+ onTextChanged: card_eth.mtuInput = text
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // MTU 说明:EnjoySDK 没有 MTU 接口,只能走 ifconfig + su,
|
|
|
|
|
+ // 需要设备已 root;失败不影响上面已下发的 IP 配置。
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: "MTU(9000) 用于 GigE 大帧,需设备已 root;失败不影响 IP 配置"
|
|
|
|
|
+ color: "#999999"
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ wrapMode: Text.Wrap
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ RowLayout {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ spacing: dp(10)
|
|
|
|
|
+ Item { Layout.fillWidth: true }
|
|
|
|
|
+ AppButton {
|
|
|
|
|
+ text: card_eth.ethBusy ? "应用中..." : "应用静态IP"
|
|
|
|
|
+ enabled: !card_eth.ethBusy
|
|
|
|
|
+ onClicked: card_eth.applyStaticIp()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // ---- 结果提示 ----
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ Layout.fillWidth: true
|
|
|
|
|
+ text: card_eth.ethMessage
|
|
|
|
|
+ color: card_eth.ethMessage === "" ? Theme.textColor : "#e8a33d"
|
|
|
|
|
+ font.pixelSize: sp(12)
|
|
|
|
|
+ wrapMode: Text.Wrap
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Component.onCompleted: {
|
|
|
|
|
+ // 默认展示 eth1 状态(eth0 用于 GigE 相机,由程序启动时自动配置)
|
|
|
|
|
+ card_eth.ethIface = "eth1"
|
|
|
|
|
+ card_eth.refresh()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// AppCard {
|
|
|
|
|
+// id: card_cfg
|
|
|
|
|
+// width: parent.width
|
|
|
|
|
+// height: width*1.5
|
|
|
|
|
+// property real resetX: 0
|
|
|
|
|
+// x: resetX
|
|
|
|
|
+// margin: dp(5)
|
|
|
|
|
+
|
|
|
|
|
+// paper.radius: dp(5)
|
|
|
|
|
+
|
|
|
|
|
+// header: SimpleRow {
|
|
|
|
|
+// imageSource: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
|
|
|
|
|
+// text: "参数"
|
|
|
|
|
+// detailText: "AppCard detailed text"
|
|
|
|
|
+
|
|
|
|
|
+// image.radius: image.width / 2
|
|
|
|
|
+// image.fillMode: Image.PreserveAspectCrop
|
|
|
|
|
+// style: StyleSimpleRow {
|
|
|
|
|
+// showDisclosure: false
|
|
|
|
|
+// backgroundColor: "transparent"
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// media: AppImage {
|
|
|
|
|
+// width: card_cfg.width
|
|
|
|
|
+// fillMode: Image.PreserveAspectFit
|
|
|
|
|
+// source: Qt.resolvedUrl("../../assets/architecture-1477041_960_720.jpg")
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// content: AppText{
|
|
|
|
|
+// width: card_cfg.width
|
|
|
|
|
+// padding: dp(15)
|
|
|
|
|
+// text: "此界面显示参数等信息,运行时间等"
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+// cardSwipeArea.onSwipeOutCompleted: {
|
|
|
|
|
+// card_cfg.x = card_cfg.resetX
|
|
|
|
|
+// card_cfg.rotation = 0
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ //} // AppCard section
|
|
|
|
|
+
|
|
|
|
|
+ } // convenience controls section
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Timer {
|
|
|
|
|
+ interval: 1000
|
|
|
|
|
+ running: true
|
|
|
|
|
+ repeat: true
|
|
|
|
|
+ onTriggered: {
|
|
|
|
|
+ picinfo_list = serial.pathinfo()
|
|
|
|
|
+ pic_path.text = "图片存储目录:" + picinfo_list[0]
|
|
|
|
|
+ pic_count.text = "文件数量:" + picinfo_list[1]
|
|
|
|
|
+ pic_total.text = "占用大小:" + picinfo_list[2] + "(Mb)"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Section {
|
|
|
|
|
+ title: "存储信息"
|
|
|
|
|
+ bottomPadding: dp(Theme.navigationBar.defaultBarItemPadding)
|
|
|
|
|
+
|
|
|
|
|
+ Grid {
|
|
|
|
|
+ anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
+ columns: 2
|
|
|
|
|
+ rows: 4
|
|
|
|
|
+ //horizontalItemAlignment: Grid.AlignHCenter
|
|
|
|
|
+ Column{
|
|
|
|
|
+ AppButton {
|
|
|
|
|
+ text: "查询"
|
|
|
|
|
+ flat: false
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ serial.readPathinfo()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ AppButton {
|
|
|
|
|
+ text: "清理"
|
|
|
|
|
+ flat: false
|
|
|
|
|
+ onClicked: {
|
|
|
|
|
+ serial.removepic()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Column{
|
|
|
|
|
+
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ id: pic_path
|
|
|
|
|
+ text: "图片存储目录:" + picinfo_list[0]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AppText{
|
|
|
|
|
+ id: pic_count
|
|
|
|
|
+ text: "文件数量:" + picinfo_list[1]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AppText{
|
|
|
|
|
+ id: pic_total
|
|
|
|
|
+ text: "占用大小:" + picinfo_list[2]
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ } // native utils section }
|
|
|
|
|
+
|
|
|
|
|
+ Section {
|
|
|
|
|
+ title: "Device Info"
|
|
|
|
|
+ bottomPadding: dp(15)
|
|
|
|
|
+
|
|
|
|
|
+ Row {
|
|
|
|
|
+ width: parent.width - dp(30)
|
|
|
|
|
+ anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
+ spacing: dp(5)
|
|
|
|
|
+
|
|
|
|
|
+ Column {
|
|
|
|
|
+ id: firstInfoColumn
|
|
|
|
|
+ spacing: dp(5)
|
|
|
|
|
+ width: (parent.width - parent.spacing) * 0.5
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>OS Type:</b> " + system.osType
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ visible: system.osType !== "undefined"
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>OS Version:</b> " + system.osVersion
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ visible: system.osVersion !== "undefined"
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>Device Model:</b> " + nativeUtils.deviceModel()
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ visible: nativeUtils.deviceModel() !== "undefined"
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: qsTr("<b>Device Online:</b> %1 (%2)").arg(app.isOnline ? "Yes" : "No").arg(nativeUtils.connectionType)
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>MAC Address:</b> " + system.macAddress
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
|
+ visible: system.macAddress !== "undefined"
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>Unique Device Id:</b> " + system.UDID
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
|
+ visible: system.UDID !== "undefined"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Column {
|
|
|
|
|
+ id: secondInfoColumn
|
|
|
|
|
+ spacing: dp(5)
|
|
|
|
|
+ width: firstInfoColumn.width
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>Orientation:</b> " + (Theme.isPortrait ? "portrait" : "landscape")
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>Statusbar Height:</b> " + Theme.statusBarHeight
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>App Identifier:</b> " + system.appIdentifier
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ width: parent.width
|
|
|
|
|
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
|
+ visible: system.appIdentifier !== "undefined"
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>App Version:</b> " + system.appVersionCode
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>Qt Version:</b> " + system.qtVersion
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ }
|
|
|
|
|
+ AppText {
|
|
|
|
|
+ text: "<b>Felgo Version:</b> " + system.felgoVersion + " (" + system.felgoVersionRef + ")"
|
|
|
|
|
+ font.pixelSize: sp(11)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } // device info section
|
|
|
|
|
+ } // content column
|
|
|
|
|
+ } // flickable
|
|
|
|
|
+
|
|
|
|
|
+ ThemeModal {
|
|
|
|
|
+ id: themeModal
|
|
|
|
|
+ pushBackContent: navigationStack
|
|
|
|
|
+ } // theme modal
|
|
|
|
|
+} // page
|
|
|
|
|
+
|