| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733 |
- <template>
- <view class="container">
- <!-- 头部区域 -->
- <BluetoothHeader
- @ble-data-received="handleBleDataReceived"
- />
- <!-- 主要内容区域 -->
- <scroll-view class="content" >
- <view class="param-section">
- <!-- 电机方向 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">电机方向</u-button>
- </view>
- <view class="input-class" >
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.motorDirection"
- disabledColor="#ffffff"
- placeholder="请选择方向"
- readonly
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wDir" @change="handleDirectionChange" class="checkbox" label="W_Dir">W_Dir</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" @click="writeDirection" :disabled="params.wDir">方向设置</u-button>
- </view>
- <!-- 通讯时间 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">通讯时间</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.communicationTime"
- disabledColor="#ffffff"
- placeholder=""
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group v-model="checkboxValue_timedSend"
- placement="column">
- <u-checkbox name="timedSend" v-model="params.timedSend" class="checkbox" label="定时发送" @change="handleCommunicationTimeChange">定时发送</u-checkbox>
- </u-checkbox-group>
- </view>
- </view>
- <!-- 夜返角度 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">夜返角度°</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.nightReturnAngle"
- placeholder="请输入角度"
- type="text"
- class="param-input"
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wBackA" class="checkbox" label="W_BackA" @change="handleNightReturnAngleChange">W_BackA</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" :disabled="params.wBackA"
- @click="writeNightReturnAngle">夜返角写入
- </u-button>
- </view>
- <!-- 放平角度 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">放平角度°</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.flatAngle"
- placeholder="请输入角度"
- type="text"
- class="param-input"
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wFlat" class="checkbox" label="W_Flat" @change="handleFlatAngleChange">W_Flat</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" :disabled="params.wFlat" @click="writeFlatAngle">
- 放平角度写入
- </u-button>
- </view>
- <!-- 指定角度 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">指定角度°</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.specifiedAngle"
- placeholder="请输入角度"
- type="text"
- class="param-input"
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wSetA" class="checkbox" label="W_SetA" @change="handleSpecifiedAngleChange">W_SetA</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" :disabled="params.wSetA" @click="writeSpecifiedAngle">
- 指定角度写入
- </u-button>
- </view>
- <!-- 雪天角度 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">雪天角度°</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.snowAngle"
- placeholder="请输入角度"
- type="text"
- class="param-input"
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wSno" class="checkbox" label="W_Sno" @change="handleSnowAngleChange">W_Sno</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" :disabled="params.wSno" @click="writeSnowAngle">
- 雪天角度写入
- </u-button>
- </view>
- <!-- 大风角度 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">大风角度°</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.windAngle"
- placeholder="请输入角度"
- type="text"
- class="param-input"
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wWin" class="checkbox" label="W_Win" @change="handleWindAngleChange">W_Win</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" :disabled="params.wWin" @click="writeWindAngle">
- 大风角度写入
- </u-button>
- </view>
- <!-- 过流值 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">过流值(A)</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.overcurrentValue"
- placeholder="请输入过流值"
- type="text"
- class="param-input"
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wCurr" class="checkbox" label="W_Curr" @change="handleOvercurrentValueChange">W_Curr</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" :disabled="params.wCurr"
- @click="writeOvercurrentProtection">过流保护写入
- </u-button>
- </view>
- <!-- 跟踪精度 -->
- <view class="param-row">
- <view class="btn-class">
- <u-button type="primary" size="mini" class="param-label">跟踪精度</u-button>
- </view>
- <view class="input-class">
- <u-input
- @focus="editStatus = true"
- @blur="handleBlurWithDelay"
- v-model="params.trackingAccuracy"
- placeholder="请输入精度"
- type="text"
- class="param-input"
- ></u-input>
- </view>
- <view class="checkbox-class">
- <u-checkbox-group
- placement="column">
- <u-checkbox v-model="params.wAccu" class="checkbox" label="W_Accu" @change="handleAccuracyChange">W_Accu</u-checkbox>
- </u-checkbox-group>
- </view>
- <u-button :plain="true" :hairline="true" size="mini" class="action-btn" :disabled="params.wAccu" @click="writeAccuracy">
- 精度写入
- </u-button>
- </view>
- </view>
- </scroll-view>
- <DeviceStatusInfo/>
- <u-action-sheet
- :show="showMotorDirection"
- :actions="directionOptions"
- title="请选择电机方向"
- @close="showMotorDirection = false"
- @select="motorDirectionSelect"
- >
- </u-action-sheet>
- </view>
- </template>
- <script>
- import BluetoothHeader from '@/pages/components/header.vue';
- import DeviceStatusInfo from '@/pages/components/DeviceStatusInfo.vue';
- import {writeRegister,setTime,stopHeartbeat,setTimeStatus,getAgreement} from '@/utils/modbus.js';
- export default {
- components: {
- BluetoothHeader,
- DeviceStatusInfo
- },
- data() {
- return {
- agreementTypeName :'',
- checkboxValue_timedSend: ['timedSend'],
- editStatus: false,
- showMotorDirection: false,
- checkboxValue1: [],
- activeTab: 'settings2',
- params: {
- motorDirection: '正转',
- communicationTime: '0.5',
- nightReturnAngle: '-30',
- flatAngle: '-1',
- specifiedAngle: '20',
- snowAngle: '30',
- windAngle: '10',
- overcurrentValue: '5',
- trackingAccuracy: '1',
- wDir:true,
- timedSend: true,
- wBackA: true,
- wFlat: true,
- wSetA: true,
- wSno: true,
- wWin: true,
- wCurr: true,
- wAccu: true
- },
- directionOptions: [
- {name: '正转', value: '正转'},
- {name: '反转', value: '反转'}
- ],
- communicationLink_2: false,
- communicationTimer_2: null, // 添加这一行用于保存定时器 ID
- }
- },
- onShow() {
- this.agreementTypeName = getAgreement();
- },
- methods: {
- // 处理从子组件传递过来的蓝牙数据
- handleBleDataReceived(data) {
- console.log('在父组件中接收到蓝牙数据:', data);
- this.updateSensorData(data);
- },
- handleBlurWithDelay() {
- setTimeout(() => {
- this.editStatus = false;
- }, 1000);
- },
- handleNightReturnAngleChange(value){
- this.params.wBackA = !value;
- },
- handleFlatAngleChange(value){
- this.params.wFlat = !value;
- },
- handleSpecifiedAngleChange(value){
- this.params.wSetA = !value;
- },
- handleSnowAngleChange(value){
- this.params.wSno = !value;
- },
- handleWindAngleChange(value){
- this.params.wWin = !value;
- },
- handleOvercurrentValueChange(value){
- this.params.wCurr = !value;
- },
- handleAccuracyChange(value){
- this.params.wAccu = !value;
- },
- handleCommunicationTimeChange(value){
- this.params.wTim = !value;
- if (value){
- let number = parseFloat(this.params.communicationTime || "0");
- const intValue1 = Math.round(number * 1000);
- setTime(intValue1);
- }else{
- stopHeartbeat();
- }
- setTimeStatus(value);
- },
- handleDirectionChange(value){
- this.params.wDir = !value;
- },
- motorDirectionSelect(e){
- this.params.motorDirection = e.name
- uni.showModal({
- title: '确认写入',
- content: `确定执行电机方向设置?`,
- success: (res) => {
- if (res.confirm) {
- if (e.name === '正转'){
- writeRegister('READ_DIRECTION', null)
- }else {
- writeRegister('READ_REVERSE', null)
- }
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- writeDirection() {
- this.showMotorDirection = true;
- },
- writeNightReturnAngle() {
- if (this.params.wBackA) return
- uni.showModal({
- title: '确认写入',
- content: `是否确定执行此操作?`,
- success: (res) => {
- if (res.confirm) {
- writeRegister('READ_RETURN', this.params.nightReturnAngle);
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- writeFlatAngle() {
- if (this.params.wFlat) return
- uni.showModal({
- title: '确认写入',
- content: `是否确定执行此操作?`,
- success: (res) => {
- if (res.confirm) {
- writeRegister('READ_FLAT', this.params.flatAngle);
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- writeSpecifiedAngle() {
- if (this.params.wSetA) return
- uni.showModal({
- title: '确认写入',
- content: `是否确定执行此操作?`,
- success: (res) => {
- if (res.confirm) {
- writeRegister('READ_SPECIFY', this.params.specifiedAngle);
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- writeSnowAngle() {
- if (this.params.wSno) return
- uni.showModal({
- title: '确认写入',
- content: `是否确定执行此操作?`,
- success: (res) => {
- if (res.confirm) {
- writeRegister('READ_SNOW', this.params.snowAngle);
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- writeWindAngle() {
- if (this.params.wWin) return
- uni.showModal({
- title: '确认写入',
- content: `是否确定执行此操作?`,
- success: (res) => {
- if (res.confirm) {
- writeRegister('READ_WIND', this.params.windAngle);
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- writeOvercurrentProtection() {
- if (this.params.wCurr) return
- uni.showModal({
- title: '确认写入',
- content: `是否确定执行此操作?`,
- success: (res) => {
- if (res.confirm) {
- writeRegister('READ_OVERCURRENT', this.params.overcurrentValue);
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- writeAccuracy() {
- if (this.params.wAccu) return
- uni.showModal({
- title: '确认写入',
- content: `是否确定执行此操作?`,
- success: (res) => {
- if (res.confirm) {
- writeRegister('READ_ACCURACY', this.params.trackingAccuracy);
- uni.showToast({
- title: '操作执行成功!',
- icon: 'success',
- duration: 2000
- });
- }
- }
- });
- },
- updateSensorData(data) {
- // 根据蓝牙数据更新参数值
- if (data.MotDrection_37 !== undefined && this.params.wDir) {
- // 电机方向: 0表示正转,1表示反转
- this.params.motorDirection = data.MotDrection_37 === '1' ? '反转' : '正转'
- }
- if (data.qNightAngle_66 !== undefined && this.params.wBackA) {
- this.params.nightReturnAngle = data.qNightAngle_66
- }
- if (data.qFlatAngle_67 !== undefined && this.params.wFlat) {
- this.params.flatAngle = data.qFlatAngle_67
- }
- if (data.qSpecifiedAngle_69 !== undefined && this.params.wSetA) {
- this.params.specifiedAngle = data.qSpecifiedAngle_69
- }
- if (data.qSnowAngle_68 !== undefined && this.params.wSno) {
- this.params.snowAngle = data.qSnowAngle_68
- }
- if (data.qWindAngle_70 !== undefined && this.params.wWin ) {
- this.params.windAngle = data.qWindAngle_70
- }
- if (data.OverProtection_38 !== undefined && this.params.wCurr) {
- this.params.overcurrentValue = data.OverProtection_38
- }
- if (data.TrackingAccuracy_39 !== undefined && this.params.wAccu) {
- this.params.trackingAccuracy = data.TrackingAccuracy_39
- }
- // 设置6秒后将 communicationLink_2 设置为 false 的定时器
- this.communicationTimer_2 = setTimeout(() => {
- this.communicationLink_2 = false
- this.communicationTimer_2 = null
- }, 5000)
- }
- }
- }
- </script>
- <style lang="scss" >
- @import '@/static/scss/custom-theme.scss';
- .container {
- height: calc(100vh - 100px);
- display: flex;
- flex-direction: column;
- background-color: $custom-bg-tertiary;
- }
- .status-bar {
- height: $custom-status-height;
- background-color: $custom-bg-primary;
- @include flex-between;
- padding: 0 $custom-spacing-md;
- font-size: 14px;
- .status-left {
- color: $custom-text-primary;
- }
- .status-right {
- @include flex-start;
- gap: $custom-spacing-xs;
- .data-rate {
- color: $custom-text-secondary;
- font-size: 12px;
- }
- .wifi-icon, .hd-text, .network, .battery {
- font-size: 12px;
- }
- }
- }
- .content {
- flex: 1;
- padding: $custom-spacing-md;
- height: calc(100% - 90px) ;
- }
- .param-section {
- height: 100%;
- overflow: auto;
- @include card-style;
- }
- .param-row {
- @include flex-start;
- margin-bottom: $custom-spacing-md;
- gap: 2px;
- .param-label {
- width: 70px;
- @include button-style('primary');
- }
- .param-input {
- flex: 1;
- width: 60px;
- @include input-style;
- }
- .radio-group {
- @include flex-start;
- gap: $custom-spacing-md;
- }
- .checkbox {
- margin-left: $custom-spacing-sm;
- }
- .action-btn {
- width: 90px;
- background-color: $custom-bg-secondary;
- color: $custom-text-secondary;
- border: 1px solid $custom-border-secondary;
- height: 30px;
- line-height: 30px;
- margin-right: 0px;
- font-size: 12px;
- }
- }
- .bottom-nav {
- height: $custom-nav-height;
- background-color: $custom-nav-bg;
- display: flex;
- border-top: 1px solid $custom-border-primary;
- .nav-item {
- flex: 1;
- @include flex-center;
- font-size: 14px;
- color: $custom-text-secondary;
- background-color: $custom-bg-secondary;
- border-right: 1px solid $custom-border-primary;
- transition: $custom-transition;
- &:last-child {
- border-right: none;
- }
- &.active {
- background-color: $custom-nav-active-bg;
- color: $custom-text-primary;
- font-weight: bold;
- }
- &:hover {
- background-color: darken($custom-bg-secondary, 5%);
- }
- }
- }
- .footer-status {
- height: $custom-footer-height;
- @include gradient-bg;
- @include flex-between;
- padding: 0 $custom-spacing-md;
- .bt-status {
- color: #007aff;
- font-size: 14px;
- font-weight: bold;
- }
- .rx-tx-status {
- color: $custom-text-primary;
- font-size: 12px;
- }
- }
- // 响应式设计
- @include responsive(md) {
- .param-row {
- .param-input {
- min-width: 150px;
- }
- }
- }
- @include responsive(lg) {
- .param-row {
- .param-input {
- min-width: 200px;
- }
- }
- }
- ::v-deep .param-section .u-button--mini{
- width: 80px !important;
- height: 36px !important;
- font-size: 10px !important;
- }
- ::v-deep .param-section .u-input{
- width: 60px !important;
- }
- ::v-deep .content text{
- font-size: 12px !important;
- }
- .typeSelect{
- font-size: 16px;
- color: #fff;
- font-weight: 600;
- display: flex;
- }
- </style>
|