不知都有多久沒有寫文檔了,發(fā)現(xiàn)自己的文檔編寫能力實在太差。
從今天開始,慢慢寫文檔。?
????????不知道是那一年打電話問了某研究時的陳老師咨詢了CVI8.5,發(fā)現(xiàn)CVI這個軟件在測控行業(yè),有很大測優(yōu)勢,很豐富的控件,現(xiàn)成的驅(qū)動庫,交互式編程,讓有C語言基礎(chǔ)的人能快速實現(xiàn)工程需求。?
重點,CVI軟件是基于C語言開發(fā)的,所以開發(fā)CVI語言需要C語言基礎(chǔ)的。?
但是本人C語言實在是太差太差,不會初始化,不會用指針,不會用結(jié)構(gòu)體,不會寫函數(shù),不會寫頭文件,不會寫.C文件,但是本人有一個優(yōu)點,就是目標(biāo)確定后 堅韌不拔,耗時間我是一把好手,其實我也不想耗時間,能力太次了,拿不動啊,但是又想拿,只能用時間來湊了。
必須有C語言基礎(chǔ),我推薦 《C程序設(shè)計語言》 ?
? NewAsyncTimerCV I數(shù)據(jù)我推薦《虛擬儀器軟件開發(fā)環(huán)境Labwindows/CVI 6.0》 這本書不能買到新書了,在二手市場上能夠買的到。
以上概括一下 ?
在測控行業(yè) CVI軟件是一款基于C語言的交互式編程軟件開發(fā)工具,需要設(shè)計師有明確的目標(biāo),需要有C語言基礎(chǔ)。?
下面我介紹一下我用CVI2019 的心得?
心得1? 支持代碼補齊功能?
不會上傳圖片,總之有代碼補齊功能好啊,但是需要大概知道自己使用函數(shù)的前綴?
我現(xiàn)在使用最多的是? get。。。 ?? set。。。 ? 本人記性太差 根本記不住函數(shù) ,有這個功能實在是太好了
心得2 ? 如何使用CVI? 獲得幫助 ?? 這個是最重要的 ?? CVI工具好啊 ,但是問題來了怎么用好?
我的使用套路? ,明確目標(biāo)后,比如 ?? 工程上常用的 異步定時器和多線程,這些需求是必須的。?
現(xiàn)在明確 要學(xué)習(xí) 異步定時器 ,異步定時器的使用場合,什么時候使用異步定時器? 如何得到最專業(yè)的異步定時器的資料及代碼?
1百度搜啊 百度搜啊? 不會找度娘啊,打開百度? 搜索 CVI? 異步定時器 ?
? ?? 搜到了。。。? 這時候 打斷,百度搜到的 是思路及函數(shù)明細(xì)啊 ,不能直接用百度搜到的 代碼。?
? ? 搜到了? 用到?NewAsyncTimer函數(shù)?
? ? 打開CVI2019 ? 按? F1 ? ? 在索引里面 輸入 ?NewAsyncTimer
?? 當(dāng)當(dāng)當(dāng)? 右側(cè)出現(xiàn)一堆英文 ,馬迪 看不懂? 看不懂 沒關(guān)系? 下載 翻譯軟件 ? 翻譯軟件很重要啊? ,網(wǎng)上自己下載吧? 據(jù)說 QQ瀏覽器 及**軟件挺好,找一款適合自己的翻譯軟件 ,復(fù)制粘貼 看看什么意思,或者選中? 出現(xiàn)問號 點一點 看是什么意思。
在 右側(cè)的一堆英文下方? 找到 了?
Include file:toolbox\asynctmr.h
LabWindows/CVI compatibility:LabWindows/CVI 5.0 and later
這兩句話? 這兩句話? 告訴我們 需要加載驅(qū)動 ,驅(qū)動文件夾位置 在?:toolbox下 ,load ?toolbox\asynctmr.fp?
2? 獲得專業(yè)代碼 ?
在 幫助問價寫? 輸入NewAsyncTimer? 切換到搜索? 列出主題 ?
馬蒂? 又出現(xiàn)一堆英文? ,別怕 ? 別慌 ? 一堆英文 能搞懂一個實用的就行了 ,記不住全部英文單詞? 記住 前4個英語單詞就行 ?
馬蒂? 出現(xiàn)的一堆英文里 第一個 序言看一看 ? 明白套路 ? 函數(shù)的目的? 輸入輸出 什么意思? 驅(qū)動路徑 啥的 ? ?
還有現(xiàn)成的 demo 這比百度要好多少 ?? 好多少 ? ? demo? 必須看 ? ?
看完一個demo后? 馬蒂? 啥也看不懂 ? 一大度代碼? 核心代碼是什么? 一團霧水 ??
這時候需要找核心代碼了 ?
列出主提? 不是看到一堆英文了? 找 code 相關(guān)的主題 ?
找到了?
Using a Thread Pool to Run Code in Secondary Threads 主題?
右側(cè)出現(xiàn)下文 ? ?
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 ? 異步的意思?
總之 編程想實現(xiàn)? 異步定時器 ,記住 異步新a就行 ? ? 我就是編的? 記不住code? 記不住函數(shù)? 只能時間來湊了 ??
總之? 還是要知道有這么回事,然后? 百度 幫助 文件? copy? copy?
不知道會有人看完這篇文章 ,看完如果覺得有幫助的話? 點一下贊
這個格式以前竟然不知道m(xù)arkdown?