美文网首页
CVI2019 使用心得

CVI2019 使用心得

作者: 蓝天白云石头彩虹 | 来源:发表于2019-10-07 11:31 被阅读0次

    不知都有多久没有写文档了,发现自己的文档编写能力实在太差。

    从今天开始,慢慢写文档。 

            不知道是那一年打电话问了某研究时的陈老师咨询了CVI8.5,发现CVI这个软件在测控行业,有很大测优势,很丰富的控件,现成的驱动库,交互式编程,让有C语言基础的人能快速实现工程需求。 

    重点,CVI软件是基于C语言开发的,所以开发CVI语言需要C语言基础的。 

    但是本人C语言实在是太差太差,不会初始化,不会用指针,不会用结构体,不会写函数,不会写头文件,不会写.C文件,但是本人有一个优点,就是目标确定后 坚韧不拔,耗时间我是一把好手,其实我也不想耗时间,能力太次了,拿不动啊,但是又想拿,只能用时间来凑了。

    必须有C语言基础,我推荐 《C程序设计语言》  

      NewAsyncTimerCV I数据我推荐《虚拟仪器软件开发环境Labwindows/CVI 6.0》 这本书不能买到新书了,在二手市场上能够买的到。

    以上概括一下  

    在测控行业 CVI软件是一款基于C语言的交互式编程软件开发工具,需要设计师有明确的目标,需要有C语言基础。 

    下面我介绍一下我用CVI2019 的心得 

    心得1  支持代码补齐功能 

    不会上传图片,总之有代码补齐功能好啊,但是需要大概知道自己使用函数的前缀 

    我现在使用最多的是  get。。。    set。。。   本人记性太差 根本记不住函数 ,有这个功能实在是太好了

    心得2   如何使用CVI  获得帮助    这个是最重要的    CVI工具好啊 ,但是问题来了怎么用好 

    我的使用套路  ,明确目标后,比如    工程上常用的 异步定时器和多线程,这些需求是必须的。 

    现在明确 要学习 异步定时器 ,异步定时器的使用场合,什么时候使用异步定时器? 如何得到最专业的异步定时器的资料及代码?

    1百度搜啊 百度搜啊  不会找度娘啊,打开百度  搜索 CVI  异步定时器  

         搜到了。。。  这时候 打断,百度搜到的 是思路及函数明细啊 ,不能直接用百度搜到的 代码。 

        搜到了  用到 NewAsyncTimer函数 

        打开CVI2019   按  F1     在索引里面 输入  NewAsyncTimer

       当当当  右侧出现一堆英文 ,马迪 看不懂  看不懂 没关系  下载 翻译软件   翻译软件很重要啊  ,网上自己下载吧  据说 QQ浏览器 及**软件挺好,找一款适合自己的翻译软件 ,复制粘贴 看看什么意思,或者选中  出现问号 点一点 看是什么意思。

    在 右侧的一堆英文下方  找到 了 

    Include file:toolbox\asynctmr.h

    LabWindows/CVI compatibility:LabWindows/CVI 5.0 and later

    这两句话  这两句话  告诉我们 需要加载驱动 ,驱动文件夹位置 在 :toolbox下 ,load  toolbox\asynctmr.fp 

    2  获得专业代码  

    在 帮助问价写  输入NewAsyncTimer  切换到搜索  列出主题  

    马蒂  又出现一堆英文  ,别怕   别慌   一堆英文 能搞懂一个实用的就行了 ,记不住全部英文单词  记住 前4个英语单词就行  

    马蒂  出现的一堆英文里 第一个 序言看一看   明白套路   函数的目的  输入输出 什么意思  驱动路径 啥的    

    还有现成的 demo 这比百度要好多少    好多少     demo  必须看    

    看完一个demo后  马蒂  啥也看不懂   一大度代码  核心代码是什么? 一团雾水   

    这时候需要找核心代码了  

    列出主提  不是看到一堆英文了  找 code 相关的主题  

    找到了 

    Using a Thread Pool to Run Code in Secondary Threads 主题 

    右侧出现下文    

    NewAsyncTimer

    int NewAsyncTimer (double interval, int count, int initialState,

    void *eventFunction, void *callbackData);

    Purpose

    Creates a new asynchronous timer and returns a timer ID you can

    use to identify the timer in subsequent function calls.

    NewAsyncTimercreates asynchronous timers that run in threads with priorityTHREAD_PRIORITY_HIGHEST(2).

    RTNewAsyncTimercreates asynchronous timers that run in threads with a priority of 2. To specify a different priority, callNewAsyncTimerWithPriority.

    NoteYou can use asynchronous timers onWindows, real-time

    (RT), and Linux operating systems.

    Asynchronous timer tick events can accumulate when the library

    thread responsible for generating timer tick events is unable to call the

    callback function at the specified interval. For example, the library thread

    could fall behind if the time to complete the callback function is longer than

    the specified interval. When asynchronous timer tick events accumulate, the

    library thread dispatches the accumulated events as quickly as possible. In this

    case, the interval at which the library thread generates events might be shorter

    than the interval you specified when you created the asynchronous timer. If the

    cause for the accumulated events is temporary and the library thread finishes

    generating the accumulated events, the library thread resumes generating events

    at the interval you specified when you created the asynchronous timer.

    On Windows, all asynchronous callback functions share a common

    thread. As a result, the duration of any asynchronous callback function can have

    an impact on all other asynchronous timers, possibly causing timer tick events

    to accumulate.

    Parameters

    Input

    NameTypeDescription

    intervaldoubleSpecifies the wait interval, in seconds, between timer events.

    The minimum interval value that you can use depends on the system that is running the asynchronous timer. If the interval is smaller than the asynchronous timer resolution supported by your system, LabWindows/CVI uses an interval equal to the resolution supported by the system. CallGetAsyncTimerResolutionto get the asynchronous timer resolution for your system.

    countintSpecifies the number of timer events to be generated before the timer is automatically discarded.

    If you pass a negative value, the timer will generate events until it is discarded by a call toDiscardAsyncTimeror suspended by a call toSuspendAsyncTimerCallbacks.

    NoteA value of zero will return an error.

    initialStateintSpecifies whether the timer is enabled or disabled when it is created. You can specify one of the following values:

    Pass0or selectDisabledin the function panel—The timer is disabled and does not generate timer events when it is created.

    Pass a nonzero value or selectEnabledin the function panel—The timer is enabled and generates timer events when it is created.

    The value of this parameter determines the value of theASYNC_ATTR_ENABLEDattribute.

    NoteIf you create a new timer with aninitialStateof 0, you cannot enable the timer by callingResumeAsyncTimerCallbacks. Instead, you must setASYNC_ATTR_ENABLEDto1to enable the timer.

    eventFunctionvoid *Specifies the name of the user function that processes the callback. This event function (typeAsyncTimerCallbackPtr) takes the same form as the timer callback function:

    int

    CVICALLBACK FunctionName (int reserved, int timerId, int event, void

    *callbackData, int eventData1, int eventData2);

    The first parameter of the event function is reserved.timerIdis the timer that caused the callback. The types of events generated areEVENT_TIMER_TICKandEVENT_DISCARD.eventData1is a pointer to a double that represents the current time in seconds and is relative to the start of the first timer event.eventData2is a pointer to a double that represents the time that has elapsed since the last call to the timer callback. The elapsed time is set to zero if the callback has not been called previously. The resolution ofeventData1andeventData2matches the resolution of the asynchronous timer. Callback data defined by the user also is passed to the event function.

    callbackDatavoid *Specifies a pointer to user-defined data passed to the event

    function.

    Return Value

    NameTypeDescription

    timerIDintSpecifies the ID that is used to reference the timer in subsequent function calls. Negative values indicate that an error occurred.

    Error Codes:

    –1The system failed to allocate a timer.

    –2No more IDs are available to assign to a new timer.

    –3Not enough memory left for this operation.

    –4The timer with the given ID was not found.

    –5Initialization with a call toNewAsyncTimerwas not done.

    –6An internal error occurred.

    –7The value of a parameter passed to this function was invalid.

    –8The functionality is only available on real-time operating

    systems.

    –9You cannot set this

    attribute.

    Additional Information

    Library:Asynchronous

    Timers

    Include file:toolbox\asynctmr.h

    LabWindows/CVI compatibility:LabWindows/CVI 5.0 and later

    Example

    Refer totoolbox\asyncdem.cwsfor an example of using theNewAsyncTimerfunction.

    Open example

    if(typeof(Print_Link)=="function"){

    Print_Link();

    }

    惊不惊喜 意不意外   这样就找到了 核心代码,不带一个绕圈圈的代码,能够工程用的代码。 速度高效  

    然后 记住了   用 异步定时器  需要记住  newa。。。     马蒂代码会补齐的 能 记住 mewa就行  记不住  记住   

    异步新a   异步newa     异步新a   异步。。        a是  async   异步的意思 

    总之 编程想实现  异步定时器 ,记住 异步新a就行     我就是编的  记不住code  记不住函数  只能时间来凑了   

    总之  还是要知道有这么回事,然后  百度 帮助 文件  copy  copy 

    不知道会有人看完这篇文章 ,看完如果觉得有帮助的话  点一下赞  

    相关文章

      网友评论

          本文标题:CVI2019 使用心得

          本文链接:https://www.haomeiwen.com/subject/cmdupctx.html