Coder Social home page Coder Social logo

ats_finaltest_n9320b's Introduction

频率、幅度、marker菜单

图像显示采用定时器,两个开关分别打开和关闭定时器,当定时器开启的时候,会 发送:TRAC:DATA? TRACE1,将原始数据保存到 tracedata,但上机实测后发现,此数据不 能直接用来显示,数据格式为“-75.331291,-75.684418,-77.050140”,通过 IOLAB 发送 数据查看一共有 461 组数据,最开始的算法是用 for 循环,但是害怕有可能出现正的数 据、或者长度可变等情况,最终采用 strtok,进行以逗号字符串分割,while 循环到最 后为空,每次将分割好的字符串 atof 转化为数字,本算法仍有改进余地,当时为了方 便调试后来为了显示图像 atof 单独写的,写报告时发现可以完全集成在 while 里,同时 ii 可以用于图像显示长度(之前是 define DISPDATALEN 461),实现长度自适应。 在 使 用 strtok 时 需 要 注 意 , 每 次 只 能 分 割 出 一 个 字 符 , 第 一 次 调 用 后 strtok(tracedata,delims),后续需要 strtok( NULL, delims ),因为此时内部有个指针指向 tracedata 运行后第一个“,”,此时只用 strtok( NULL, delims )即可,当为 NULL,指针 从上一个位置开始, 直到遇见下个“,”这样把所有数据分割出来。 处理完数据后,就可以直接显示了,提前处理好 xdata,线性增加,进行画图即可。 为使图像直观,还有三个查询命令,起始、中心、截至频率显示在图像下方。

Marker 实现动态标记,并左右可调整(采用纯软件算法,在来回变化可能会有精 度略微改变)。如果 marker 打开,发送命令获得 x、y 的值(其实是字符串需要 atof 转化一下),但是此时 x 是频率并不是实际图像的位置,需要通过起始频率和截至频率 进行映射到 x 轴,markerknob 为面板上的旋钮,目的是左右加偏置,y 的值根据最终 x 的值确定(精度误差产生于此),最后将(x,y)以绿色小点的形式画出来,实际 y 轴 位置+2,为了方便观察。最后再将变换后的 x 轴坐标映射到频率显示出来,以及 y 的幅 度,实现 marker 测量功能。 值得注意,因为是索引数组,虽然旋钮范围是(-300,300)但实际有可能会索引 超出范围,因为图像有一定延时,所以需要小心调整或者手动输入。

ats_finaltest_n9320b's People

Contributors

kingskymoon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.