file-type

Java监控触发器配置教程

ZIP文件

下载需积分: 9 | 12MB | 更新于2025-08-09 | 199 浏览量 | 0 下载量 举报 收藏
download 立即下载
### 知识点详解 #### 标题解析:“monitor-trigger” 从标题“monitor-trigger”可以推断,本文档可能与监控机制中的“触发器”相关。触发器通常在数据库系统中被定义为数据库表上的特殊存储过程,它会在数据发生变更(如INSERT, UPDATE, DELETE)时自动执行。通过这个配置描述,可以推断该触发器是用于监控数据库表(如本文中的“PUBLIC.PERSONS”表)的数据变化,以便于执行某些操作,如记录日志、数据验证或自动更新其他数据库表等。 #### 描述解析:“配置” 描述部分提供了在数据库(在这里是HSQLDB)中配置触发器的具体步骤,这些步骤涉及了从构建、部署到数据库操作的完整流程。 1. **预配置zip存档的处理** - 如果使用预先配置好的zip文件,用户可以直接跳过后续的配置步骤。 2. **项目构建** - 要求用户跳转到项目的根目录下。 - 执行命令`mvn clean install`来构建项目。这个命令是Maven构建工具中用于清理上一次构建的产物并重新进行项目的安装过程。 3. **部署与数据库准备** - 将构建生成的jar文件复制到`hsqldb`文件夹中的`lib`文件夹下。 - 启动HSQL数据库控制台,并创建名为“testdb”的数据库实例。HSQLDB是一种开源的Java数据库,用于快速创建轻量级的数据库应用。 - 在HSQL控制台中运行SQL语句创建内存数据库表`PUBLIC.PERSONS`,其中包含个人信息字段。 4. **触发器配置** - 清除可能已经存在的触发器,这些触发器分别对应于插入、更新和删除操作。 - 创建一个新的触发器`people_insert_trigger`,其触发条件为在`PUBLIC.PERSONS`表上执行插入(INSERT)操作后。 - 描述中并未提供完整的触发器创建语句,但根据上下文,可以猜测触发器可能用于执行与插入操作相关的监控任务。 #### 标签解析:“Java” 该标签表明,在整个配置过程中,可能使用了Java语言或Java相关的开发环境。具体来说,构建项目使用的Maven是Java生态中常用的项目管理工具,而HSQLDB虽是用Java编写的,但通常不作为Java应用程序的一部分,更多是作为Java项目中的嵌入式数据库存在。考虑到这一点,可以判断该项目的主语言是Java,尽管触发器的配置是直接在HSQLDB中完成的。 #### 文件压缩包名称解析:“monitor-trigger-master” 文件压缩包的名称“monitor-trigger-master”可能表明了这是一个主版本或核心版本的监控触发器项目。名称中的“master”通常在软件开发中指代主分支,意味着这可能是项目的主干代码或主版本。这个命名通常在使用版本控制系统(如Git)时被采用,用于区分不同版本的项目代码。 ### 综合总结 综合上述信息,本文档主要涉及到在Java项目中配置数据库触发器的详细步骤。触发器是一种数据库机制,允许用户定义在特定数据库事件发生时自动执行的代码,用于自动化复杂的数据库操作。本文档中的触发器配置步骤适用于HSQLDB数据库,但是概念上适用于任何支持触发器的数据库管理系统。 在实际操作过程中,开发人员需要根据项目根目录下的构建脚本构建项目,并将产出的jar包部署到合适的路径。通过HSQLDB的控制台工具来创建数据库和表,然后编写触发器代码以响应数据库表的插入事件。这种配置方式可以广泛应用于需要数据变化监控和自动化处理的场景,例如,触发器可以用来记录数据变更日志、更新其他表的关联数据、或者对数据变更进行合法性校验等。 最后,文件的命名规则和项目结构通常会遵循开发者或团队的约定,而在此情境下,“monitor-trigger-master”很可能是一个主版本库的命名,代表这是监控触发器项目的主线版本。

相关推荐

filetype

  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-folder-line"></use></svg>
    develop/api
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-folder-line"></use></svg>
    cc
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    agenda.adoc
    + 79- 47
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    bot-asr.adoc
    + 3- 3
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    cache.adoc
    + 7- 8
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    call.adoc
    + 225- 24
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    cdr-ib.adoc
    + 5- 5
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    cdr-new-ib.adoc
    + 45- 19
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    cdr-new-ob.adoc
    + 2- 2
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    cdr-ob.adoc
    + 1- 4
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    cdr-webcall.adoc
    + 10- 5
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    cloud-number.adoc
    + 57- 17
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    comment.adoc
    + 1- 1
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-client.adoc
    + 299- 79
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-enterprise-pause.adoc
    + 38- 16
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-exten.adoc
    + 153- 43
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-global.adoc
    + 12
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-ivr.adoc
    + 2- 6
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-number.adoc
    + 70- 41
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-queue.adoc
    + 135- 52
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    config-restrict-tel.adoc
    + 63- 29
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    enterprise-info.adoc
    + 12- 3
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    intelligent.adoc
    + 2- 2
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    investigation.adoc
    + 8- 7
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    ivr-script.adoc
    + 2- 2
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    log.adoc
    + 17- 8
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    manage.adoc
    + 101- 21
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    monitor.adoc
    + 44- 28
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    record.adoc
    + 1- 1
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    report.adoc
    + 225- 119
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    sms.adoc
    + 119- 54
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    sqc-asr.adoc
    + 34- 11
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    sso-login.adoc
    + 1- 1
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    task-property.adoc
    + 10- 2
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    voice-mail.adoc
    + 9- 3
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    wm_rtc.adoc
    + 38- 13
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    ws-login.adoc
    + 12- 3
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-folder-line"></use></svg>
    include
  • <svg viewBox="0 0 1024 1024"><use xlink:href="#yunxiao-modified-code-file-line"></use></svg>
    preface-cc.adoc
    + 4- 1
这是我插件所控制pr页面中文件相关代码,是否存在这样一种情况,只有点击文件之后才会进行创建从而生成该文件的diff,

filetype

tidb pd启动报错日志:[2025/08/07 10:09:05.941 +08:00] [INFO] [serve.go:103] ["ready to serve client requests"] [2025/08/07 10:09:05.942 +08:00] [INFO] [health.go:61] ["grpc service status changed"] [service=] [status=SERVING] [2025/08/07 10:09:05.943 +08:00] [INFO] [registry.go:69] ["gRPC service already registered"] [prefix=pd-14.22.74.132-2379] [service-name=MetaStorage] [2025/08/07 10:09:05.943 +08:00] [INFO] [registry.go:69] ["gRPC service already registered"] [prefix=pd-14.22.74.132-2379] [service-name=ResourceManager] [2025/08/07 10:09:05.943 +08:00] [INFO] [serve.go:187] ["serving client traffic insecurely; this is strongly discouraged!"] [traffic=grpc+http] [address="[::]:2379"] [2025/08/07 10:09:12.951 +08:00] [ERROR] [etcdutil.go:94] ["failed to get cluster from remote"] [error="[PD:etcd:ErrEtcdGetCluster]etcd get cluster from remote peer failed: coul [2025/08/07 10:09:22.954 +08:00] [ERROR] [health_checker.go:455] ["failed to list members"] [source=server-etcd-client] [error="[PD:etcd:ErrEtcdMemberList]rpc error: code = Deadext deadline exceeded"] [2025/08/07 10:09:22.954 +08:00] [WARN] [health_checker.go:351] ["no available etcd endpoint returned by etcd cluster"] [source=server-etcd-client] [2025/08/07 10:09:22.954 +08:00] [FATAL] [main.go:289] ["run server failed"] [error="[PD:etcd:ErrEtcdMemberList]rpc error: code = DeadlineExceeded desc = context deadline exceedn\t/workspace/source/pd/cmd/pd-server/main.go:289\nmain.createServerWrapper\n\t/workspace/source/pd/cmd/pd-server/main.go:194\ngithub.com/spf13/cobra.(*Command).execute\n\t/rootxecuteC\n\t/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115\ngithub.com/spf13/cobra.(*Command).Execute\n\t/root/go/pkg/mod/github.com/spf13/[email protected]/command.go/go/src/runtime/proc.go:272"] [2025/08/07 10:09:38.159 +08:00] [INFO] [meminfo.go:213] ["use physical memory hook"] [cgroupMemorySize=9223372036854771712] [physicalMemorySize=66998362112] [2025/08/07 10:09:38.159 +08:00] [INFO] [versioninfo.go:98] ["Welcome to Placement Driver (PD)"] [2025/08/07 10:09:38.159 +08:00] [INFO] [versioninfo.go:99] [PD] [release-version=v8.5.1] [2025/08/07 10:09:38.159 +08:00] [INFO] [versioninfo.go:100] [PD] [edition=Community] [2025/08/07 10:09:38.159 +08:00] [INFO] [versioninfo.go:101] [PD] [git-hash=5036cc277fc8c0e7fa1219265ae407de80b950b7] [2025/08/07 10:09:38.159 +08:00] [INFO] [versioninfo.go:102] [PD] [git-branch=HEAD] [2025/08/07 10:09:38.159 +08:00] [INFO] [versioninfo.go:103] [PD] [utc-build-time="2025-01-10 06:52:08"] [2025/08/07 10:09:38.159 +08:00] [INFO] [metricutil.go:86] ["disable Prometheus push client"] [2025/08/07 10:09:38.159 +08:00] [INFO] [server.go:250] ["PD config"] [config="{\"client-urls\":\"http://0.0.0.0:2379\",\"peer-urls\":\"http://0.0.0.0:2380\",\"advertise-client-me\":\"pd-14.22.74.132-2379\",\"data-dir\":\"/u01/tidb/tidb-data/pd-2379\",\"force-new-cluster\":false,\"enable-grpc-gateway\":true,\"initial-cluster\":\"pd-14.22.74.132-2379=htster\",\"join\":\"\",\"lease\":3,\"log\":{\"level\":\"info\",\"format\":\"text\",\"disable-timestamp\":false,\"file\":{\"filename\":\"/u01/tidb/tidb-deploy/pd-2379/log/pd.log\",se,\"disable-stacktrace\":false,\"disable-error-verbose\":true,\"sampling\":null,\"error-output-path\":\"\"},\"max-concurrent-tso-proxy-streamings\":5000,\"tso-proxy-recv-from-cms\",\"enable-local-tso\":false,\"metric\":{\"job\":\"pd-14.22.74.132-2379\",\"address\":\"\",\"interval\":\"15s\"},\"schedule\":{\"max-snapshot-count\":64,\"max-pending-peer-co1h0m0s\",\"switch-witness-interval\":\"1h0m0s\",\"enable-one-way-merge\":\"false\",\"enable-cross-table-merge\":\"true\",\"patrol-region-interval\":\"10ms\",\"max-store-down-timchedule-policy\":\"count\",\"region-schedule-limit\":2048,\"witness-schedule-limit\":4,\"replica-schedule-limit\":64,\"merge-schedule-limit\":8,\"hot-region-schedule-limit\":4,\-ratio\":0.8,\"high-space-ratio\":0.7,\"region-score-formula-version\":\"v2\",\"scheduler-max-waiting-operator\":5,\"enable-remove-down-replica\":\"true\",\"enable-replace-offlirue\",\"enable-location-replacement\":\"true\",\"enable-debug-metrics\":\"false\",\"enable-joint-consensus\":\"true\",\"enable-tikv-split-region\":\"true\",\"enable-heartbeat-br[{\"type\":\"balance-region\",\"args\":null,\"disable\":false,\"args-payload\":\"\"},{\"type\":\"balance-leader\",\"args\":null,\"disable\":false,\"args-payload\":\"\"},{\"type\w-store\",\"args\":null,\"disable\":false,\"args-payload\":\"\"}],\"hot-regions-write-interval\":\"10m0s\",\"hot-regions-reserved-days\":7,\"max-movable-hot-peer-size\":512,\"enratio-threshold\":0.3,\"store-limit-version\":\"v1\",\"patrol-region-worker-count\":1},\"replication\":{\"max-replicas\":3,\"location-labels\":\"host\",\"strictly-match-label\":olation-level\":\"\"},\"pd-server\":{\"use-region-storage\":\"true\",\"max-gap-reset-ts\":\"24h0m0s\",\"key-type\":\"table\",\"runtime-services\":\"\",\"metric-storage\":\"\",\"\":\"1s\",\"server-memory-limit\":0,\"server-memory-limit-gc-trigger\":0.7,\"enable-gogc-tuner\":\"false\",\"gc-tuner-threshold\":0.6,\"block-safe-point-v1\":\"false\"},\"cluste:\"periodic\",\"auto-compaction-retention-v2\":\"1h\",\"tick-interval\":\"500ms\",\"election-interval\":\"3s\",\"enable-prevote\":true,\"max-request-bytes\":157286400,\"securityABytes\":null,\"SSLCertBytes\":null,\"SSLKEYBytes\":null,\"redact-info-log\":false,\"encryption\":{\"data-encryption-method\":\"plaintext\",\"data-key-rotation-period\":\"168h0m,\"path\":\"\"}}},\"label-property\":null,\"dashboard\":{\"tidb-cacert-path\":\"\",\"tidb-cert-path\":\"\",\"tidb-key-path\":\"\",\"public-path-prefix\":\"\",\"internal-proxy\":alse},\"replication-mode\":{\"replication-mode\":\"majority\",\"dr-auto-sync\":{\"label-key\":\"\",\"primary\":\"\",\"dr\":\"\",\"primary-replicas\":0,\"dr-replicas\":0,\"wait-skeyspace\":{\"pre-alloc\":null,\"wait-region-split\":true,\"wait-region-split-timeout\":\"30s\",\"check-region-split-interval\":\"50ms\"},\"micro-service\":{\"enable-scheduling-ration\":\"30s\",\"ltb-token-rpc-max-delay\":\"1s\",\"request-unit\":{\"read-base-cost\":0.125,\"read-per-batch-base-cost\":0.5,\"read-cost-per-byte\":0.0000152587890625,\"writeu-ms-cost\":0.3333333333333333},\"enable-controller-trace-log\":\"false\"}}"] [2025/08/07 10:09:38.165 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/pd/api/v1] [2025/08/07 10:09:38.165 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/pd/api/v2/] [2025/08/07 10:09:38.165 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/autoscaling] [2025/08/07 10:09:38.165 +08:00] [INFO] [distro.go:51] ["using distribution strings"] [strings={}] [2025/08/07 10:09:38.166 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/dashboard/api/] [2025/08/07 10:09:38.166 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/dashboard/] [2025/08/07 10:09:38.166 +08:00] [INFO] [registry.go:97] ["restful API service registered successfully"] [prefix=pd-14.22.74.132-2379] [service-name=MetaStorage] [2025/08/07 10:09:38.166 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/resource-manager/api/v1/] [2025/08/07 10:09:38.166 +08:00] [INFO] [registry.go:97] ["restful API service registered successfully"] [prefix=pd-14.22.74.132-2379] [service-name=ResourceManager] [2025/08/07 10:09:38.166 +08:00] [WARN] [config.go:687] ["Running http and grpc server on single port. This is not recommended for production."] [2025/08/07 10:09:38.166 +08:00] [INFO] [etcd.go:128] ["configuring peer listeners"] [listen-peer-urls="[http://0.0.0.0:2380]"] [2025/08/07 10:09:38.166 +08:00] [INFO] [systimemon.go:30] ["start system time monitor"] [2025/08/07 10:09:38.167 +08:00] [INFO] [etcd.go:136] ["configuring client listeners"] [listen-client-urls="[http://0.0.0.0:2379]"] [2025/08/07 10:09:38.167 +08:00] [INFO] [etcd.go:620] ["pprof is enabled"] [path=/debug/pprof] [2025/08/07 10:09:38.167 +08:00] [INFO] [etcd.go:310] ["starting an etcd server"] [etcd-version=3.5.15] [git-sha="Not provided (use ./build instead of go build)"] [go-version=goed=true] [name=pd-14.22.74.132-2379] [data-dir=/u01/tidb/tidb-data/pd-2379] [wal-dir=] [wal-dir-dedicated=] [member-dir=/u01/tidb/tidb-data/pd-2379/member] [force-new-cluster=fanapshot-count=100000] [max-wals=5] [max-snapshots=5] [snapshot-catchup-entries=5000] [initial-advertise-peer-urls="[http://14.22.74.132:2380]"] [listen-peer-urls="[http://0.0.0..0.0.0:2379]"] [listen-metrics-urls="[]"] [cors="[*]"] [host-whitelist="[*]"] [initial-cluster=] [initial-cluster-state=new] [initial-cluster-token=] [quota-backend-bytes=858993ial-corrupt-check=false] [corrupt-check-time-interval=0s] [compact-check-time-enabled=false] [compact-check-time-interval=1m0s] [auto-compaction-mode=periodic] [auto-compaction-grade-check-interval=5s] [2025/08/07 10:09:38.167 +08:00] [WARN] [server.go:344] ["exceeded recommended request limit"] [max-request-bytes=157286400] [max-request-size="157 MB"] [recommended-request-byt [2025/08/07 10:09:38.167 +08:00] [WARN] [fileutil.go:53] ["check file permission"] [error="directory \"/u01/tidb/tidb-data/pd-2379\" exist, but the permission is \"drwxrwxrwx\".data"] [2025/08/07 10:09:38.167 +08:00] [WARN] [fileutil.go:53] ["check file permission"] [error="directory \"/u01/tidb/tidb-data/pd-2379/member/snap\" exist, but the permission is \"dcess to the data"] [2025/08/07 10:09:38.169 +08:00] [INFO] [backend.go:81] ["opened backend db"] [path=/u01/tidb/tidb-data/pd-2379/member/snap/db] [took=1.618732ms] [2025/08/07 10:09:38.173 +08:00] [INFO] [server.go:532] ["No snapshot found. Recovering WAL from scratch!"] [2025/08/07 10:09:38.179 +08:00] [INFO] [raft.go:530] ["restarting local member"] [cluster-id=668837b4654a6c36] [local-member-id=9f2c47b40885d021] [commit-index=4680] [2025/08/07 10:09:38.181 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 switched to configuration voters=()"] [2025/08/07 10:09:38.181 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 became follower at term 2340"] [2025/08/07 10:09:38.181 +08:00] [INFO] [raft] [zap_raft.go:77] ["newRaft 9f2c47b40885d021 [peers: [], term: 2340, commit: 4680, applied: 0, lastindex: 4680, lastterm: 2340]"] [2025/08/07 10:09:38.181 +08:00] [WARN] [fileutil.go:53] ["check file permission"] [error="directory \"/u01/tidb/tidb-data/pd-2379/member\" exist, but the permission is \"drwxrwto the data"] [2025/08/07 10:09:38.184 +08:00] [WARN] [store.go:1241] ["simple token is not cryptographically signed"] [2025/08/07 10:09:38.186 +08:00] [INFO] [kvstore.go:418] ["kvstore restored"] [current-rev=1] [2025/08/07 10:09:38.188 +08:00] [INFO] [quota.go:117] ["enabled backend quota"] [quota-name=v3-applier] [quota-size-bytes=8589934592] [quota-size="8.6 GB"] [2025/08/07 10:09:38.190 +08:00] [INFO] [server.go:867] ["starting etcd server"] [local-member-id=9f2c47b40885d021] [local-server-version=3.5.15] [cluster-version=to_be_decided] [2025/08/07 10:09:38.190 +08:00] [INFO] [server.go:767] ["starting initial election tick advance"] [election-ticks=6] [2025/08/07 10:09:38.190 +08:00] [INFO] [purge.go:50] ["started to purge file"] [dir=/u01/tidb/tidb-data/pd-2379/member/snap] [suffix=snap.db] [max=5] [interval=30s] [2025/08/07 10:09:38.190 +08:00] [INFO] [purge.go:50] ["started to purge file"] [dir=/u01/tidb/tidb-data/pd-2379/member/snap] [suffix=snap] [max=5] [interval=30s] [2025/08/07 10:09:38.190 +08:00] [INFO] [health.go:61] ["grpc service status changed"] [service=] [status=SERVING] [2025/08/07 10:09:38.190 +08:00] [INFO] [purge.go:50] ["started to purge file"] [dir=/u01/tidb/tidb-data/pd-2379/member/wal] [suffix=wal] [max=5] [interval=30s] [2025/08/07 10:09:38.191 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 switched to configuration voters=(11469621189568483361)"] [2025/08/07 10:09:38.191 +08:00] [INFO] [cluster.go:421] ["added member"] [cluster-id=668837b4654a6c36] [local-member-id=9f2c47b40885d021] [added-peer-id=9f2c47b40885d021] [adde [2025/08/07 10:09:38.191 +08:00] [INFO] [cluster.go:584] ["set initial cluster version"] [cluster-id=668837b4654a6c36] [local-member-id=9f2c47b40885d021] [cluster-version=3.5] [2025/08/07 10:09:38.191 +08:00] [INFO] [capability.go:75] ["enabled capabilities for version"] [cluster-version=3.5] [2025/08/07 10:09:38.193 +08:00] [INFO] [etcd.go:279] ["now serving peer/client/metrics"] [local-member-id=9f2c47b40885d021] [initial-advertise-peer-urls="[http://14.22.74.132:22:2379]"] [listen-client-urls="[http://0.0.0.0:2379]"] [listen-metrics-urls="[]"] [2025/08/07 10:09:38.193 +08:00] [INFO] [etcd.go:599] ["serving peer traffic"] [address="[::]:2380"] [2025/08/07 10:09:38.193 +08:00] [INFO] [etcd.go:571] [cmux::serve] [address="[::]:2380"] [2025/08/07 10:09:43.183 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 is starting a new election at term 2340"] [2025/08/07 10:09:43.183 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 became pre-candidate at term 2340"] [2025/08/07 10:09:43.183 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 received MsgPreVoteResp from 9f2c47b40885d021 at term 2340"] [2025/08/07 10:09:43.183 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 became candidate at term 2341"] [2025/08/07 10:09:43.183 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 received MsgVoteResp from 9f2c47b40885d021 at term 2341"] [2025/08/07 10:09:43.183 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 became leader at term 2341"] [2025/08/07 10:09:43.183 +08:00] [INFO] [raft] [zap_raft.go:77] ["raft.node: 9f2c47b40885d021 elected leader 9f2c47b40885d021 at term 2341"] [2025/08/07 10:09:43.186 +08:00] [INFO] [server.go:2118] ["published local member to cluster through raft"] [local-member-id=9f2c47b40885d021] [local-member-attributes="{Name:pd0885d021/attributes] [cluster-id=668837b4654a6c36] [publish-timeout=11s] [2025/08/07 10:09:43.186 +08:00] [INFO] [serve.go:103] ["ready to serve client requests"] [2025/08/07 10:09:43.186 +08:00] [INFO] [health.go:61] ["grpc service status changed"] [service=] [status=SERVING] [2025/08/07 10:09:43.187 +08:00] [INFO] [registry.go:69] ["gRPC service already registered"] [prefix=pd-14.22.74.132-2379] [service-name=MetaStorage] [2025/08/07 10:09:43.187 +08:00] [INFO] [registry.go:69] ["gRPC service already registered"] [prefix=pd-14.22.74.132-2379] [service-name=ResourceManager] [2025/08/07 10:09:43.187 +08:00] [INFO] [serve.go:187] ["serving client traffic insecurely; this is strongly discouraged!"] [traffic=grpc+http] [address="[::]:2379"] [2025/08/07 10:09:48.194 +08:00] [ERROR] [etcdutil.go:94] ["failed to get cluster from remote"] [error="[PD:etcd:ErrEtcdGetCluster]etcd get cluster from remote peer failed: coul [2025/08/07 10:09:58.196 +08:00] [ERROR] [health_checker.go:455] ["failed to list members"] [source=server-etcd-client] [error="[PD:etcd:ErrEtcdMemberList]rpc error: code = Deadext deadline exceeded"] [2025/08/07 10:09:58.196 +08:00] [WARN] [health_checker.go:351] ["no available etcd endpoint returned by etcd cluster"] [source=server-etcd-client] [2025/08/07 10:09:58.196 +08:00] [ERROR] [health_checker.go:455] ["failed to list members"] [source=election-etcd-client] [error="[PD:etcd:ErrEtcdMemberList]rpc error: code = Dentext deadline exceeded"] [2025/08/07 10:09:58.196 +08:00] [WARN] [health_checker.go:351] ["no available etcd endpoint returned by etcd cluster"] [source=election-etcd-client] [2025/08/07 10:09:58.196 +08:00] [FATAL] [main.go:289] ["run server failed"] [error="[PD:etcd:ErrEtcdMemberList]rpc error: code = DeadlineExceeded desc = context deadline exceedn\t/workspace/source/pd/cmd/pd-server/main.go:289\nmain.createServerWrapper\n\t/workspace/source/pd/cmd/pd-server/main.go:194\ngithub.com/spf13/cobra.(*Command).execute\n\t/rootxecuteC\n\t/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:1115\ngithub.com/spf13/cobra.(*Command).Execute\n\t/root/go/pkg/mod/github.com/spf13/[email protected]/command.go/go/src/runtime/proc.go:272"] [2025/08/07 10:10:13.404 +08:00] [INFO] [meminfo.go:213] ["use physical memory hook"] [cgroupMemorySize=9223372036854771712] [physicalMemorySize=66998362112] [2025/08/07 10:10:13.404 +08:00] [INFO] [versioninfo.go:98] ["Welcome to Placement Driver (PD)"] [2025/08/07 10:10:13.404 +08:00] [INFO] [versioninfo.go:99] [PD] [release-version=v8.5.1] [2025/08/07 10:10:13.404 +08:00] [INFO] [versioninfo.go:100] [PD] [edition=Community] [2025/08/07 10:10:13.404 +08:00] [INFO] [versioninfo.go:101] [PD] [git-hash=5036cc277fc8c0e7fa1219265ae407de80b950b7] [2025/08/07 10:10:13.404 +08:00] [INFO] [versioninfo.go:102] [PD] [git-branch=HEAD] [2025/08/07 10:10:13.404 +08:00] [INFO] [versioninfo.go:103] [PD] [utc-build-time="2025-01-10 06:52:08"] [2025/08/07 10:10:13.404 +08:00] [INFO] [metricutil.go:86] ["disable Prometheus push client"] [2025/08/07 10:10:13.404 +08:00] [INFO] [server.go:250] ["PD config"] [config="{\"client-urls\":\"http://0.0.0.0:2379\",\"peer-urls\":\"http://0.0.0.0:2380\",\"advertise-client-me\":\"pd-14.22.74.132-2379\",\"data-dir\":\"/u01/tidb/tidb-data/pd-2379\",\"force-new-cluster\":false,\"enable-grpc-gateway\":true,\"initial-cluster\":\"pd-14.22.74.132-2379=htster\",\"join\":\"\",\"lease\":3,\"log\":{\"level\":\"info\",\"format\":\"text\",\"disable-timestamp\":false,\"file\":{\"filename\":\"/u01/tidb/tidb-deploy/pd-2379/log/pd.log\",se,\"disable-stacktrace\":false,\"disable-error-verbose\":true,\"sampling\":null,\"error-output-path\":\"\"},\"max-concurrent-tso-proxy-streamings\":5000,\"tso-proxy-recv-from-cms\",\"enable-local-tso\":false,\"metric\":{\"job\":\"pd-14.22.74.132-2379\",\"address\":\"\",\"interval\":\"15s\"},\"schedule\":{\"max-snapshot-count\":64,\"max-pending-peer-co1h0m0s\",\"switch-witness-interval\":\"1h0m0s\",\"enable-one-way-merge\":\"false\",\"enable-cross-table-merge\":\"true\",\"patrol-region-interval\":\"10ms\",\"max-store-down-timchedule-policy\":\"count\",\"region-schedule-limit\":2048,\"witness-schedule-limit\":4,\"replica-schedule-limit\":64,\"merge-schedule-limit\":8,\"hot-region-schedule-limit\":4,\-ratio\":0.8,\"high-space-ratio\":0.7,\"region-score-formula-version\":\"v2\",\"scheduler-max-waiting-operator\":5,\"enable-remove-down-replica\":\"true\",\"enable-replace-offlirue\",\"enable-location-replacement\":\"true\",\"enable-debug-metrics\":\"false\",\"enable-joint-consensus\":\"true\",\"enable-tikv-split-region\":\"true\",\"enable-heartbeat-br[{\"type\":\"balance-region\",\"args\":null,\"disable\":false,\"args-payload\":\"\"},{\"type\":\"balance-leader\",\"args\":null,\"disable\":false,\"args-payload\":\"\"},{\"type\w-store\",\"args\":null,\"disable\":false,\"args-payload\":\"\"}],\"hot-regions-write-interval\":\"10m0s\",\"hot-regions-reserved-days\":7,\"max-movable-hot-peer-size\":512,\"enratio-threshold\":0.3,\"store-limit-version\":\"v1\",\"patrol-region-worker-count\":1},\"replication\":{\"max-replicas\":3,\"location-labels\":\"host\",\"strictly-match-label\":olation-level\":\"\"},\"pd-server\":{\"use-region-storage\":\"true\",\"max-gap-reset-ts\":\"24h0m0s\",\"key-type\":\"table\",\"runtime-services\":\"\",\"metric-storage\":\"\",\"\":\"1s\",\"server-memory-limit\":0,\"server-memory-limit-gc-trigger\":0.7,\"enable-gogc-tuner\":\"false\",\"gc-tuner-threshold\":0.6,\"block-safe-point-v1\":\"false\"},\"cluste:\"periodic\",\"auto-compaction-retention-v2\":\"1h\",\"tick-interval\":\"500ms\",\"election-interval\":\"3s\",\"enable-prevote\":true,\"max-request-bytes\":157286400,\"securityABytes\":null,\"SSLCertBytes\":null,\"SSLKEYBytes\":null,\"redact-info-log\":false,\"encryption\":{\"data-encryption-method\":\"plaintext\",\"data-key-rotation-period\":\"168h0m,\"path\":\"\"}}},\"label-property\":null,\"dashboard\":{\"tidb-cacert-path\":\"\",\"tidb-cert-path\":\"\",\"tidb-key-path\":\"\",\"public-path-prefix\":\"\",\"internal-proxy\":alse},\"replication-mode\":{\"replication-mode\":\"majority\",\"dr-auto-sync\":{\"label-key\":\"\",\"primary\":\"\",\"dr\":\"\",\"primary-replicas\":0,\"dr-replicas\":0,\"wait-skeyspace\":{\"pre-alloc\":null,\"wait-region-split\":true,\"wait-region-split-timeout\":\"30s\",\"check-region-split-interval\":\"50ms\"},\"micro-service\":{\"enable-scheduling-ration\":\"30s\",\"ltb-token-rpc-max-delay\":\"1s\",\"request-unit\":{\"read-base-cost\":0.125,\"read-per-batch-base-cost\":0.5,\"read-cost-per-byte\":0.0000152587890625,\"writeu-ms-cost\":0.3333333333333333},\"enable-controller-trace-log\":\"false\"}}"] [2025/08/07 10:10:13.410 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/pd/api/v1] [2025/08/07 10:10:13.410 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/pd/api/v2/] [2025/08/07 10:10:13.411 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/autoscaling] [2025/08/07 10:10:13.411 +08:00] [INFO] [distro.go:51] ["using distribution strings"] [strings={}] [2025/08/07 10:10:13.412 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/dashboard/api/] [2025/08/07 10:10:13.412 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/dashboard/] [2025/08/07 10:10:13.412 +08:00] [INFO] [registry.go:97] ["restful API service registered successfully"] [prefix=pd-14.22.74.132-2379] [service-name=MetaStorage] [2025/08/07 10:10:13.412 +08:00] [INFO] [apiutil.go:437] ["register REST path"] [path=/resource-manager/api/v1/] [2025/08/07 10:10:13.412 +08:00] [INFO] [registry.go:97] ["restful API service registered successfully"] [prefix=pd-14.22.74.132-2379] [service-name=ResourceManager] [2025/08/07 10:10:13.413 +08:00] [WARN] [config.go:687] ["Running http and grpc server on single port. This is not recommended for production."] [2025/08/07 10:10:13.413 +08:00] [INFO] [etcd.go:128] ["configuring peer listeners"] [listen-peer-urls="[http://0.0.0.0:2380]"] [2025/08/07 10:10:13.413 +08:00] [INFO] [systimemon.go:30] ["start system time monitor"] [2025/08/07 10:10:13.413 +08:00] [INFO] [etcd.go:136] ["configuring client listeners"] [listen-client-urls="[http://0.0.0.0:2379]"] [2025/08/07 10:10:13.413 +08:00] [INFO] [etcd.go:620] ["pprof is enabled"] [path=/debug/pprof] [2025/08/07 10:10:13.413 +08:00] [INFO] [etcd.go:310] ["starting an etcd server"] [etcd-version=3.5.15] [git-sha="Not provided (use ./build instead of go build)"] [go-version=goed=true] [name=pd-14.22.74.132-2379] [data-dir=/u01/tidb/tidb-data/pd-2379] [wal-dir=] [wal-dir-dedicated=] [member-dir=/u01/tidb/tidb-data/pd-2379/member] [force-new-cluster=fanapshot-count=100000] [max-wals=5] [max-snapshots=5] [snapshot-catchup-entries=5000] [initial-advertise-peer-urls="[http://14.22.74.132:2380]"] [listen-peer-urls="[http://0.0.0..0.0.0:2379]"] [listen-metrics-urls="[]"] [cors="[*]"] [host-whitelist="[*]"] [initial-cluster=] [initial-cluster-state=new] [initial-cluster-token=] [quota-backend-bytes=858993ial-corrupt-check=false] [corrupt-check-time-interval=0s] [compact-check-time-enabled=false] [compact-check-time-interval=1m0s] [auto-compaction-mode=periodic] [auto-compaction-grade-check-interval=5s] [2025/08/07 10:10:13.413 +08:00] [WARN] [server.go:344] ["exceeded recommended request limit"] [max-request-bytes=157286400] [max-request-size="157 MB"] [recommended-request-byt [2025/08/07 10:10:13.413 +08:00] [WARN] [fileutil.go:53] ["check file permission"] [error="directory \"/u01/tidb/tidb-data/pd-2379\" exist, but the permission is \"drwxrwxrwx\".data"] [2025/08/07 10:10:13.413 +08:00] [WARN] [fileutil.go:53] ["check file permission"] [error="directory \"/u01/tidb/tidb-data/pd-2379/member/snap\" exist, but the permission is \"dcess to the data"] [2025/08/07 10:10:13.415 +08:00] [INFO] [backend.go:81] ["opened backend db"] [path=/u01/tidb/tidb-data/pd-2379/member/snap/db] [took=1.667902ms] [2025/08/07 10:10:13.419 +08:00] [INFO] [server.go:532] ["No snapshot found. Recovering WAL from scratch!"] [2025/08/07 10:10:13.425 +08:00] [INFO] [raft.go:530] ["restarting local member"] [cluster-id=668837b4654a6c36] [local-member-id=9f2c47b40885d021] [commit-index=4682] [2025/08/07 10:10:13.426 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 switched to configuration voters=()"] [2025/08/07 10:10:13.426 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 became follower at term 2341"] [2025/08/07 10:10:13.426 +08:00] [INFO] [raft] [zap_raft.go:77] ["newRaft 9f2c47b40885d021 [peers: [], term: 2341, commit: 4682, applied: 0, lastindex: 4682, lastterm: 2341]"] [2025/08/07 10:10:13.426 +08:00] [WARN] [fileutil.go:53] ["check file permission"] [error="directory \"/u01/tidb/tidb-data/pd-2379/member\" exist, but the permission is \"drwxrwto the data"] [2025/08/07 10:10:13.428 +08:00] [WARN] [store.go:1241] ["simple token is not cryptographically signed"] [2025/08/07 10:10:13.430 +08:00] [INFO] [kvstore.go:418] ["kvstore restored"] [current-rev=1] [2025/08/07 10:10:13.432 +08:00] [INFO] [quota.go:117] ["enabled backend quota"] [quota-name=v3-applier] [quota-size-bytes=8589934592] [quota-size="8.6 GB"] [2025/08/07 10:10:13.434 +08:00] [INFO] [server.go:867] ["starting etcd server"] [local-member-id=9f2c47b40885d021] [local-server-version=3.5.15] [cluster-version=to_be_decided] [2025/08/07 10:10:13.434 +08:00] [INFO] [purge.go:50] ["started to purge file"] [dir=/u01/tidb/tidb-data/pd-2379/member/snap] [suffix=snap.db] [max=5] [interval=30s] [2025/08/07 10:10:13.434 +08:00] [INFO] [purge.go:50] ["started to purge file"] [dir=/u01/tidb/tidb-data/pd-2379/member/snap] [suffix=snap] [max=5] [interval=30s] [2025/08/07 10:10:13.434 +08:00] [INFO] [server.go:767] ["starting initial election tick advance"] [election-ticks=6] [2025/08/07 10:10:13.434 +08:00] [INFO] [health.go:61] ["grpc service status changed"] [service=] [status=SERVING] [2025/08/07 10:10:13.434 +08:00] [INFO] [purge.go:50] ["started to purge file"] [dir=/u01/tidb/tidb-data/pd-2379/member/wal] [suffix=wal] [max=5] [interval=30s] [2025/08/07 10:10:13.435 +08:00] [INFO] [raft] [zap_raft.go:77] ["9f2c47b40885d021 switched to configuration voters=(11469621189568483361)"] [2025/08/07 10:10:13.435 +08:00] [INFO] [cluster.go:421] ["added member"] [cluster-id=668837b4654a6c36] [local-member-id=9f2c47b40885d021] [added-peer-id=9f2c47b40885d021] [adde [2025/08/07 10:10:13.435 +08:00] [INFO] [cluster.go:584] ["set initial cluster version"] [cluster-id=668837b4654a6c36] [local-member-id=9f2c47b40885d021] [cluster-version=3.5] [2025/08/07 10:10:13.435 +08:00] [INFO] [capability.go:75] ["enabled capabilities for version"] [cluster-version=3.5] [2025/08/07 10:10:13.437 +08:00] [INFO] [etcd.go:599] ["serving peer traffic"] [address="[::]:2380"] [2025/08/07 10:10:13.437 +08:00] [INFO] [etcd.go:571] [cmux::serve] [address="[::]:2380"] [2025/08/07 10:10:13.437 +08:00] [INFO] [etcd.go:279] ["now serving peer/client/metrics"] [local-member-id=9f2c47b40885d021] [initial-advertise-peer-urls="[http://14.22.74.132:22:2379]"] [listen-client-urls="[http://0.0.0.0:2379]"] [listen-metrics-urls="[]"]

filetype

两个程序用的同一个OLED屏文件,写的也是同一个函数,只是前面是最简单的输出int main(void) { OLED_Init(); arm_sin_f32(23); while(1) { float six = 6; char str[40]; sprintf(str,"six = %.3f",six); OLED_ShowString(WORD_WIDTH*0,WORD_HIGH*1,(u8 *)str,WORD_SIZE); OLED_Refresh_Gram(); delay_us(100); } }而后者是加了pid用7606测电压跑buck的程序然后OLED屏就不亮了#include "stm32f4xx.h" #include "./usart/bsp_usart.h" #include "General_Tim.h" #include "delay.h" #include "sys.h" #include "PID.h" #include "math.h" #include "./adc/bsp_adc.h" #include "tim.h" #include "oled.h" #include "stdio.h" #include "stdlib.h" extern float voltage1, voltage2, voltage3; extern float Vout_actual; float Target= 25; // 目标输出电压25 float a; //extern __IO uint16_t ADC_ConvertedValue; extern uint16_t TIM_Advance_Impulse; int main(void) { TIM_Init(); PID_init(); Adc_Init(); OLED_Init(); while(1) { ADC_Read(); a= PID_DC( Target ,Vout_actual, 20.0f ); float six = 6; char str[40]; sprintf(str,"Vout_actual = %.3f",Vout_actual); OLED_ShowString(WORD_WIDTH*0,WORD_HIGH*1,(u8 *)str,WORD_SIZE); OLED_Refresh_Gram(); delay_us(100); } } /*********************************************END OF FILE**********************/下面这个buck闭环电路程序的oled屏不亮,下面是这个函数的代码#include "stm32f4xx.h" #include "./usart/bsp_usart.h" #include "delay.h" #include "sys.h" #include "PID.h" #include "math.h" #include "./adc/bsp_adc.h" #include "tim.h" #include "oled.h" #include "stdio.h" #include "stdlib.h" extern float voltage1, voltage2, voltage3; extern float Vout_actual; float Target= 25; // 目标输出电压25 float a; //extern __IO uint16_t ADC_ConvertedValue; extern uint16_t TIM_Advance_Impulse; int main(void) { OLED_Init(); // 首先初始化OLED TIM_Init(); PID_init(); Adc_Init(); while(1) { ADC_Read(); a= PID_DC( Target ,Vout_actual, 20.0f ); float six = 6; char str[40]; sprintf(str,"Vout_actual = %.3f",Vout_actual); OLED_ShowString(WORD_WIDTH*0,WORD_HIGH*1,(u8 *)str,WORD_SIZE); OLED_Refresh_Gram(); delay_us(100); sprintf(str,"six = %.3f",six); OLED_ShowString(WORD_WIDTH*0,WORD_HIGH*1,(u8 *)str,WORD_SIZE); OLED_Refresh_Gram(); delay_us(100); } } /*********************************************END OF FILE**********************/ pid文件:#include "stdio.h" #include "sys.h" #include "PID.h" //extern float V0,V1,V2; float duty=0; float pid_out=0; struct _pid { float SetSpeed; //定义设定值 float ActualSpeed; //定义实际值 float err; //定义偏差值 float err_last; //定义上一个偏差值 float Kp, Ki, Kd; //定义比例、积分、微分系数 float voltage; //定义电压值(控制执行器的变量) float integral; //定义积分值 float S; //返回值 }pid; void PID_init() { pid.SetSpeed = 0.0; pid.ActualSpeed = 0.0; pid.err = 0.0; pid.err_last = 0.0; pid.voltage = 0.0; pid.integral = 0.0; pid.Kp = 150; pid.Ki = 0.55; pid.Kd = 0; } float PID_realize(float speed, float Actual) { pid.SetSpeed = speed; //目标值 pid.ActualSpeed = Actual; //实际值 pid.err = pid.SetSpeed - pid.ActualSpeed; //误差 pid.integral += pid.err; //积分项误差相加 pid.voltage = pid.Kp * pid.err + pid.Ki * pid.integral + pid.Kd * (pid.err - pid.err_last); //计算结果 0.2*27+0.1* pid.err_last = pid.err; //更新误差 pid.S = pid.voltage * 1.0f; //计算结果 返回值 return pid.S; } float PID_DC( float goal ,float Actual,float k ) { Actual=Actual*k; pid_out = PID_realize(goal, Actual); duty+=pid_out; if(duty>=4200) duty=4200; if(duty<=-4200) duty=0; TIM_SetCompare1(TIM8,4200+duty) ; return pid_out; } pid.h #ifndef __PID_H #define __PID_H void PID_init(void);//PID参数初始化 float PID_realize(float speed, float Actual);//实现PID算法 float PID_DC( float goal ,float Actual,float k ); #endif adc模块:#include "./adc/bsp_adc.h" __IO uint16_t ADC_ConvertedValue[RHEOSTAT_NOFCHANEL]={0}; float voltage1=0, voltage2=0, voltage3=0; float Vout_actual; static void ADC_GPIO_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; /*=====================通道1======================*/ // 使能 GPIO 时钟 RCC_AHB1PeriphClockCmd(ADC_GPIO_CLK1,ENABLE); // 配置 IO GPIO_InitStructure.GPIO_Pin = ADC_GPIO_PIN1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //不上拉不下拉 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(ADC_GPIO_PORT1, &GPIO_InitStructure); /*=====================通道2======================*/ // 使能 GPIO 时钟 RCC_AHB1PeriphClockCmd(ADC_GPIO_CLK2,ENABLE); // 配置 IO GPIO_InitStructure.GPIO_Pin = ADC_GPIO_PIN2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //不上拉不下拉 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(ADC_GPIO_PORT2, &GPIO_InitStructure); /*=====================通道3=======================*/ // 使能 GPIO 时钟 RCC_AHB1PeriphClockCmd(ADC_GPIO_CLK3,ENABLE); // 配置 IO GPIO_InitStructure.GPIO_Pin = ADC_GPIO_PIN3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //不上拉不下拉 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(ADC_GPIO_PORT3, &GPIO_InitStructure); } static void ADC_Mode_Config(void) { DMA_InitTypeDef DMA_InitStructure; ADC_InitTypeDef ADC_InitStructure; ADC_CommonInitTypeDef ADC_CommonInitStructure; // ------------------DMA Init 结构体参数 初始化-------------------------- // ADC1使用DMA2,数据流0,通道0,这个是手册固定死的 // 开启DMA时钟 RCC_AHB1PeriphClockCmd(ADC_DMA_CLK, ENABLE); // 外设基址为:ADC 数据寄存器地址 DMA_InitStructure.DMA_PeripheralBaseAddr = RHEOSTAT_ADC_DR_ADDR; // 存储器地址,实际上就是一个内部SRAM的变量 DMA_InitStructure.DMA_Memory0BaseAddr = (u32)ADC_ConvertedValue; // 数据传输方向为外设到存储器 DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; // 缓冲区大小为,指一次传输的数据量 DMA_InitStructure.DMA_BufferSize = RHEOSTAT_NOFCHANEL; // 外设寄存器只有一个,地址不用递增 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; // 存储器地址固定 DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; // // 外设数据大小为半字,即两个字节 DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; // 存储器数据大小也为半字,跟外设数据大小相同 DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; // 循环传输模式 DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; // DMA 传输通道优先级为高,当使用一个DMA通道时,优先级设置不影响 DMA_InitStructure.DMA_Priority = DMA_Priority_High; // 禁止DMA FIFO ,使用直连模式 DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; // FIFO 大小,FIFO模式禁止时,这个不用配置 DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; // 选择 DMA 通道,通道存在于流中 DMA_InitStructure.DMA_Channel = ADC_DMA_CHANNEL; //初始化DMA流,流相当于一个大的管道,管道里面有很多通道 DMA_Init(ADC_DMA_STREAM, &DMA_InitStructure); // 使能DMA传输完成中断 DMA_ITConfig(ADC_DMA_STREAM, DMA_IT_TC, ENABLE); // 使能DMA流 DMA_Cmd(ADC_DMA_STREAM, ENABLE); // 开启ADC时钟 RCC_APB2PeriphClockCmd(ADC_CLK , ENABLE); // -------------------ADC Common 结构体 参数 初始化------------------------ // 独立ADC模式 ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; // 时钟为fpclk x分频 ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div4; // 禁止DMA直接访问模式 ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled; // 采样时间间隔 ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles; ADC_CommonInit(&ADC_CommonInitStructure); // -------------------ADC Init 结构体 参数 初始化-------------------------- ADC_StructInit(&ADC_InitStructure); // ADC 分辨率 ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; // 扫描模式,多通道采集需要 ADC_InitStructure.ADC_ScanConvMode = ENABLE; // 连续转换 ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //禁止外部边沿触发 ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; //外部触发通道,本例子使用软件触发,此值随便赋值即可 ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; //数据右对齐 ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //转换通道 1个 ADC_InitStructure.ADC_NbrOfConversion = RHEOSTAT_NOFCHANEL; ADC_Init(ADC_, &ADC_InitStructure); //--------------------------------------------------------------------------- // 配置 ADC 通道转换顺序和采样时间周期 ADC_RegularChannelConfig(ADC_, ADC_CHANNEL1, 1, ADC_SampleTime_15Cycles); ADC_RegularChannelConfig(ADC_, ADC_CHANNEL2, 2, ADC_SampleTime_15Cycles); ADC_RegularChannelConfig(ADC_, ADC_CHANNEL3, 3, ADC_SampleTime_15Cycles); // 使能DMA请求 after last transfer (Single-ADC mode) ADC_DMARequestAfterLastTransferCmd(ADC_, ENABLE); // 使能ADC DMA ADC_DMACmd(ADC_, ENABLE); // 使能ADC ADC_Cmd(ADC_, ENABLE); //开始adc转换,软件触发 ADC_SoftwareStartConv(ADC_); } static void ADC_NVIC_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //配置DMA NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } void ADC_Read(void) { voltage1=(float)ADC_ConvertedValue[0]*0.000244140625*3.3; voltage2=(float)ADC_ConvertedValue[1]*0.000244140625*3.3; voltage3=(float)ADC_ConvertedValue[2]*0.000244140625*3.3; Vout_actual = voltage1; } void Adc_Init(void) { ADC_GPIO_Config(); ADC_Mode_Config(); ADC_NVIC_Config(); } adc.h #ifndef __BSP_ADC_H #define __BSP_ADC_H #include "stm32f4xx.h" #define RHEOSTAT_NOFCHANEL 3 /*=====================通道1 IO======================*/ // ADC IO宏定义 #define ADC_GPIO_PORT1 GPIOA #define ADC_GPIO_PIN1 GPIO_Pin_1 #define ADC_GPIO_CLK1 RCC_AHB1Periph_GPIOA #define ADC_CHANNEL1 ADC_Channel_1 /*=====================通道2 IO ======================*/ // ADC IO宏定义 #define ADC_GPIO_PORT2 GPIOA #define ADC_GPIO_PIN2 GPIO_Pin_2 #define ADC_GPIO_CLK2 RCC_AHB1Periph_GPIOA #define ADC_CHANNEL2 ADC_Channel_2 /*=====================通道3 IO ======================*/ // ADC IO宏定义 #define ADC_GPIO_PORT3 GPIOA #define ADC_GPIO_PIN3 GPIO_Pin_3 #define ADC_GPIO_CLK3 RCC_AHB1Periph_GPIOA #define ADC_CHANNEL3 ADC_Channel_3 // ADC 序号宏定义 #define ADC_ ADC1 #define ADC_CLK RCC_APB2Periph_ADC1 // ADC DR寄存器宏定义,ADC转换后的数字值则存放在这里 #define RHEOSTAT_ADC_DR_ADDR ((u32)ADC1+0x4c) // ADC DMA 通道宏定义,这里我们使用DMA传输 #define ADC_DMA_CLK RCC_AHB1Periph_DMA2 #define ADC_DMA_CHANNEL DMA_Channel_0 #define ADC_DMA_STREAM DMA2_Stream0 void Adc_Init(void); void ADC_Read(void); #endif /* __BSP_ADC_H */ tim文件 #include "tim.h" uint16_t TIM1_Impluse = 4200;//预设占空比 float z = 0; const uint32_t spwm[400] = { 4200,4265,4331,4397,4463,4529,4595,4660,4726,4791,4857,4922,4987,5051,5116,5180, 5244,5308,5371,5434,5497,5560,5622,5684,5746,5807,5868,5928,5988,6047,6106,6165, 6223,6280,6337,6394,6450,6505,6560,6615,6668,6721,6774,6826,6877,6927,6977,7026, 7075,7122,7169,7216,7261,7306,7350,7393,7436,7477,7518,7558,7597,7636,7673,7710, 7746,7781,7815,7848,7880,7911,7942,7971,8000,8027,8054,8080,8105,8128,8151,8173, 8194,8214,8233,8251,8268,8283,8298,8312,8325,8337,8348,8358,8366,8374,8381,8387, 8391,8395,8397,8399,8400,8399,8397,8395,8391,8387,8381,8374,8366,8358,8348,8337, 8325,8312,8298,8283,8268,8251,8233,8214,8194,8173,8151,8128,8105,8080,8054,8027, 8000,7971,7942,7911,7880,7848,7815,7781,7746,7710,7673,7636,7597,7558,7518,7477, 7436,7393,7350,7306,7261,7216,7169,7122,7075,7026,6977,6927,6877,6826,6774,6721, 6668,6615,6560,6505,6450,6394,6337,6280,6223,6165,6106,6047,5988,5928,5868,5807, 5746,5684,5622,5560,5497,5434,5371,5308,5244,5180,5116,5051,4987,4922,4857,4791, 4726,4660,4595,4529,4463,4397,4331,4265,4200,4134,4068,4002,3936,3870,3804,3739, 3673,3608,3542,3477,3412,3348,3283,3219,3155,3091,3028,2965,2902,2839,2777,2715, 2653,2592,2531,2471,2411,2352,2293,2234,2176,2119,2062,2005,1949,1894,1839,1784, 1731,1678,1625,1573,1522,1472,1422,1373,1324,1277,1230,1183,1138,1093,1049,1006, 963,922,881,841,802,763,726,689,653,618,584,551,519,488,457,428, 399,372,345,319,294,271,248,226,205,185,166,148,131,116,101,87, 74,62,51,41,33,25,18,12,8,4,2,0,0,0,2,4, 8,12,18,25,33,41,51,62,74,87,101,116,131,148,166,185, 205,226,248,271,294,319,345,372,399,428,457,488,519,551,584,618, 653,689,726,763,802,841,881,922,963,1006,1049,1093,1138,1183,1230,1277, 1324,1373,1422,1472,1522,1573,1625,1678,1731,1784,1839,1894,1949,2005,2062,2119, 2176,2234,2293,2352,2411,2471,2531,2592,2653,2715,2777,2839,2902,2965,3028,3091, 3155,3219,3283,3348,3412,3477,3542,3608,3673,3739,3804,3870,3936,4002,4068,4134 }; //TIM1的GPIO static void TIM_GPIO_Config(void) { GPIO_InitTypeDef TIM_GPIO_InitStruct; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB, ENABLE);//开钟 /*-----------------------------PA8,PA7------------------------------------*/ GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_TIM1);//引脚复用 主 PA8,PA7 GPIO_PinAFConfig(GPIOA,GPIO_PinSource7,GPIO_AF_TIM1);//引脚复用 补 TIM_GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; //模拟模式GPIO_Mode_AN/F TIM_GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8; //引脚 TIM_GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; //高速 TIM_GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; //推挽 TIM_GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOA, &TIM_GPIO_InitStruct); //写入 TIM_GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7; GPIO_Init(GPIOA, &TIM_GPIO_InitStruct); /*-----------------------------------------------------------------------*/ /*-----------------------------PA9,PB14------------------------------------*/ GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_TIM1);//引脚复用 主 GPIO_PinAFConfig(GPIOB,GPIO_PinSource14,GPIO_AF_TIM1);//引脚复用 补 TIM_GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; //模拟模式GPIO_Mode_AN/F TIM_GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9; //引脚 TIM_GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; //高速 TIM_GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; //推挽 TIM_GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOA, &TIM_GPIO_InitStruct); //写入 TIM_GPIO_InitStruct.GPIO_Pin = GPIO_Pin_14; GPIO_Init(GPIOB, &TIM_GPIO_InitStruct); /*-----------------------------------------------------------------------*/ /*-----------------------------PA10,PB1------------------------------------*/ GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_TIM1);//引脚复用 主 GPIO_PinAFConfig(GPIOB,GPIO_PinSource1,GPIO_AF_TIM1);//引脚复用 补 TIM_GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; //模拟模式GPIO_Mode_AN/F TIM_GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10; //引脚 TIM_GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; //高速 TIM_GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; //推挽 TIM_GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOA, &TIM_GPIO_InitStruct); //写入 TIM_GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1; GPIO_Init(GPIOB, &TIM_GPIO_InitStruct); /*-----------------------------------------------------------------------*/ // TIM_GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN; //模拟模式 pa6死刹 // TIM_GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6; //引脚 // TIM_GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; //高速 // TIM_GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; //推挽 // TIM_GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; //浮空 // GPIO_Init(GPIOA, &TIM_GPIO_InitStruct); //写入 } //TIM1 static void TIM_A1_Mode_Config(void) { TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure; TIM_OCInitTypeDef TIM_OCInitStruct; TIM_BDTRInitTypeDef TIM_BDTRInitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE);///使能时钟 //168MHZ->20kHZ 主频/(计数+1)*(预分频系数+1) //168MHz/8 * 1050 = 20khz /*-----------------------------基本结构体------------------------------------*/ TIM_TimeBaseInitStructure.TIM_Period = (8400-1); //自动重装载值 TIM_TimeBaseInitStructure.TIM_Prescaler=(1-1); //定时器分频 TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; //向上计数模式 TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1; //1分频 TIM_TimeBaseInitStructure.TIM_RepetitionCounter=0; //不需要重复计数 TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure); //初始化TIM /*-----------------------------基本结构体------------------------------------*/ /*-----------------------------输出比较------------------------------------*/ TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1; //pwm模式选择 TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable; ///使能输出通道 TIM_OCInitStruct.TIM_OutputNState = TIM_OutputNState_Enable; //使能互补通道 TIM_OCInitStruct.TIM_Pulse = TIM1_Impluse; //预设占空比 TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High; //PWM1和2中的CH和CCR之间值的大小(多用pwm1的模式1) TIM_OCInitStruct.TIM_OCNPolarity = TIM_OCNPolarity_High; //当使用了刹车功能时,两路PWM1和2都会被强制禁止,进而输出我们配置的的空闲先状态 TIM_OCInitStruct.TIM_OCIdleState = TIM_OCIdleState_Set; //刹车时输出通道的状态 Set = high TIM_OCInitStruct.TIM_OCNIdleState = TIM_OCNIdleState_Reset; //刹车时互补通道的状态 Reset = low TIM_OC1Init(TIM1, &TIM_OCInitStruct); //使能通道1 TIM_OC1PreloadConfig(TIM1,TIM_OCPreload_Enable); /* 使能通道1重载 */ TIM_OCInitStruct.TIM_Pulse = TIM1_Impluse; TIM_OC2Init(TIM1, &TIM_OCInitStruct); TIM_OC2PreloadConfig(TIM1,TIM_OCPreload_Enable); TIM_OCInitStruct.TIM_Pulse = TIM1_Impluse; TIM_OC3Init(TIM1, &TIM_OCInitStruct); TIM_OC3PreloadConfig(TIM1,TIM_OCPreload_Enable); /*-----------------------------输出比较------------------------------------*/ /*-----------------------------死区刹车------------------------------------*/ TIM_BDTRInitStructure.TIM_OSSRState = TIM_OSSRState_Enable; //开启死区 TIM_BDTRInitStructure.TIM_OSSIState = TIM_OSSIState_Enable; //开启1空闲状态 TIM_BDTRInitStructure.TIM_LOCKLevel = TIM_LOCKLevel_1; //不同的锁定级别 (看BDTR寄存器) TIM_BDTRInitStructure.TIM_DeadTime = 20; //刹车时间,(看BDTR寄存器中的DTG[7:0]) //11转换成二进制为0000 1011 死区时间看[7;5]位,此处为000 TIM_BDTRInitStructure.TIM_Break = TIM_Break_Enable; //允许刹车 //BKIN 测到低电平 比较信号禁止 TIM_BDTRInitStructure.TIM_BreakPolarity = TIM_BreakPolarity_High; //高极性 TIM_BDTRInitStructure.TIM_AutomaticOutput = TIM_AutomaticOutput_Enable; //自动输出使能(刹车输入无效) TIM_BDTRConfig(TIM1, &TIM_BDTRInitStructure); //写入 /*-----------------------------死区刹车------------------------------------*/ TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //允许定时器更新中断 | TIM_IT_Trigger TIM_Cmd(TIM1,ENABLE); //使能定时器 TIM_CtrlPWMOutputs(TIM1, ENABLE); //主动输出使能 } static void TIM_A1_NVIC_Config(void) { NVIC_InitTypeDef NVIC_InitStructure; /*-----------------------------中断------------------------------------*/ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); //分组 NVIC_InitStructure.NVIC_IRQChannel=TIM1_UP_TIM10_IRQn; //定时器1中断 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2; NVIC_InitStructure.NVIC_IRQChannelSubPriority=0; NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; //使能中断 NVIC_Init(&NVIC_InitStructure); //写入 /*-----------------------------中断------------------------------------*/ } void TIM_Init(void) { TIM_A1_NVIC_Config(); TIM_GPIO_Config(); TIM_A1_Mode_Config(); } tim.h #ifndef __TIM_H #define __TIM_H #include "sys.h" void TIM_Init(void); #endif oled模块: #include "oled.h" #include "oledfont.h" #include "delay.h" //OLED的显存 //存放格式如下. //[0]0 1 2 3 ... 127 //[1]0 1 2 3 ... 127 //[2]0 1 2 3 ... 127 //[3]0 1 2 3 ... 127 //[4]0 1 2 3 ... 127 //[5]0 1 2 3 ... 127 //[6]0 1 2 3 ... 127 //[7]0 1 2 3 ... 127 u8 OLED_GRAM[128][8]; #if OLED_MODE==0 //向SSD1106写入一个字节。 //dat:要写入的数据/命令 //cmd:数据/命令标志 0,表示命令;1,表示数据; void OLED_WR_Byte(u8 dat,u8 cmd) { u8 i; OLED_DC=cmd; OLED_CS=0; for(i=0;i<8;i++) { OLED_SCL=0; if(dat&0x80) OLED_SDA=1; else OLED_SDA=0; OLED_SCL=1; dat<<=1; } OLED_CS=1; OLED_DC=1; } #endif #if OLED_MODE==1 //向SSD1106写入一个字节。 //dat:要写入的数据/命令 //cmd:数据/命令标志 0,表示命令;1,表示数据; void OLED_WR_Byte(u8 dat,u8 cmd) { OLED_DATA_OUT(dat); OLED_RST=cmd; OLED_CS=0; OLED_WR=0; OLED_WR=1; OLED_CS=1; OLED_DC=1; } #endif #if OLED_MODE==2 void OLED_WR_Byte(u8 dat,u8 cmd) { } #endif //更新显存到LCD void OLED_Refresh_Gram(void) { u8 i,n; for(i=0;i<8;i++) { OLED_WR_Byte (0xb0+i,OLED_CMD); //设置页地址(0~7) OLED_WR_Byte (0x00,OLED_CMD); //设置显示位置—列低地址 OLED_WR_Byte (0x10,OLED_CMD); //设置显示位置—列高地址 for(n=0;n<128;n++)OLED_WR_Byte(OLED_GRAM[n][i],OLED_DATA); } } void OLED_Set_Pos(unsigned char x, unsigned char y) { OLED_WR_Byte(0xb0+y,OLED_CMD); OLED_WR_Byte(((x&0xf0)>>4)|0x10,OLED_CMD); OLED_WR_Byte((x&0x0f)|0x01,OLED_CMD); } //开启OLED显示 void OLED_Display_On(void) { OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令 OLED_WR_Byte(0X14,OLED_CMD); //DCDC ON OLED_WR_Byte(0XAF,OLED_CMD); //DISPLAY ON } //关闭OLED显示 void OLED_Display_Off(void) { OLED_WR_Byte(0X8D,OLED_CMD); //SET DCDC命令 OLED_WR_Byte(0X10,OLED_CMD); //DCDC OFF OLED_WR_Byte(0XAE,OLED_CMD); //DISPLAY OFF } //清屏函数,清完屏,整个屏幕是黑色的!和没点亮一样!!! void OLED_Clear(void) { u8 i,n; for(i=0;i<8;i++) { for(n=0;n<128;n++) { OLED_GRAM[n][i]=0; } } OLED_Refresh_Gram();//更新显示 } //画点 //x:0~127 //y:0~63 //t:1 填充 0,清空 void OLED_DrawPoint(u8 x,u8 y,u8 t) { u8 pos,bx,temp=0; if(x>127||y>63)return;//超出范围了. pos=7-y/8; bx=y%8; temp=1<<(7-bx); if(t)OLED_GRAM[x][pos]|=temp; else OLED_GRAM[x][pos]&=~temp; } void OLED_DrawLine(u8 x1, u8 y1, u8 x2, u8 y2) { u16 t; int xerr=0,yerr=0,delta_x,delta_y,distance; int incx,incy,uRow,uCol; delta_x=x2-x1; //计算坐标增量 delta_y=y2-y1; uRow=x1; uCol=y1; if(delta_x>0)incx=1; //设置单步方向 else if(delta_x==0)incx=0;//垂直线 else {incx=-1;delta_x=-delta_x;} if(delta_y>0)incy=1; else if(delta_y==0)incy=0;//水平线 else{incy=-1;delta_y=-delta_y;} if( delta_x>delta_y)distance=delta_x; //选取基本增量坐标轴 else distance=delta_y; for(t=0;t<=distance+1;t++ )//画线输出 { OLED_DrawPoint(uRow,uCol,1);//画点 xerr+=delta_x ; yerr+=delta_y ; if(xerr>distance) { xerr-=distance; uRow+=incx; } if(yerr>distance) { yerr-=distance; uCol+=incy; } } } void OLED_DrawRectangle(u8 x1, u8 y1, u8 x2, u8 y2) { OLED_DrawLine(x1,y1,x2,y1); OLED_DrawLine(x1,y1,x1,y2); OLED_DrawLine(x1,y2,x2,y2); OLED_DrawLine(x2,y1,x2,y2); } //x1,y1,x2,y2 填充区域的对角坐标 //确保x1<=x2;y1<=y2 0<=x1<=127 0<=y1<=63 //dot:0,清空;1,填充 void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot) { u8 x,y; for(x=x1;x<=x2;x++) { for(y=y1;y<=y2;y++) { OLED_DrawPoint(x,y,dot); } } OLED_Refresh_Gram();//更新显示 } //在指定位置显示一个字符,包括部分字符 //x:0~127 //y:0~63 //mode:0,反白显示;1,正常显示 //size:选择字体 12/16/24 void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 size,u8 mode) { u8 temp,t,t1; u8 y0=y; u8 csize=(size/8+((size%8)?1:0)) * (size/2); //得到字体一个字符对应点阵集所占的字节数 chr=chr-' ';//得到偏移后的值 for(t=0;t<csize;t++) { if(size==12)temp=ascii_1206[chr][t]; //调用1206字体 else if(size==16)temp=ascii_1608[chr][t]; //调用1608字体 else if(size==24)temp=ascii_2412[chr][t]; //调用2412字体 else return; //没有的字库 for(t1=0;t1<8;t1++) { if(temp&0x80)OLED_DrawPoint(x,y,mode); else OLED_DrawPoint(x,y,!mode); temp<<=1; y++; if((y-y0)==size) { y=y0; x++; break; } } } } //m^n函数 u32 oled_pow(u8 m,u8 n) { u32 result=1; while(n--)result*=m; return result; } //显示2个数字 //x,y :起点坐标 //len :数字的位数 //size:字体大小 //num:数值(0~4294967295); void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size) { u8 t,temp; u8 enshow=0; for(t=0;t<len;t++) { temp=(num/oled_pow(10,len-t-1))%10; if(enshow==0&&t<(len-1)) { if(temp==0) { OLED_ShowChar(x+(size/2)*t,y,' ',size,1); continue; }else enshow=1; } OLED_ShowChar(x+(size/2)*t,y,temp+'0',size,1); } } //显示字符串 //x,y:起点坐标 //size:字体大小 //*p:字符串起始地址 void OLED_ShowString(u8 x,u8 y,const u8 *p,u8 size) { while((*p<='~')&&(*p>=' '))//判断是不是非法字符! { if(x>(128-(size/2))){x=0;y+=size;} if(y>(64-size)){y=x=0;OLED_Clear();} OLED_ShowChar(x,y,*p,size,1); x+=size/2; p++; } } //显示汉字 //x,y:起点坐标 //pos:数组位置汉字显示 //size:字体大小 //mode:0,反白显示;1,正常显示 void OLED_ShowFontHZ(u8 x,u8 y,u8 pos,u8 size,u8 mode) { u8 temp,t,t1; u8 y0=y; u8 csize=(size/8+((size%8)?1:0))*(size);//得到字体一个字符对应点阵集所占的字节数 if(size!=12&&size!=16&&size!=24&&size!=32)return; //不支持的size for(t=0;t<csize;t++) { if(size==12)temp=FontHzk_12[pos][t]; //调用1206字体 else if(size==16)temp=FontHzk_16[pos][t]; //调用1608字体 else if(size==24)temp=FontHzk_24[pos][t]; //调用2412字体 else if(size==32)temp=FontHzk_32[pos][t]; //调用3216字体 else return; //没有的字库 for(t1=0;t1<8;t1++) { if(temp&0x80)OLED_DrawPoint(x,y,mode); else OLED_DrawPoint(x,y,!mode); temp<<=1; y++; if((y-y0)==size) { y=y0; x++; break; } } } } //显示BMP图片128×64 //起始点坐标(x,y),x的范围0~127,y为页的范围0~7 void OLED_DrawBMP(u8 x0, u8 y0,u8 x1, u8 y1,u8 BMP[]) { u16 j=0; u8 x,y; if(y1%8==0)y=y1/8; else y=y1/8+1; for(y=y0;y<y1;y++) { OLED_Set_Pos(x0,y); for(x=x0;x<x1;x++) { OLED_WR_Byte(BMP[j++],OLED_DATA); } } } //GND 接电源地 //VCC 接5V或3.3v电源 //D0 接PD6(SCL) //D1 接PD7(SDA) //RES 接PD4 //DC 接PD5 //CS 接PD3 void OLED_Init() { GPIO_InitTypeDef GPIO_InitStructure; #if OLED_MODE==0 //4线SPI模式 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOA,ENABLE); GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT; //输出模式 GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2|GPIO_Pin_6;//管脚设置 GPIO_InitStructure.GPIO_Speed=GPIO_Speed_100MHz;//速度为100M GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;//推挽输出 GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;//不拉 GPIO_Init(GPIOE,&GPIO_InitStructure); //初始化结构体 GPIO_SetBits(GPIOE,GPIO_Pin_2|GPIO_Pin_6); //拉高电平 GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT; //输出模式 GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_13;//管脚设置 GPIO_InitStructure.GPIO_Speed=GPIO_Speed_100MHz;//速度为100M GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;//推挽输出 GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;//不拉 GPIO_Init(GPIOC,&GPIO_InitStructure); //初始化结构体 GPIO_SetBits(GPIOC,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_13); //拉高电平 OLED_Clear(); #endif #if OLED_MODE==1 //8080模式 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOC,ENABLE); GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT; //输出模式 GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;//管脚设置 GPIO_InitStructure.GPIO_Speed=GPIO_Speed_100MHz;//速度为100M GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;//推挽输出 GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;//上拉 GPIO_Init(GPIOD,&GPIO_InitStructure); //初始化结构体 GPIO_SetBits(GPIOD,GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7); GPIO_InitStructure.GPIO_Pin = 0XFF; //PC0-7 GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_SetBits(GPIOC,0xFF); //PC0-7输出高 #endif #if OLED_MODE==2 //IIC模式 #endif OLED_RST=1; delay_ms(100); OLED_RST=0; delay_ms(100); OLED_RST=1; OLED_WR_Byte(0xAE,OLED_CMD); //关闭显示 OLED_WR_Byte(0xD5,OLED_CMD); //设置时钟分频因子,震荡频率 OLED_WR_Byte(80,OLED_CMD); //[3:0],分频因子;[7:4],震荡频率 OLED_WR_Byte(0xA8,OLED_CMD); //设置驱动路数 OLED_WR_Byte(0X3F,OLED_CMD); //默认0X3F(1/64) OLED_WR_Byte(0xD3,OLED_CMD); //设置显示偏移 OLED_WR_Byte(0X00,OLED_CMD); //默认为0 OLED_WR_Byte(0x40,OLED_CMD); //设置显示开始行 [5:0],行数. OLED_WR_Byte(0x8D,OLED_CMD); //电荷泵设置 OLED_WR_Byte(0x14,OLED_CMD); //bit2,开启/关闭 OLED_WR_Byte(0x20,OLED_CMD); //设置内存地址模式 OLED_WR_Byte(0x02,OLED_CMD); //[1:0],00,列地址模式;01,行地址模式;10,页地址模式;默认10; OLED_WR_Byte(0xA1,OLED_CMD); //段重定义设置,bit0:0,0->0;1,0->127; OLED_WR_Byte(0xC0,OLED_CMD); //设置COM扫描方向;bit3:0,普通模式;1,重定义模式 COM[N-1]->COM0;N:驱动路数 OLED_WR_Byte(0xDA,OLED_CMD); //设置COM硬件引脚配置 OLED_WR_Byte(0x12,OLED_CMD); //[5:4]配置 OLED_WR_Byte(0x81,OLED_CMD); //对比度设置 OLED_WR_Byte(0xEF,OLED_CMD); //1~255;默认0X7F (亮度设置,越大越亮) OLED_WR_Byte(0xD9,OLED_CMD); //设置预充电周期 OLED_WR_Byte(0xf1,OLED_CMD); //[3:0],PHASE 1;[7:4],PHASE 2; OLED_WR_Byte(0xDB,OLED_CMD); //设置VCOMH 电压倍率 OLED_WR_Byte(0x30,OLED_CMD); //[6:4] 000,0.65*vcc;001,0.77*vcc;011,0.83*vcc; OLED_WR_Byte(0xA4,OLED_CMD); //全局显示开启;bit0:1,开启;0,关闭;(白屏/黑屏) OLED_WR_Byte(0xA6,OLED_CMD); //设置显示方式;bit0:1,反相显示;0,正常显示 OLED_WR_Byte(0xAF,OLED_CMD); //开启显示 OLED_Clear(); } oled.h #ifndef _oled_H #define _oled_H #include "sys/system.h" #include "stdlib.h" #define WORD_SIZE 12 #define X_OFFSET_WORD 0 #define Y_OFFSET_WORD 0 #define X_OFFSTE_PIXEL 0 #define Y_OFFSTE_PIXEL 0 #if WORD_SIZE != 12 && WORD_SIZE != 16 && WORD_SIZE != 24 #define WORD_SIZE 12 #endif #if WORD_SIZE == 24 #define WORD_WIDTH 12 #define WORD_HIGH 24 #endif #if WORD_SIZE == 16 #define WORD_WIDTH 8 #define WORD_HIGH 16 #endif #if WORD_SIZE == 12 #define WORD_WIDTH 6 #define WORD_HIGH 12 #endif //OLED模式设置 //0:4线串行SPI模式 //1:并行8080模式 //2:IIC模式 #define OLED_MODE 0 #define SIZE 16 #define XLevelL 0x00 #define XLevelH 0x10 #define Max_Column 128 #define Max_Row 64 #define Brightness 0xFF #define X_WIDTH 128 #define Y_WIDTH 64 #if OLED_MODE==0 //OLDE-SPI4线控制管脚定义 #define OLED_SCL PCout(1) #define OLED_SDA PCout(0) #define OLED_RST PCout(13) #define OLED_DC PEout(6) #define OLED_CS PEout(2) #endif #if OLED_MODE==1 //OLDE-8080总线控制管脚定义 #define OLED_CS PDout(3) #define OLED_RST PDout(4) #define OLED_DC PDout(5) #define OLED_WR PDout(6) #define OLED_RD PDout(7) #define OLED_DATA_OUT(x) GPIO_Write(GPIOC,x);//输出 #endif #if OLED_MODE==2 //OLDE-IIC总线控制管脚定义 #endif #define OLED_CMD 0 //写命令 #define OLED_DATA 1 //写数据 //OLED控制用函数 void OLED_WR_Byte(u8 dat,u8 cmd); void OLED_Display_On(void); void OLED_Display_Off(void); void OLED_Set_Pos(unsigned char x, unsigned char y); void OLED_Init(void); void OLED_Refresh_Gram(void); void OLED_Clear(void); void OLED_DrawPoint(u8 x,u8 y,u8 t); void OLED_DrawLine(u8 x1, u8 y1, u8 x2, u8 y2); void OLED_DrawRectangle(u8 x1, u8 y1, u8 x2, u8 y2); void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot); void OLED_ShowChar(u8 x,u8 y,u8 chr,u8 size,u8 mode); void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size); void OLED_ShowString(u8 x,u8 y,const u8 *p,u8 size); void OLED_ShowFontHZ(u8 x,u8 y,u8 pos,u8 size,u8 mode); void OLED_DrawBMP(u8 x0, u8 y0,u8 x1, u8 y1,u8 BMP[]); #endif stm32f4xx_it.c中断文件:/* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_it.h" #include "./usart/bsp_usart.h" #include "./adc/bsp_adc.h" #include "PID.h" /** @addtogroup STM32F429I_DISCOVERY_Examples * @{ */ /** @addtogroup FMC_SDRAM * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ /******************************************************************************/ /* Cortex-M4 Processor Exceptions Handlers */ /******************************************************************************/ /** * @brief This function handles NMI exception. * @param None * @retval None */ extern uint16_t ADC_ConvertedValue[RHEOSTAT_NOFCHANEL]; uint16_t TIM_Advance_Impulse ;//高级定时器占空比 extern float Vout_actual; float Vout_set; // 目标输出电压 extern float pid_out; void TIM1_UP_IRQHandler(void) { if(TIM_GetITStatus(TIM1,TIM_IT_Update) == SET) { pid_out = PID_DC(Vout_set, Vout_actual, 20.0f); TIM1->CCR1 = pid_out; TIM_ClearITPendingBit(TIM1, TIM_IT_Update); } } void DMA2_Stream0_IRQHandler(void) { // 检查传输完成中断标志 if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0) != RESET) { // 清除中断标志 DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0); // 调用ADC_Read计算电压 ADC_Read(); } } //void ADC_IRQHandler(void) //{ // if(ADC_GetITStatus(ADC_,ADC_IT_EOC) == SET) // { // ADC_ConvertedValue = ADC_GetConversionValue(ADC_); // } // ADC_ClearITPendingBit(ADC_,ADC_IT_EOC); //} // void NMI_Handler(void) { } /** * @brief This function handles Hard Fault exception. * @param None * @retval None */ void HardFault_Handler(void) { /* Go to infinite loop when Hard Fault exception occurs */ while (1) {} } /** * @brief This function handles Memory Manage exception. * @param None * @retval None */ void MemManage_Handler(void) { /* Go to infinite loop when Memory Manage exception occurs */ while (1) {} } /** * @brief This function handles Bus Fault exception. * @param None * @retval None */ void BusFault_Handler(void) { /* Go to infinite loop when Bus Fault exception occurs */ while (1) {} } /** * @brief This function handles Usage Fault exception. * @param None * @retval None */ void UsageFault_Handler(void) { /* Go to infinite loop when Usage Fault exception occurs */ while (1) {} } /** * @brief This function handles Debug Monitor exception. * @param None * @retval None */ void DebugMon_Handler(void) {} /** * @brief This function handles SVCall exception. * @param None * @retval None */ void SVC_Handler(void) {} /** * @brief This function handles PendSV_Handler exception. * @param None * @retval None */ void PendSV_Handler(void) {} /** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) {} /******************************************************************************/ /* STM32F4xx Peripherals Interrupt Handlers */ /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */ /* available peripheral interrupt handler's name please refer to the startup */ /* file (startup_stm32f429_439xx.s). */ /******************************************************************************/ void DEBUG_USART_IRQHandler(void) { uint8_t ucTemp; if(USART_GetITStatus(DEBUG_USART,USART_IT_RXNE)!=RESET) { ucTemp = USART_ReceiveData( DEBUG_USART ); USART_SendData(DEBUG_USART,ucTemp); } USART_ClearITPendingBit(USART1,USART_IT_IDLE); } //void ADVANCE_TIM_IRQHandler(void) //{ // if(TIM_GetITStatus(ADVANCE_TIM,TIM_IT_Update)==SET) //溢出中断 // { // Get_AUTO_RST_Mode_Data(value,8); //自动扫描模式,自动扫描并转换8通道。转换数据存与Value数组中 // printf("\r\n试一试\r\n"); // } // TIM_ClearITPendingBit(ADVANCE_TIM,TIM_IT_Update); //清除中断标志位 //} /** * @} */ /** * @} */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

filetype

Requirements The code is tested on clean Ubuntu 20.04 with ROS noetic installation. Install the required package toppra: sudo pip3 install toppra catkin_pkg PyYAML empy matplotlib pyrfc3339 Run the code 1. Download and compile the code git clone https://github.com/ZJU-FAST-Lab/Primitive-Planner.git cd Primitive-Planner catkin_make -DCMAKE_BUILD_TYPE=Release 2. Generate the motion primitive library cd src/scripts python3 swarm_path.py The generated motion primitive library is stored in "src/planner/plan_manage/primitive_library/". 3. Run the planner In the "Primitive-Planner/" directory: source devel/setup.bash # or setup.zsh cd src/scripts python3 gen_position_swap.py 20 # It will generate the swarm.launch with 20 drones roslaunch primitive_planner swarm.launch Wait until all the nodes have their launch process finished and keep printing "[FSM]: state: WAIT_TARGET. Waiting for trigger". Open another terminal, publish the trigger cd src/scripts bash pub_trigger.sh Then the drones (drone number is 40) will start to fly like this Change the drone number when executing "python3 gen_position_swap.py <drone_number>". Before starting the "roslaunch" command, please open another terminal and run "htop" to monitor the Memory usage and CPU usage. Each drone requires about 200 MB memory. Keep the htop opened for entire flight. The computation time is printed on the terminal in blue text, named as "plan_time". To get the accurate computation time, please fix the CPU frequency to its maximum by sudo apt install cpufrequtils sudo cpufreq-set -g performance Otherwise the CPU will run in powersave mode with low frequency分析代码,生成复现过程

filetype

请帮我把以下程序转化为C语言程序输出:import AccoTestAPI from AccoTestAPI.AWG import AwgLoader from AccoTestAPI.DMM import HighSpeedSampler class FLTB_Monitor: def __init__(self): # 硬件初始化 self.awg = AwgLoader(device_id=0, slot=2) # 假设AWG位于2号槽位[^3] self.dmm = HighSpeedSampler(channel=5) # 假设SS连接5号通道[^3] # 波形参数 self.sample_rate = 1e6 # 1MS/s采样率 self.trigger_level = 10.0 # 触发电平 def define_waveform(self): """ 定义FLTB下降波形 """ waveform = [] t_step = 1e-3 # 1ms时间步长 for t in range(0, 200): # 200ms持续时间 voltage = 12.0 - (12.0/200)*t # 线性下降 waveform.append(voltage if voltage > 0 else 0.0) return waveform def setup_measurement(self): try: # 1. 波形配置 fltb_wave = self.define_waveform() self.awg.LoadWaveform(channel=1, waveform=fltb_wave, sample_rate=self.sample_rate) # 2. 源初始化 self.awg.Set(1, 12.0) # FLTB初始12V self.awg.Set(2, 0.0) # SS初始0V # 3. 触发配置 trigger_config = { 'source': 'FLTB', 'slope': 'Falling', 'level': self.trigger_level, 'delay': 10e-6 # 10us触发延迟 } self.awg.AwgSelect(trigger_config) # 4. 同步测量 self.dmm.configure({ 'range': 15.0, 'aperture': 1e-6, 'trigger_sync': True }) except AccoTestAPI.HardwareError as e: print(f"硬件错误: {e}") self._emergency_shutdown() def run_measurement(self): """ 执行触发测量 """ try: self.awg.Start() ss_voltage = self.dmm.capture(1000) # 捕获1000个点 return self._analyze_data(ss_voltage) except AccoTestAPI.TimeoutError: print("错误: 触发超时")

filetype

Requirements The code is tested on clean Ubuntu 20.04 with ROS noetic installation. Install the required package toppra: sudo pip3 install toppra catkin_pkg PyYAML empy matplotlib pyrfc3339 Run the code 1. Download and compile the code git clone https://github.com/ZJU-FAST-Lab/Primitive-Planner.git cd Primitive-Planner catkin_make -DCMAKE_BUILD_TYPE=Release 2. Generate the motion primitive library cd src/scripts python3 swarm_path.py The generated motion primitive library is stored in "src/planner/plan_manage/primitive_library/". 3. Run the planner In the "Primitive-Planner/" directory: source devel/setup.bash # or setup.zsh cd src/scripts python3 gen_position_swap.py 20 # It will generate the swarm.launch with 20 drones roslaunch primitive_planner swarm.launch Wait until all the nodes have their launch process finished and keep printing "[FSM]: state: WAIT_TARGET. Waiting for trigger". Open another terminal, publish the trigger cd src/scripts bash pub_trigger.sh Then the drones (drone number is 40) will start to fly like this Change the drone number when executing "python3 gen_position_swap.py <drone_number>". Before starting the "roslaunch" command, please open another terminal and run "htop" to monitor the Memory usage and CPU usage. Each drone requires about 200 MB memory. Keep the htop opened for entire flight. The computation time is printed on the terminal in blue text, named as "plan_time". To get the accurate computation time, please fix the CPU frequency to its maximum by sudo apt install cpufrequtils sudo cpufreq-set -g performance Otherwise the CPU will run in powersave mode with low frequency. 根据我要复现的代码安装TOPPRAv1.0.0+版本可以吗

filetype

<template>
健康监测统计 <el-radio-group v-model=“drgName” style=‘margin-left:10px’ @click=“query()”> <el-radio-button label=“hypertension”>高血压</el-radio-button> <el-radio-button label=“diabetes”>糖尿病</el-radio-button> </el-radio-group>
<search-tree style='width: 200px' type="org" v-model="orgId" :cache="false" clearable placeholder="所属机构" class="filter-item" /> <date-range v-model="dateRange" type="daterange" range-separator="至" start-placeholder="预约日期起" end-placeholder="预约日期止" class="filter-item" ></date-range> <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="query()" > 搜索 </el-button>
<el-row :gutter="20" class="combined-row"> <el-col :span="5">
慢病管理人数
{{ monitorData.diseaseManageTotalNum }}
慢病一体化人数
{{ monitorData.monitorTotalNum }}
</el-col> <el-col :span="18">
<ve-histogram :data="monitorStatisticDate" :settings="monitorStatisticSettings" :extend="chartExtend" ></ve-histogram>
</el-col> </el-row>
<el-table border ref="dataTable" v-loading="loading" :data="formData" size="small" style="width: 100%" > <el-table-column prop="orgName" label="机构" show-overflow-tooltip align="center" ></el-table-column> <el-table-column prop="diseaseManageNum" label="管理人数" show-overflow-tooltip align="center" ></el-table-column> <el-table-column label="已监测人数" show-overflow-tooltip align="center" > <el-table-column prop="monitorNormalNum" label="正常" show-overflow-tooltip align="center" ></el-table-column> <el-table-column prop="monitorMildNum" label="轻度" show-overflow-tooltip align="center" ></el-table-column> <el-table-column prop="monitorModerateNum" label="中度" show-overflow-tooltip align="center" ></el-table-column> <el-table-column prop="monitorSeriousNum" label="重度" show-overflow-tooltip align="center" ></el-table-column> <el-table-column prop="monitorExceptionNum" label="异常" show-overflow-tooltip align="center" ></el-table-column> <el-table-column prop="monitorTotalNum" label="合计" show-overflow-tooltip align="center" ></el-table-column> </el-table-column> <el-table-column prop="notMonitorNum" label="未监测人数" show-overflow-tooltip align="center" ></el-table-column> </el-table>
</template> <script> import DateUtil from ‘…/…/…/…/utils/date’ import { statisticsMonitorTotal,statisticsMonitorFormTotal } from ‘…/…/…/…/api/fu/statistic’ export default { name: ‘StatisticsMonitorIndex’, components: { DateUtil }, data() { return { drgName:‘hypertension’, orgId: null, diseaseManageNum: null, rateCount: null, loading: false, monitorData: { diseaseManageTotalNum: 0, monitorTotalNum: 0 }, monitorStatisticItemDTOList: [], formData: [], // 分页查询参数 params: { }, // 时间区间,默认为上周到今天7天内日期 dateRange: [DateUtil.addDate(new Date(), -31), DateUtil.getNowDate()], monitorStatisticDate: { columns: ['orgName', '管理人数', '监测完成率'], rows: [] }, monitorStatisticSettings: { showLine: ['监测完成率'], axisSite: { right: ['监测完成率'] }, yAxisName: ['管理人数', '监测完成率(%)'] }, chartExtend: { color: ['#45C2E0', '#FF9393'], legend: { data: ['管理人数', '监测完成率'] }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross' } }, series: { smooth: false }, alignTicks: true, xAxis: { axisLabel: { interval: 0 } }, yAxis: [ { name: '管理人数', type: 'value', splitNumber: 5, axisLabel: { formatter: '{value}' }, splitLine: { show: true, lineStyle: { type: 'dashed' } } }, { name: '监测完成率(%)', type: 'value', min: 0, max: 100, interval: 20, splitNumber: 5, axisLabel: { formatter: '{value}%' }, splitLine: { show: true, lineStyle: { type: 'dashed' } } } ] }, } }, created() { this.$nextTick(() => { // 路由自带的查询参数 this.params = Object.assign({}, this.params, this.$route.query) this.query() }) }, watch: { // 监听drgName的变化 drgName(newValue, oldValue) { if (newValue !== oldValue) { this.query(); } }, dateRange(val) { // 安全判断 if (val && Array.isArray(val) && val.length >= 2) { this.params.startDate = DateUtil.format(val[0], ‘yyyy-MM-dd’); this.params.endDate = DateUtil.format(val[1], ‘yyyy-MM-dd’); } else { this.params.startDate = null; this.params.endDate = null; } }, }, methods: { /** * 查询 * @param */ query() { this.loading = true; let startDate = null; let endDate = null; if (this.dateRange && Array.isArray(this.dateRange) && this.dateRange.length >= 2) { startDate = DateUtil.format(this.dateRange[0], 'yyyy-MM-dd'); endDate = DateUtil.format(this.dateRange[1], 'yyyy-MM-dd'); } const params = { drgName: this.drgName, orgId: this.orgId, startDate: startDate, endDate: endDate }; // 并发请求两个接口 Promise.all([ statisticsMonitorTotal(params), // 图表数据 statisticsMonitorFormTotal(params) // 表单数据 ]) .then(([response1, response2]) => { // 处理第一个接口:统计图数据 if (response1.code === 'success') { const data = response1.data || {}; this.monitorData = { diseaseManageTotalNum: data.diseaseManageTotalNum || 0, monitorTotalNum: data.monitorTotalNum || 0 }; this.monitorStatisticDate.rows = (data.monitorStatisticItemDTOList || []).map(item => ({ orgName: item.orgName, '管理人数': item.diseaseManageNum, '监测完成率': item.rateCount })); } else { this.$message.error(response1.message || '获取统计图表数据失败'); } // 处理第二个接口:表单数据 if (response2.code === 'success') { const formDataList = response2.data; this.formData = formDataList.map(formData => ({ orgName: formData.orgName, diseaseManageNum: formData.diseaseManageNum, monitorNormalNum: formData.monitorNormalNum, monitorMildNum: formData.monitorMildNum, monitorModerateNum: formData.monitorModerateNum, monitorSeriousNum: formData.monitorSeriousNum, monitorExceptionNum: formData.monitorExceptionNum, monitorTotalNum: formData.monitorTotalNum, notMonitorNum: formData.notMonitorNum })); } else { this.$message.error(response2.message || '获取表单统计数据失败'); } }) .catch(error => { console.error('API调用错误:', error); this.$message.error('数据加载失败'); }) .finally(() => { this.loading = false; }); }, }, computed: {} } </script> 这是全部代码,要实现双Y轴左右刻度线一致,并且左侧管理人数固定6条,刻度根据实际数值自动变换;右侧监测完成率(%)固定6条,取消自动计算,刻度分别是0 20 40 60 80 100

kolten
  • 粉丝: 58
上传资源 快速赚钱