null  null
‫معرفی چند منبع در زمینه آموزش برنامه نویسی ‪ MATLAB‬یا متلب‬
‫کتاب های به زبان انگلیسی‬
‫عنوان‪Matlab, Third Edition: A Practical Introduction to :‬‬
‫‪Programming and Problem Solving‬‬
‫ترجمه عنوان‪ :‬متلب‪ :‬مقدمه ای عملی بر برنامه نويسی و حل مساله‪ ،‬چاپ سوم‬
‫مولفین‪Stormy Attaway :‬‬
‫سال چاپ‪2013 :‬‬
‫انتشارات‪Butterworth-Heinemann :‬‬
‫کتاب های به زبان فارسی‬
‫عنوان‪ :‬اصول و مبانی متلب برای علوم مهندسی‬
‫مولفین‪ :‬برايان هان‪ ،‬دانیل تی‪ ،‬والنتین‬
‫مترجمین‪ :‬رامین موالنا پور‪ ،‬سارا موالناپور‪ ،‬نینا اسدی پور‬
‫انتشارات‪ :‬سها دانش‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB For Dummies :‬‬
‫ترجمه عنوان‪ :‬تلب به زبان ساده‬
‫مولفین‪Jim Sizemore, John Paul Mueller :‬‬
‫سال چاپ‪2014 :‬‬
‫انتشارات‪For Dummies :‬‬
‫عنوان‪ :‬کاربرد ‪ MATLAB‬در علوم مهندسی‬
‫مولفین‪ :‬حیدرعلی شايانفر‪ ،‬حسین شايقی‬
‫انتشارات‪ :‬ياوريان‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Essential MATLAB for Engineers and Scientists :‬‬
‫عنوان‪ :‬برنامه نويسی ‪ MATLAB‬برای مهندسان‬
‫ترجمه عنوان‪ :‬آنچه بايد مهندسین و دانشمندان از متلب بدانند‬
‫مولفین‪ :‬محمود کشاورز مهر‪ ،‬بهزاد عبدی‬
‫مولفین‪Brian Hahn, Daniel Valentine:‬‬
‫سال چاپ‪2013 :‬‬
‫انتشارات‪Academic Press :‬‬
‫انتشارات‪ :‬نوپردازان‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB: An Introduction with Applications :‬‬
‫عنوان‪ :‬آموزش کاربردی مباحث پیشرفته با ‪MATLAB‬‬
‫ترجمه عنوان‪ :‬مقدمه ای بر متلب و کاربردهای آن‬
‫مولفین‪ :‬نیما جمشیدی‪ ،‬علی ابويی مهريزی‪ ،‬رسول مواليی‬
‫مولف‪Amos Gilat :‬‬
‫انتشارات‪ :‬عابد‬
‫سال چاپ‪2014 :‬‬
‫انتشارات‪Wiley :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB For Beginners: A Gentle Approach:‬‬
‫عنوان‪ :‬کاملترين مرجع آموزشی و کاربردی ‪MATLAB‬‬
‫ترجمه عنوان‪ :‬متلب برای افراد مبتدی با يک رويکرد تدريجی‬
‫مولفین‪ :‬علی اکبر علمداری‪ ،‬نسرين علمداری‬
‫مولف‪Peter I. Kattan:‬‬
‫انتشارات‪ :‬نگارنده دانش‬
‫سال چاپ‪2008 :‬‬
‫انتشارات‪CreateSpace Independent Publishing Platform :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB for Engineers :‬‬
‫عنوان‪ :‬برنامه نويسی ‪ MATLAB‬برای مهندسین‬
‫ترجمه عنوان‪ :‬متلب برای مهندسین‬
‫مولف‪ :‬استفن چاپمن‬
‫مولف‪Holly Moore :‬‬
‫سال چاپ‪2011 :‬‬
‫انتشارات‪Prentice Hall :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Mastering MATLAB :‬‬
‫ترجمه عنوان‪ :‬تسلط بر متلب‬
‫مولفین‪Duane C. Hanselman, Bruce L. Littlefield :‬‬
‫سال چاپ‪2011 :‬‬
‫انتشارات‪Prentice Hall :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫مترجم‪ :‬سعدان زکائی‬
‫انتشارات‪ :‬دانشگاه صنعتی خواجه نصیرالدين طوسی‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪ :‬آموزش گام به گام محاسبات عددی با متلب‬
‫مولف‪ :‬کلیو مولر‬
‫مترجم‪ :‬رسول نصیری‬
‫انتشارات‪ :‬نشر گستر‬
‫لینک دسترسی‪ :‬لینک‬
‫منابع آموزشی آنالین‬
‫عنوان‪ :‬مجموعه فرادرسهای برنامهنويسی متلب‬
‫مدرس‪ :‬دکتر سید مصطفی کالمی هريس‬
‫مدت زمان‪ ۹ :‬ساعت و ‪ ۳‬دقیقه‬
‫زبان‪ :‬فارسی‬
‫ارائه دهنده‪ :‬فرادرس‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪ :‬مجموعه فرادرسهای متلب برای علوم و مهندسی‬
‫مدرس‪ :‬دکتر سید مصطفی کالمی هريس‬
‫مدت زمان‪ 14 :‬ساعت و ‪ 2۲‬دقیقه‬
‫زبان‪ :‬فارسی‬
‫ارائه دهنده‪ :‬فرادرس‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪ :‬مجموعه فرادرسهای برنامه نويسی متلب پیشرفته‬
‫مدرس‪ :‬دکتر سید مصطفی کالمی هريس‬
‫مدت زمان‪ ۲ :‬ساعت و ‪ 12‬دقیقه‬
‫زبان‪ :‬فارسی‬
‫ارائه دهنده‪ :‬فرادرس‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Introduction to Programming with MATLAB :‬‬
‫ترجمه عنوان‪ :‬آشنايی با برنامهنويسی متلب‬
‫مدرسین‪Akos Ledeczi, Michael Fitzpatrick, Robert Tairas :‬‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪Vanderbilt University :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Introduction to MATLAB :‬‬
‫ترجمه عنوان‪ :‬مقدمهای بر متلب‬
‫مدرس‪Danilo Šćepanović :‬‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪MIT OCW :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Up and Running with MATLAB :‬‬
‫ترجمه عنوان‪ :‬شروع سريع کار با متلب‬
‫مدرس‪Patrick Royal :‬‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪lynda.com :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Modelling and Simulation using MATLAB :‬‬
‫ترجمه عنوان‪ :‬مدلسازی و شبیهسازی با استفاده از متلب‬
‫مدرسین‪ Prof. Dr.-Ing. Georg Fries :‬و دیگران‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪iversity.org :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫™‪xPC Target‬‬
‫‪API Guide‬‬
‫‪R2013b‬‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
How to Contact MathWorks
Web
Newsgroup
www.mathworks.com/contact_TS.html Technical Support
www.mathworks.com
comp.soft-sys.matlab
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Product enhancement suggestions
Bug reports
Documentation error reports
Order status, license renewals, passcodes
Sales, pricing, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc.
3 Apple Hill Drive
Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
xPC Target™ API Guide
© COPYRIGHT 2002–2013 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern
the use, modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government)
and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the
government’s needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Revision History
July 2002
October 2002
September 2003
June 2004
August 2004
October 2004
November 2004
March 2005
September 2005
March 2006
May 2006
September 2006
March 2007
September 2007
March 2008
October 2008
March 2009
September 2009
March 2010
September 2010
April 2011
September 2011
March 2012
September 2012
March 2013
September 2013
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
New for Version 2 (Release 13)
Updated for Version 2 (Release 13)
Revised for Version 2.0.1 (Release 13SP1)
Revised for Version 2.5 (Release 14)
Revised for Version 2.6 (Release 14+)
Revised for Version 2.6.1 (Release 14SP1)
Revised for Version 2.7 (Release 14SP1+)
Revised for Version 2.7.2 (Release 14SP2)
Revised for Version 2.8 (Release 14SP3)
Revised for Version 2.9 (Release 2006a)
Revised for Version 3.0 (Release 2006a+)
Revised for Version 3.1 (Release 2006b)
Revised for Version 3.2 (Release 2007a)
Revised for Version 3.3 (Release 2007b)
Revised for Version 3.4 (Release 2008a)
Revised for Version 4.0 (Release 2008b)
Revised for Version 4.1 (Release 2009a)
Revised for Version 4.2 (Release 2009b)
Revised for Version 4.3 (Release 2010a)
Revised for Version 4.4 (Release 2010b)
Revised for Version 5.0 (Release 2011a)
Revised for Version 5.1 (Release 2011b)
Revised for Version 5.2 (Release 2012a)
Revised for Version 5.3 (Release 2012b)
Revised for Version 5.4 (Release 2013a)
Revised for Version 5.5 (Release 2013b)
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Contents
Introduction
1
xPC Target APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-2
xPC Target API for Microsoft .NET Framework . . . . . .
1-3
xPC Target C API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-5
..............................
1-7
Required Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-9
xPC Target COM API
xPC Target API for Microsoft .NET Framework
2
Using the xPC Target API for .NET Framework . . . . . .
Features and Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xpcosc Client Applications . . . . . . . . . . . . . . . . . . . . . . . . . .
File Server Browser Client Application . . . . . . . . . . . . . . . .
2-2
2-2
2-3
2-3
xPC Target .NET API Object Model . . . . . . . . . . . . . . . . . .
2-4
xPC Target API for .NET Framework Classes . . . . . . . .
Mathworks.xPCTarget.Framework.xPCTargetPC . . . . . . .
Mathworks.xPCTarget.Framework.xPCApplication . . . . .
Mathworks.xPCTarget.Framework.xPCScopes . . . . . . . . .
Mathworks.xPCTarget.Framework.xPCParameters . . . . .
Mathworks.xPCTarget.Framework.xPCParameter . . . . . .
Mathworks.xPCTarget.Framework.xPCSignals . . . . . . . . .
Mathworks.xPCTarget.Framework.xPCSignal . . . . . . . . . .
Mathworks.xPCTarget.Framework.xPCAppLogger . . . . . .
2-5
2-5
2-6
2-6
2-6
2-6
2-7
2-7
2-7
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
v
xPC Target .NET API Usage . . . . . . . . . . . . . . . . . . . . . . . .
2-8
xPC Target .NET API Application Deployment . . . . . . .
2-10
xPC Target API for C
3
...................................
3-2
Visual C Console Application . . . . . . . . . . . . . . . . . . . . . . .
Target Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Folders and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Building the xPC Target Application . . . . . . . . . . . . . . . . . .
Creating a Visual C Application . . . . . . . . . . . . . . . . . . . . . .
Building a Visual C Application . . . . . . . . . . . . . . . . . . . . . .
Running an xPC Target Visual C API Application . . . . . . .
Using the xPC Target C API Application . . . . . . . . . . . . . .
C Code for sf_car_xpc.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3-4
3-4
3-4
3-6
3-6
3-9
3-10
3-10
3-16
Using the C API
xPC Target API for COM
4
vi
Contents
Using the COM API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4-2
Visual Basic GUI Using COM Objects . . . . . . . . . . . . . . . .
Target Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simulink Water Tank Model . . . . . . . . . . . . . . . . . . . . . . . .
Creating a Simulink Target Model . . . . . . . . . . . . . . . . . . .
Tagging Block Parameters . . . . . . . . . . . . . . . . . . . . . . . . . .
Tagging Block Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating the Target Application and Model-Specific COM
Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Model-Specific COM Interface Library
(model_nameCOMiface.dll) . . . . . . . . . . . . . . . . . . . . . . .
Creating a New Microsoft Visual Basic Project . . . . . . . . . .
4-4
4-5
4-5
4-7
4-8
4-11
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-13
4-16
4-18
Referencing the xPC Target COM API and Model-Specific
COM Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating the Graphical Interface . . . . . . . . . . . . . . . . . . . . .
Setting Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Writing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Creating the General Declarations . . . . . . . . . . . . . . . . . . .
Creating the Load Procedure . . . . . . . . . . . . . . . . . . . . . . . .
Creating Event Procedures . . . . . . . . . . . . . . . . . . . . . . . . . .
Referencing Parameters and Signals Without Using
Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Testing the Visual Basic Application . . . . . . . . . . . . . . . . . .
Building the Visual Basic Application . . . . . . . . . . . . . . . . .
Deploying the API Application . . . . . . . . . . . . . . . . . . . . . . .
Creating a New Visual Basic Project Using Microsoft Visual
Studio 8.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4-20
4-22
4-24
4-25
4-26
4-26
4-27
4-33
4-37
4-38
4-38
4-40
xPC Target API Examples
5
Visual Basic GUI Using .NET . . . . . . . . . . . . . . . . . . . . . . .
Before Starting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Accessing the Demo Project Solution . . . . . . . . . . . . . . . . . .
Rebuilding the Demo Project Solution . . . . . . . . . . . . . . . . .
Using the Demo Executable . . . . . . . . . . . . . . . . . . . . . . . . .
5-2
5-2
5-3
5-3
5-4
Visual Basic GUI Using COM . . . . . . . . . . . . . . . . . . . . . . .
Before Starting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Accessing the sf_car_xpc Project . . . . . . . . . . . . . . . . . . . . .
Rebuilding the sf_car_xpc Project . . . . . . . . . . . . . . . . . . . .
Using the sf_car_xpc Executable . . . . . . . . . . . . . . . . . . . . .
5-5
5-6
5-6
5-7
5-7
Command Line Scripts Using COM API . . . . . . . . . . . . . .
Tcl/Tk Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Required Tcl/Tk Software . . . . . . . . . . . . . . . . . . . . . . . . . . .
Using the Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5-8
5-8
5-9
5-9
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
vii
xPC Target API Reference for Microsoft .NET
Framework
6
xPC Target API for Microsoft .NET Framework
Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6-2
6-2
6-3
6-3
6-4
6-4
6-5
6-5
6-6
xPC Target API for Microsoft .NET Framework —
Alphabetical List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6-7
xPC Target API Reference for C
7
viii
Contents
C API Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7-2
7-2
7-3
7-4
7-6
7-7
7-7
7-8
7-9
C API Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7-10
C API Structures and Functions — Alphabetical List . .
7-14
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target API Reference for COM
8
COM API Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Target Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
File Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8-2
8-2
8-3
8-4
8-6
8-6
8-7
8-7
8-8
COM API Methods — Alphabetical List . . . . . . . . . . . . . .
8-9
Index
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
ix
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫‪Contents‬‬
‫‪x‬‬
1
Introduction
• “xPC Target APIs” on page 1-2
• “xPC Target API for Microsoft .NET Framework” on page 1-3
• “xPC Target C API” on page 1-5
• “xPC Target COM API” on page 1-7
• “Required Products” on page 1-9
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
1
Introduction
xPC Target APIs
The xPC Target™ software provides several APIs that enable you to create
custom applications to control real-time applications running on target
computers.
The xPC Target software provides multiple types of xPC Target API (for
example, the xPC Target API for Microsoft® .NET Framework, xPC Target C,
and xPC Target COM). These interfaces provide the same functionality for
you to write custom solutions (for example, client target applications and
batch runs) that use the xPC Target software. The xPC Target documentation
collectively refers to these APIs as xPC Target API.
The xPC Target APIs allow you to:
• Establish communication between the host computer and the target
computer via an Ethernet or serial connection
• Load the target application, a .dlm file, to the target computer
• Run that application on the target computer
• Monitor the behavior of the target application on the target computer
• Stop that application on the target computer
• Unload the target application from the target computer
• Close the connection to the target computer
The following sections describe each library:
• “xPC Target API for Microsoft .NET Framework” on page 1-3
• “xPC Target C API” on page 1-5
• “xPC Target COM API” on page 1-7
1-2
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ API for Microsoft® .NET Framework
xPC Target API for Microsoft .NET Framework
The xPC Target API for Microsoft .NET Framework consists of objects
arranged in hierarchical order. Each of these objects has methods and
properties that allow you to manipulate and interact with it. The API provides
a number of classes, including those for target applications, scopes, the file
system, and the target computer. The xPCTargetPC class is the main class
that sits on top of a hierarchy of classes. This document presents the API
reference. You can use these API functions from languages and applications
that support managed code.
The Microsoft Windows® API supplies the infrastructure for using threads.
The xPC Target API for Microsoft .NET Framework builds on top of that
infrastructure to provide a programming model that includes asynchronous
support. You do not need prior knowledge of threads programming to use
this API.
The xPC Target .NET object model closely models the xPC Target system.
One xPCTargetPC Class object represents one xPC Target system.
An xPCApplication Class object represents the target application. It
contains xPCSignals, xPCParameters, and xPC*Logger objects. These objects
respectively represent the signals, parameters, and logs available in the
target application.
An xPCFileSystem Class object represents the entire xPC Target file system.
It contains objects like the following:
• xPCDriveInfo, which represents a volume drive that the target computer
recognizes.
• xPCDirectoryInfo, which represents a target computer folder item.
• xPCFileInfo, which represents a target computer file item.
The following graphic outlines the xPCTargetPC hierarchy.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
1-3
1
Introduction
xPCTargetPC
Application
Signals
Signal
Parameters
Parameter
Logger
States
State
DataLogObject
Time
DataLogObject
Outputs
Output
DataLogObject
TET
DataLogObject
Scopes
HostScopes
HostScope
ScopeSignals
ScopeSignal
DataScSignalObject
TargetScopes
TargetScope
ScopeSignals
ScopeSignal
FileScopes
FileScope
ScopeSignals
ScopeSignal
DataScSignalObject
1-4
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
File system
Drives
Drive
Directories
Files
Directories
Files
xPC Target™ C API
xPC Target C API
The xPC Target C API consists of a series of C functions that you can call from
a C or C++ application. This API is designed for multi-threaded operation.
The xPC Target C API DLL consists of C functions that you can incorporate
into a high-level language application. A user can use an application written
through either interface to load, run, and monitor an xPC Target application
without interacting with MATLAB®. With the xPC Target C API, you write
the application in a high-level language (such as C, C++, or Java®) that
works with an xPC Target application; this option requires that you are an
experienced programmer.
The xpcapi.dll file contains the xPC Target C API dynamic link library,
which contains over 90 functions you can use to access the target application.
Because xpcapi.dll is a dynamic link library, your program can use run-time
linking rather than static linking at compile time. Accessing the xPC Target C
API DLL is beneficial when you are building applications using development
environments such as Microsoft Foundation Class Library/Active Template
Library (MFC/ATL), DLL, Win32 (non-MFS) program and DLL, and console
programs integrating with third-party product APIs (for example, Altia®).
All custom xPC Target C API applications must link with the xpcapi.dll
file (xPC API DLL). Also associated with the dynamic link library is the
xpcinitfree.c file. This file contains functions that load and unload the xPC
Target C API. You must build this file along with the custom xPC Target C
API application.
The xPC Target C API consists of blocking functions. For communications
between the host and target computer, a default timeout of 5 seconds controls
how long a target computer can take to communicate with a host computer.
The documentation reflects the fact that the API is written in the C
programming language. However, the API functions are usable from other
languages and applications, such as C++ and Java.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
1-5
1
Introduction
Note To write a non-C application that calls functions in the xPC Target C
API library, refer to the compiler documentation for a description of how
to access functions from a library DLL. You must follow these directions to
access the xPC Target C API DLL.
1-6
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ COM API
xPC Target COM API
Note The xPC Target COM API is no longer being enhanced. You should use
the xPC Target API for Microsoft .NET Framework instead. See “xPC Target
API for Microsoft .NET Framework” on page 1-3
The xPC Target COM API is an open environment application program
interface designed to work with Microsoft COM and the xPC Target C API.
The COM API is not designed for multi-threaded operation.
With xPC Target COM API, you use a graphical development environment to
create a GUI that works with an xPC Target application. Designed to work
with Microsoft COM, the xPC Target COM API conforms to the component
object model standard established by Microsoft.
The xPC Target COM API is a programming layer that sits between you and
the xPC Target C API. The difference between the C API and this API is that
while the C API is a dynamic link library of C functions, the xPC Target
COM API dynamic link library is an organized collection of objects, classes,
and functions. You access this collection through a graphical development
environment such as Microsoft Visual Basic®. Using such a graphical
development environment, you can create a custom GUI application that can
work with one xPC Target application.
The xPC Target COM API library depends on xpcapi.dll, the xPC Target
dynamic link library. However, the xPC Target C API is independent of the
xPC Target COM API.
The xPC Target COM API consists of blocking functions. For communications
between the host and target computer, a default timeout of 5 seconds controls
how long a target computer can take to communicate with a host computer.
The xPC Target COM API has the following features:
• A DLL component server library — xpcapicom.dll is a component server
DLL library COM interface consisting of component interfaces that
access the target computer. The COM API library enhances the built-in
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
1-7
1
Introduction
functionality of a programming language by allowing you to easily access
the xPC Target C API for rapid development of xPC Target GUI.
• Built on top of the xPC Target C API — You can use the data, methods,
and structured object model hierarchy in xpcapicom.dll to interface
with an xPC Target application via an application such as Visual Basic.
xpcapicom.dll also enables search functionality and bidirectional
browsing capabilities. Generally, you view object models by selecting a type
and viewing its members. Using the xPC Target COM API library, you can
select a member and view the types to which it belongs.
• Programming language independent — This section describes how to create
an xPC Target COM API application using Visual Basic. However, the xPC
Target COM API interface is not limited to this third-party product. You
can add the COM API library to development environments that can access
COM libraries, such as Visual C++® or Java, as well as scripting languages
such as Perl, Python, and Basic.
• Ideal for use with Visual Basic — The xPC Target COM API works well
with Visual Basic, and extends the event-driven programming environment
of Visual Basic.
1-8
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Required Products
Required Products
Refer to System Requirements for a list of the required xPC Target products.
In addition, you need the following products:
• Third-party Development Environment — To build a custom application
that references interfaces in the xPC Target API for the .NET Framework,
use a third-party development environment and compiler that can interact
with .NET. For example, the Windows PowerShell™, Microsoft Visual
Studio®, and the MATLAB environments.
• Third-Party Compiler — To build a custom application (.exe, DLL) that calls
functions from the xPC Target API libraries, use a third-party compiler that
generates code for Win32 systems. You can write client applications that
call these functions in another high-level language, such as C#, C++, or C.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
1-9
‫‪Introduction‬‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫‪1‬‬
‫‪1-10‬‬
2
xPC Target API for
Microsoft .NET Framework
• “Using the xPC Target API for .NET Framework” on page 2-2
• “xPC Target .NET API Object Model” on page 2-4
• “xPC Target API for .NET Framework Classes” on page 2-5
• “xPC Target .NET API Usage” on page 2-8
• “xPC Target .NET API Application Deployment” on page 2-10
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
2
xPC Target™ API for Microsoft® .NET Framework
Using the xPC Target API for .NET Framework
The xPC Target API for .NET framework is a fully managed .NET framework
component. Although this framework is designed to work with the Microsoft
Visual Studio software, you can use it with other development environments
that support the .NET framework. This API is a fully programmable
tool set. It contains easy-to-use components and types that enable you to
quickly design xPC Target client applications. You can use this API with a
programming language that supports .NET technology.
In this section...
“Features and Benefits” on page 2-2
“xpcosc Client Applications” on page 2-3
“File Server Browser Client Application” on page 2-3
Features and Benefits
The xPC Target API for .NET framework includes the following features
and benefits:
• Microsoft Visual Studio design time
• Intuitive object model (modeled after the xPC Target system environment)
• Simplified client model programming for asynchronous communication
with the target computer
The xPC Target .NET API provides multiple ways for you to interface client
side applications with target computers, including outside the MATLAB
environment. For example
• Visual instrumentation for your real-time application
• Custom applications to perform data observation, collection, and archiving
• Real-time application debugging from a remote client computer
• Calibration, test, and evaluation of real-time processes
• Real-time data analysis
2-2
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Using the xPC Target™ API for .NET Framework
• Batch processing and automation scripts, which can run in a shell
environment (such as PowerShell) or as a process console standalone
application (.exe file)
xpcosc Client Applications
The Simple Client Application with the .NET API example illustrates
how to use the xPC Target API for Microsoft .NET Framework to create client
applications to interface with the xpcosc model downloaded on the target
computer. This example provides two client applications:
• Example1 — Illustrates a client application that runs on the host computer.
The client application provides a GUI through which you can enter the IP
address port of the target computer with which you want to connect. It
consists of the toolbox items:
-
Buttons
TextBoxes
TrackBar
• Example2 — In addition to the same toolbox controls as Example 1, this
example also contains a chart that displays signals from the xpcosc target
application.
File Server Browser Client Application
The API xPC Target API for the .NET Framework has the following example,
located in:
matlabroot\toolbox\rtw\targets\xpc\api\xPCFrameworkSamples\FileSystemBrowser
This example illustrates how to use the xPC Target API for the .NET
Framework to create a file browser to browse folders and files on the target
computer file system. The application resides on the host computer and
connects to the target computer to browse its file system.
This is a C# application project developed with the Microsoft Visual Studio
2008 IDE. It illustrates how to build a standalone xPC Target executable to
connect to a target computer and a host computer. See the Readme.txt file in
the example folder for instructions on how to access and build the example
code.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
2-3
2
xPC Target™ API for Microsoft® .NET Framework
xPC Target .NET API Object Model
To develop solutions that use the xPC Target .NET API, you can interact
with the API objects in the xPC Target .NET API object model. The object
model corresponds to structure of the xPC Target environment. The object
model is hierarchical and straightforward. The following is a conceptual view
of the xPCTargetPC object.
xPC Target PC
Applications
Scopes
Parameters
Logs
Signals
File System
Drives
Files
2-4
Directories
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ API for .NET Framework Classes
xPC Target API for .NET Framework Classes
The xPC Target .NET API provides an expansive object model layer. You
should start your client model development on the following objects:
In this section...
“Mathworks.xPCTarget.Framework.xPCTargetPC” on page 2-5
“Mathworks.xPCTarget.Framework.xPCApplication” on page 2-6
“Mathworks.xPCTarget.Framework.xPCScopes” on page 2-6
“Mathworks.xPCTarget.Framework.xPCParameters” on page 2-6
“Mathworks.xPCTarget.Framework.xPCParameter” on page 2-6
“Mathworks.xPCTarget.Framework.xPCSignals” on page 2-7
“Mathworks.xPCTarget.Framework.xPCSignal” on page 2-7
“Mathworks.xPCTarget.Framework.xPCAppLogger” on page 2-7
Mathworks.xPCTarget.Framework.xPCTargetPC
The xPCTargetPC object represents the overall xPC Target environment
system. It is at the root level of the object model and exposes information
about the xPC Target session after connecting to your target computer. It
provides many class member functions that you use to access information
and manipulate its behavior.
The xPCTargetPC object principally supports a run-time user-driven mode
of execution. However, the xPCTargetPC type is also a .NET component
implementation that supports an optional developer-driven model of
execution, a design-time capability. You can integrate the design-time
capability with the Microsoft Visual Studio IDE. It supports creation and
management of the xPCTargetPC component. With this capability, you can
perform the following operations with xPCTargetPC components
• Drag and drop into the form design
• Property configuration
• Delete from the form design
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
2-5
2
xPC Target™ API for Microsoft® .NET Framework
Design-time support includes a properties window in which you can configure
design-time members, code serialization, and property-editing support with
UI type editors. This supports enables you to build xPC Target application
quickly and effortlessly by dragging the component and using its functionality
as required. For more information on using Microsoft Visual Studio .NET, see
http://msdn.microsoft.com/en-us/library/aa973739(v=vs.71).aspx.
Mathworks.xPCTarget.Framework.xPCApplication
The xPCApplication object represents the xPC Target real-time application
that you generate from a Simulink® model and download to the target
computer. The xPCApplication object exposes information and properties of
the target application. It also contains members you need to:
• Access application information
• Manipulate application behavior
• Return other objects such as child components of the application
Mathworks.xPCTarget.Framework.xPCScopes
The xPCScopes object represents a container or place holder to access and
interface with xPC Target scopes. This object enables advanced signal data
acquisition techniques. With this object, you can access child objects related
to scopes.
Mathworks.xPCTarget.Framework.xPCParameters
The xPCParameters object represents a container or place holder to access
application parameters. You can access xPCParameter objects with this
object.
Mathworks.xPCTarget.Framework.xPCParameter
The xPCParameter object represents a specific application parameter, which
represents a run-time parameter of a specific block. With this object, you can
access information related to the block parameter. With this object, you can
also tune parameter values during simulation.
2-6
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ API for .NET Framework Classes
Mathworks.xPCTarget.Framework.xPCSignals
The xPCSignals object represents a container or place holder to access the
application signals. With this object, you can access xPCSignal objects.
Mathworks.xPCTarget.Framework.xPCSignal
The xPCSignal object represents a specific application signal, which
represents the port signal of a non-graphical block output. With this object,
you can access information related to the signal. It also allows you to monitor
signal behavior during simulation.
Mathworks.xPCTarget.Framework.xPCAppLogger
The xPCAppLogger object represents a place holder for logging objects. It
contains members that return specific logging objects.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
2-7
2
xPC Target™ API for Microsoft® .NET Framework
xPC Target .NET API Usage
This topic presents the xPC Target API for .NET framework reference using
the C# language and the Microsoft Visual Studio environment. At a minimum:
• Use the xPCTargetPC component in the Visual Studio environment. This
addition provides convenient design-time features. To do this:
1 Add the xPCTargetPC component to the Visual Studio Toolbox.
2 To use this component, create a Windows application.
3 Add an xPCTargetPC object to the application form by dragging an
xPCTargetPC control from the Toolbox window to the design surface.
The xPCTargetPC control makes available in the Visual Studio
Properties window its data and appearance properties. You can click
the xPCTargetPC control in the design surface to explore and customize
the xPCTargetPC properties.
• Add a reference for xPCFramework.dll to your project (for example, to
create a console application), include the following in your code. Doing so
enables you to access the types available from the xPC Target environment
using MathWorks.xPCTarget.FrameWork;
• To use the design-time capability of the Microsoft Visual Studio
environment, copy the xpcapi.dll file to the same folder as the application
executable. You also need this file to execute the application.
The xPC Target library has a 32-bit and a 64-bit version of the xpcapi.dll.
Note On 64-bit platforms, if you build a 64–bit target application in the
Microsoft Visual Studio environment, and want to use the xPCTargetPC
nonvisual component; place the 32-bit version of xpcapi.dll in the solution
folder and place the 64-bit version of xpcapi.dll in the application folder
that contains the .exe file. Placing the 32-bit version of xpcapi.dll in
the solution folder enables you to use the design time capabilities of the
Visual Studio environment.
2-8
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ .NET API Usage
• Do not test communication between host and target computers
(xPCTargetPC.Ping method) until you have connected to the target
computer (xPCTargetPC.Connect method).
Note Be sure to disconnect the target computer from the host computer
before starting .NET client applications. A target computer can be
connected to only one host computer at a time. You can use xpctargetping
to verify connectivity; this function disconnects from the target computer
when done.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
2-9
2
xPC Target™ API for Microsoft® .NET Framework
xPC Target .NET API Application Deployment
This topic describes guidelines when distributing your xPC Target API for
Microsoft .NET Framework GUI application:
• You must have an xPC Target Embedded Option™ license to deploy or
distribute your GUI application.
• When you build your application, the Visual Studio software builds the
application files for your executable, including a *.exe file. Include these
files in the same folder when deploying or distributing your application.
• Keep in mind the relationship between the GUI application,
xPCFramework.dll, and xpcapi.dll. In particular, the GUI application
depends on xPCFramework.dll, which depends on xPCFramework.dll.
Be sure to provide the version of xpcapi.dll (32-bit or a 64-bit) for which
your application was built.
2-10
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3
xPC Target API for C
• “Using the C API” on page 3-2
• “Visual C Console Application” on page 3-4
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3
xPC Target™ API for C
Using the C API
Keep the following guidelines in mind when you begin to write xPC Target C
API applications with the xPC Target C API DLL:
• Carefully match the function data types as documented in the function
reference. For C, the API includes a header file that matches the data types.
• To write a non-C application that calls functions in the xPC Target C API
library, refer to the compiler documentation for a description of how to
access functions from a library DLL. You must follow these directions to
access the xPC Target C API DLL
• If you want to rebuild the model (sf_car_xpc), or otherwise use the
MATLAB environment, you must have xPC Target Version 2.0 or later.
To determine the version of xPC Target you are currently using, at the
MATLAB command line, type
xpclib
This opens the xPC Target Simulink blocks library. The version of xPC
Target should be at the bottom of the window.
• You can work with xPC Target applications with either MATLAB or an
xPC Target C API application. If you are working with an xPC Target
application simultaneously with a MATLAB session interacting with
the target, keep in mind that only one application can access the target
computer at a time. To move from the MATLAB session to your application,
in the MATLAB Command Window, type
close(xpc)
This frees the connection to the target computer for use by your xPC Target
C API application. Conversely, you will need to quit your application, or do
the equivalent of calling the function xPCClosePort, to access the target
from a MATLAB session.
• The xPC Target C API functions that communicate with the target
computer check for timeouts during communication. If a timeout occurs,
these functions will exit with the global variable xPCError set to either
ECOMTIMEOUT (serial connections) or ETCPTIMEOUT (TCP/IP connections).
3-2
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Using the C API
Use the xPCGetLoadTimeOut and xPCSetLoadTimeOut functions to get and
set the timeout values, respectively.
There are a few things that are not covered in “C API Functions” and “C API
Structures and Functions — Alphabetical List” for the individual functions,
because they are common to almost all the functions in the xPC Target C
API. These are
• Almost every function (except xPCOpenSerialPort, xPCOpenTcpIpPort,
xPCGetLastError, and xPCErrorMsg) has as one of its parameters the
integer variable port. This variable is returned by xPCOpenSerialPort and
xPCOpenTcpIpPort, and should be used to represent the communications
link with the target computer.
• Almost every function (except xPCGetLastError and xPCErrorMsg) sets a
global error value in case of error. The application obtains this value by
calling the function xPCGetLastError, and retrieves a descriptive string
about the error by using the function xPCErrorMsg. Although the actual
error values are subject to change, a zero value typically means that the
operation completed without producing an error, while a nonzero value
typically signifies an error condition. Note also that the library resets the
error value every time an API function is called; therefore, your application
should check the error status as soon as possible after a function call.
Some functions also use their return values (if applicable) to signify that
an error has occurred. In these cases as well, you can obtain the exact
error with xPCGetLastError.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-3
3
xPC Target™ API for C
Visual C Console Application
This topic shows how to use the xPC Target C API to create a Win32 console
application written in C. You can use this example as a template to write
your own application.
In this section...
“Target Application” on page 3-4
“Folders and Files” on page 3-4
“Building the xPC Target Application” on page 3-6
“Creating a Visual C Application” on page 3-6
“Building a Visual C Application” on page 3-9
“Running an xPC Target Visual C API Application” on page 3-10
“Using the xPC Target C API Application” on page 3-10
“C Code for sf_car_xpc.c” on page 3-16
Target Application
Before you start, you should have an existing xPC Target application that
you want to load and run on a target computer. The following topics use
the target application sf_car_xpc.dlm, built from the Simulink model
sf_car_xpc, which models an automatic transmission control system. The
automatic transmission control system consists of modules that represent the
engine, transmission, and vehicle, with an additional logic block to control
the transmission ratio. User inputs to the model are in the form of throttle
(%) and brake torque (pound-foot). You can control the target application
through MATLAB with the Simulink External Mode interface, or through a
custom xPC Target C API application.
Folders and Files
This folder contains the C source of a Win32 console application that serves
as an example for using the xPC Target C API. The sf_car_xpc files are
in the folder
C:\matlabroot\toolbox\rtw\targets\xpc\api
3-4
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
Filename
Description
VisualBasic\Models\sf_car_xpc\sf_car_xpc
Simulink model for use with xPC Target
VisualBasic\Models\sf_car_xpc\sf_car_xpc.dlm
Target application compiled from Simulink
model
VisualC\sf_car_xpc.dsp
Project file for API application
sf_car_xpc.c
Source code for API application
VisualC\sf_car_xpc.exe
Compiled API application
VisualBasic\Models\xpcapi.dll
xPC Target C API functions for supported
programming languages. Place this file in
one of the following, in order of preference:
• Folder from which the application is
loaded
• Windows system folder
The xPC Target C API files are in the folder
C:\matlabroot\toolbox\rtw\targets\xpc\api
You will need the files listed below for creating your own API application
with Microsoft Visual C++.
Filename
Description
xpcapi.h
Mapping of data types between xPC Target C API
and Visual C
xpcapiconst.h
Symbolic constants for using scope, communication,
and data-logging functions
xpcinitfree.c
C functions to upload API from xpcapi.dll
xpcapi.dll
xPC Target C API functions for supported
programming languages
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-5
3
xPC Target™ API for C
Building the xPC Target Application
These tutorials use the prebuilt xPC Target application
C:\matlabroot\toolbox\rtw\targets\
xpc\api\VisualC\sf_car_xpc.dlm
You can rebuild this application for your example:
1 Create a new folder under your MathWorks® folder. For example,
D:\mwd\sf_car_xpc2
2 Create a Simulink model and save to this folder. For example,
sf_car_xpc2
3 Build the target application with Simulink Coder™ and Microsoft Visual
C++. The target application file sf_car_xpc2.dlm is created.
Using Another C/C++ Compiler
These tutorials describe how to create and build C applications using
Microsoft Visual C++. However, to build an xPC Target C API application,
you can use other C/C++ compilers, provided they are capable of generating a
Win32 application. You will need to link and compile the xPC Target C API
application along with xpcinitfree.c to generate the executable. The file
xpcinitfree.c contains the definitions for the files in the xPC Target C
API and is located at
C:\matlabroot\toolbox\rtw\targets\xpc\api
Creating a Visual C Application
This tutorial describes how to create a Visual C application. It is assumed
that you know how to write C applications. Of particular note when writing
xPC Target C API applications,
• Call the function xPCInitAPI at the start of the application to load the
functions.
• Call the function xPCFreeAPI at the end of the application to free the
memory allocated to the functions.
3-6
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
To create a C application with a program such as Microsoft Visual C++,
1 From the previous tutorial, change folder to the new folder. This is your
working folder. For example,
D:\mwd\sf_car_xpc2
2 Copy the files xpcapi.h, xpcapi.dll, xpcapiconst.h, and xpcintfree.c
to the working folder. For example,
D:\mwd\sf_car_xpc2
3 Click the Start button, choose the All Programs option, and choose the
Microsoft Visual C++ entry. Select the Microsoft Visual C++ option.
The Microsoft Visual C++ application is displayed.
4 From the File menu, click New.
5 At the New dialog box, click the File tab.
6 In the left pane, select C++ Source File. In the right, enter the name
of the file. For example, sf_car_xpc.c. Select the folder. For example,
C:\mwd\sf_car_xpc2.
7 Click OK to create this file.
8 Enter your code in this file. For example, you can enter the contents of
sf_xpc_car.c into this file.
9 From the File menu, click New.
10 At the New dialog box, click the Projects tab.
11 In the left pane, select Win32 Console Application. On the right, enter
the name of the project. For example, sf_car_xpc. Select the working
folder from step 1. For example, C:\mwd\sf_car_xpc2.
12 To create the project, click OK.
A Win32 Console Application dialog box is displayed.
13 To create an empty project, select An empty project.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-7
3
xPC Target™ API for C
14 Click Finish.
15 To confirm the creation of an empty project, click OK at the following
dialog box.
16 To add the C file you created in step 7, from the Project menu, select the
Add to Project option and select Files.
17 Browse for the C file you created in step 7. For example,
D:\mwd\sf_car_xpc2\sf_car_xpc.c
Click OK.
18 Browse for the xpcinitfree.c file. For example, D:\mwd\xpcinitfree.c.
Click OK.
Note The code for linking in the functions in xpcapi.dll is in the file
xpcinitfree.c. You must compile and link xpcinitfree.c with your
custom application for it to load xpcapi.dll at execution time.
19 If you did not copy the files xpcapi.h, xpcapi.dll, and xpcapiconst.h
into the working or project folder, you should either copy them now, or
also add these files to the project.
20 From the File menu, click Save Workspace.
When you are ready to build your C application, go to “Building a Visual
C Application” on page 3-9.
Placing the Target Application File in a Different Folder
The sf_car_xpc.c file assumes that the xPC Target application file
sf_car_xpc.dlm is in the same folder as sf_car_xpc.c. If you move that
target application file (sf_car_xpc.dlm) to a new location, change the path
to this file in the API application (sf_car_xpc.c) and recompile the API
application. The relevant line in sf_car_xpc.c is in the function main(),
and looks like this:
3-8
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
xPCLoadApp(port, ".", "sf_car_xpc"); checkError("LoadApp: ");
The second argument (".") in the call to xPCLoadApp is the path to
sf_car_xpc.dlm. The "." indicates that the files sf_car_xpc.dlm and
sf_car_xpc.c are in the same folder. If you move the target application,
enter its new path and rebuild the xPC Target C API application.
Building a Visual C Application
This tutorial describes how to build the Visual C application from the
previous tutorial, or to rebuild the example executable sf_car_xpc.exe,
using Microsoft Visual C++:
1 To build your own application using the xPC Target C API, copy the files
xpcapi.h, xpcapi.dll, xpcapiconst.h, and xpcinitfree.c into the
working or project folder.
2 If Microsoft Visual C++ is not already running, click the Start button,
choose the All Programs option, and choose the Microsoft Visual C++
option.
3 From the File menu, click Open.
The Open dialog box is displayed.
4 Use the browser to select the project file for the application you want to
build. For example, sf_car_xpc.dsp.
5 If a corresponding workspace file (for example, sf_car_xpc.dsw) exists for
that project, a dialog box prompts you to open that workspace instead.
Click OK.
6 Build the application for the project. From the Build menu, select either
the Build project_name.exe or Rebuild All option.
Microsoft Visual C++ creates a file named project_name.exe, where
project_name is the name of the project.
When you are ready to run your Visual C Application, go to “Running an xPC
Target Visual C API Application” on page 3-10.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-9
3
xPC Target™ API for C
Running an xPC Target Visual C API Application
Before starting the API application sf_car_xpc.exe, verify the following:
• The file xpcapi.dll must either be in the same folder as the xPC Target
C API application executable, or it must be in the Windows system folder
(typically C:\windows\system or C:\winnt\system32) for global access.
The xPC Target C API application depends on this file, and will not run
if the file is not found. The same is true for other applications you write
using xPC Target C API functions.
• The compiled target application sf_car_xpc.dlm must be in the same
folder as the xPC Target C API executable. Do not move this file out of
this folder. Moving the file requires you to change the path to the target
application in the API application and recompile, as described in “Building
a Visual C Application” on page 3-9.
Using the xPC Target C API Application
To run a xPC Target C API application, you must have a working target
computer running at least xPC Target Version 2.0 (Release 13).
This tutorial assumes that you are using the xPC Target C API application
sf_car_xpc.exe that comes with xPC Target. In turn, sf_car_xpc.exe
expects that the xPC Target application is sf_car_xpc.dlm.
If you are going to run a version of sf_car_xpc.exe that you compiled
yourself using the sf_car_xpc.c code that comes with xPC Target, you can
run that application instead. Verify the following files are in the same folder:
• sf_car_xpc.exe, the xPC Target C API executable
• sf_car_xpc.dlm, the xPC Target application to be loaded to the target
computer
• xpcapi.dll, the xPC Target C API dynamic link library
If you copy this file to the Windows system folder, you do not need to
provide this file in the same folder.
3-10
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
How to Run the sf_car_xpc Executable
1 Create an xPC Target boot disk with a serial or network communication. If
you use serial communications, set the baud rate to 115200. Otherwise,
create the boot disk as directed in xPC Target Getting Started.
2 Start the target computer with the xPC Target boot disk.
The target computer displays messages like the following in the top
rightmost message area.
System:
Host-Target Interface is RS232 (COM1/2)
or
System:
Host-Target Interface is TCP/IP (Ethernet)
3 If you have downloaded target applications to the target computer through
MATLAB, in the MATLAB window, type
close(xpc)
This command disconnects MATLAB from the target computer and leaves
the target computer ready to connect to another client.
4 On the host computer, open a DOS window. Change folder to
C:\matlabroot\toolbox\rtw\targets\xpc\api\VisualC
If you are running your own version of sf_car_xpc.exe, change to the
folder that contains the executable and xPC Target application. For
example,
D:\mwd\sf_car_xpc2
5 From that DOS window, enter the command to start the example
application on the host computer and download the target application to
the target computer.
The syntax for the example command is
sf_car_xpc {-t IpAddress:IpPort|-c COMport}
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-11
3
xPC Target™ API for C
If you set up the xPC Target boot disk to use TCP/IP, then give the target
computer’s IP address and IP port as arguments to sf_car_xpc, along with
the option -t. For example, at the DOS prompt, type
sf_car_xpc -t 192.168.0.1:22222
If you set up the xPC Target boot disk to use RS-232, give the serial port
number as a command-line option. Note that indexing of serial ports starts
from 0 instead of 1. For example, if you are using serial communication
from COM port 1 on the host computer, type
sf_car_xpc -c 0
On the host computer, the example application displays the following
message:
*-------------------------------------------------------------*
*
xPC Target API Demo: sf_car_xpc.
*
*
*
* Copyright (c) 2000 The MathWorks, Inc. All Rights Reserved. *
*-------------------------------------------------------------*
Application sf_car_xpc loaded. SampleTime 0.001 StopTime: -1
R
Br
Th G
VehSpeed
VehRPM
- ---- -- - ---------- --------N
0
0 0
0.000
1000.000
The relevant line here is the last one, which displays the status of the
application. The headings are as follows:
3-12
R
The status of the target application: R if running, N if
stopped
Br
The brake torque; legal values range from 0 to 4000
Th
The throttle as a percentage (0 - 100) of the total
G
Gear the vehicle is in (ranges between 1 and 4)
VehSpeed
Speed of the vehicle in miles per hour
VehRPM
Revolutions per minute of the vehicle engine (0 to 6000)
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
From this screen, various keystrokes control the target application. The
following list summarizes these keys:
Key
Action
s
Start or stop the application, depending on whether
the application is active or not.
T
Increase the throttle by 1 (does not go above 100).
t
Decrease the throttle by 1 (does not go below 0).
B
Increase the brake value by 20 (does not go above
4000).
b
Decrease the brake value by 20 (does not go below 0).
Q or Ctrl+C
Quit the application.
Note Note that a positive value for the brake automatically sets the
throttle value to 0, and a positive value for the throttle automatically sets
the brake value to 0.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-13
3
xPC Target™ API for C
The target computer displays the following messages and three scopes.
6 Hold down the Shift key and hold down T until the value of Th reaches 100.
3-14
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
7 Press s to start the application.
The first scope (SC1) shows the throttle rising to a maximum value of 100
and the vehicle speed gradually increasing. The third scope (SC3) shows
the vehicle RPM. Notice the changes in the vehicle RPM as the gears shift
from first to fourth gear as displayed in the third numerical scope (SC2).
8 When you are done testing the example application, type Q or Ctrl+C.
The example application is disconnected from the target computer, so you
can reconnect to MATLAB.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-15
3
xPC Target™ API for C
C Code for sf_car_xpc.c
This section contains the C code for the sf_car_xpc.c application:
/* File:
sf_car_xpc.c
* Abstract: Demonstrates the use of the xPC Target C-API in Human-Machine
*
interaction. This file generates a Win32 Console application,
*
which when invoked loads the sf_car_xpc.dlm compiled application
*
on to the xPC Target PC.
*
*
To build the executable, use the Visual C/C++ project
*
sf_car_xpc.dsp.
*
* Copyright 2000-2004 The MathWorks, Inc.
*/
/* Standard include files */
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <ctype.h>
#include <conio.h>
#include <windows.h>
/* xPC Target C-API specific includes */
#include "xpcapi.h"
#include "xpcapiconst.h"
#define SERIAL 0
#define TCPIP
1
/* max and min are defined by some compilers, so we wrap them in #ifndef's */
#ifndef max
#define max(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif
/* Global Variables */
int
3-16
mode = TCPIP, comPort = 0;
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
int
port;
int
thrPID, brakePID, rpmSID, speedSID, gearSID;
char *ipAddress, *ipPort, *pathToApp = NULL;
/* Function prototypes */
double getParam(int parIdx);
void
setParam(int parIdx, double parValue);
void
findParam(char *block, char *param, int *id);
void
findSignal(char *sig, int *id);
void
Usage(void);
void
cleanUp(void);
void
checkError(char *str);
void
processKeys(void);
void
parseArgs(int argc, char *argv[]);
int
str2Int(char *str);
/* Function: main ============================================================
* Abstract: Main function for the sf_car_xpc demo
*/
int main(int argc, char *argv[]) {
printf("\n"
"*-------------------------------------------------------------*\n"
"*
xPC Target API Demo: sf_car_xpc.
"*
*\n"
*\n"
"* Copyright (c) 2000 The MathWorks, Inc. All Rights Reserved. *\n"
"*-------------------------------------------------------------*\n"
"\n");
parseArgs(argc, argv);
atexit(cleanUp);
/* Initialize the API */
if (xPCInitAPI()) {
fprintf(stderr, "Could not load api\n");
return -1;
}
if (mode == SERIAL)
port = xPCOpenSerialPort(comPort, 0);
else if (mode == TCPIP)
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-17
3
xPC Target™ API for C
port = xPCOpenTcpIpPort(ipAddress, ipPort);
else {
fprintf(stderr, "Invalid communication mode\n");
exit(EXIT_FAILURE);
}
checkError("PortOpen: ");
xPCLoadApp(port, ".", "sf_car_xpc"); checkError("LoadApp: ");
printf("Application sf_car_xpc loaded, SampleTime: %g
StopTime: %g\n\n",
xPCGetSampleTime(port), xPCGetStopTime(port));
checkError(NULL);
findParam("Throttle", "Value", &thrPID);
findParam("Brake", "Value", &brakePID);
findSignal("Engine/rpm", &rpmSID);
findSignal("Vehicle/mph", &speedSID);
findSignal("shift_logic/p1", &gearSID);
processKeys();
/* Heart of the application */
if (xPCIsAppRunning(port)) {
xPCStopApp(port);
}
return 0;
} /* end main() */
/* Function: processKeys =====================================================
* Abstract: This function reads and processes the keystrokes typed by the
*
user and takes action based on them. This function runs for most
*
of the program life.
*/
void processKeys(void) {
int
c = 0;
double throttle, brake;
throttle = getParam(thrPID);
brake
= getParam(brakePID);
fputs("\nR
fputs(
"-
Br
Th
G
VehSpeed
----
--
-
----------
VehRPM
while (1) {
if (_kbhit()) {
3-18
\n", stdout);
-------- \n", stdout);
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual C Console Application
c = _getch();
switch (c) {
case 't':
if (throttle)
setParam(thrPID, --throttle);
break;
case 'T':
if (brake)
setParam(brakePID, (brake = 0));
if (throttle < 100)
setParam(thrPID, ++throttle);
break;
case 'b':
setParam(brakePID, (brake = max(brake - 200, 0)));
if (brake)
setParam(thrPID, (throttle = 0));
break;
case 'B':
if (throttle)
setParam(thrPID, (throttle = 0));
setParam(brakePID, (brake = min(brake + 200, 4000)));
break;
case 's':
case 'S':
if (xPCIsAppRunning(port)) {
xPCStopApp(port);
checkError(NULL);
} else {
xPCStartApp(port); checkError(NULL);
}
break;
case 'q':
case 'Q':
return;
break;
default:
fputc(7, stderr);
break;
}
} else {
Sleep(50);
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-19
3
xPC Target™ API for C
}
printf( "\r%c
%4d
%3d
%1d
%10.3f
%10.3f",
(xPCIsAppRunning(port) ? 'Y' : 'N'),
(int)brake, (int)throttle,
(int)xPCGetSignal(port, gearSID),
xPCGetSignal(port, speedSID),
xPCGetSignal(port, rpmSID));
}
} /* end processKeys() */
/* Function: Usage ===========================================================
* Abstract: Prints a simple usage message.
*/
void Usage(void) {
fprintf(stdout,
"Usage: sf_car_xpc {-t IPAddress:IpPort|-c num}\n\n"
"E.g.:
sf_car_xpc -t 192.168.0.1:22222\n"
"E.g.:
sf_car_xpc -c 1\n\n");
return;
} /* end Usage() */
/* Function: str2Int =========================================================
* Abstract: Converts the supplied string str to an integer. Returns INT_MIN
*
if the string is invalid as an integer (e.g. "123string" is
*
invalid) or if the string is empty.
*/
int str2Int(char *str) {
char *tmp;
int
tmpInt;
tmpInt = (int)strtol(str, &tmp, 10);
if (*str == '\0' || (*tmp != '\0')) {
return INT_MIN;
}
return tmpInt;
} /* end str2Int */
/* Function: parseArgs =======================================================
* Abstract: Parses the command line arguments and sets the state of variables
*
based on the arguments.
void parseArgs(int argc, char *argv[]) {
if (argc != 3) {
fprintf(stderr, "Insufficient command line arguments.\n\n");
3-20
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
*/
Visual C Console Application
Usage();
exit(EXIT_FAILURE);
}
if (strlen(argv[1]) != 2
strchr("-/",
||
argv[1][0]) == NULL ||
strchr("tTcC", argv[1][1]) == NULL) {
fprintf(stderr, "Unrecognized Argument %s\n\n", argv[1]);
Usage();
exit(EXIT_FAILURE);
}
mode = tolower(argv[1][1]) == 'c' ? SERIAL : TCPIP;
if (mode == SERIAL) {
int tmpInt;
if ((tmpInt = str2Int(argv[2])) > INT_MIN) {
comPort = tmpInt;
} else {
fprintf(stderr, "Unrecognized argument %s\n", argv[2]);
Usage();
}
} else {
char *tmp;
ipAddress = argv[2];
if ((tmp = strchr(argv[2], ':')) == NULL) {
/* memory need not be freed as it is allocated only once, will *
* hang around till app ends.
*/
if ((ipPort = malloc(6 * sizeof(char))) == NULL) {
fprintf(stderr, "Unable to allocate memory");
exit(EXIT_FAILURE);
}
strcpy(ipPort, "22222");
} else {
*tmp
= '\0';
ipPort
= ++tmp;
}
}
return;
} /* end parseArgs() */
/* Function: cleanUp =========================================================
* Abstract: Called at program termination to exit in a clean way.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
*/
3-21
3
xPC Target™ API for C
void cleanUp(void) {
xPCClosePort(port);
xPCFreeAPI();
return;
} /* end cleanUp() */
/* Function: checkError ======================================================
* Abstract: Checks for error by calling xPCGetLastError(); if an error is
*
found, prints the error message and exits.
*/
void checkError(char *str) {
char errMsg[80];
if (xPCGetLastError()) {
if (str != NULL)
fputs(str, stderr);
xPCErrorMsg(xPCGetLastError(), errMsg);
fputs(errMsg, stderr);
exit(EXIT_FAILURE);
}
return;
} /* end checkError() */
/* Function: findParam =======================================================
* Abstract: Wrapper function around the xPCGetParamIdx() API call. Also
*
checks to see if the parameter is not found, and exits in that
*
case.
*/
void findParam(char *block, char *param, int *id) {
int tmp;
tmp = xPCGetParamIdx(port, block, param);
if (xPCGetLastError() || tmp == -1) {
fprintf(stderr, "Param %s/%s not found\n", block, param);
exit(EXIT_FAILURE);
}
*id = tmp;
return;
} /* end findParam() */
/* Function: findSignal ======================================================
* Abstract: Wrapper function around the xPCGetSignalIdx() API call. Also
3-22
*
checks to see if the signal is not found, and exits in that
*
case.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
*/
Visual C Console Application
void findSignal(char *sig, int *id) {
int tmp;
tmp = xPCGetSignalIdx(port, sig);
if (xPCGetLastError() || tmp == -1) {
fprintf(stderr, "Signal %s not found\n", sig);
exit(EXIT_FAILURE);
}
*id = tmp;
return;
} /* end findSignal() */
/* Function: getParam ========================================================
* Abstract: Wrapper function around the xPCGetParam() API call. Also checks
*
for error, and exits if an error is found.
*/
double getParam(int parIdx) {
double p;
xPCGetParam(port, parIdx, &p);
checkError("GetParam: ");
return p;
} /* end getParam() */
/* Function: setParam ========================================================
* Abstract: Wrapper function around the xPCSetParam() API call. Also checks
*
for error, and exits if an error is found.
*/
void setParam(int parIdx, double parValue) {
xPCSetParam(port, parIdx, &parValue);
checkError("SetParam: ");
return;
} /* end setParam() */
/** EOF sf_car_xpc.c **/
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
3-23
‫‪xPC Target™ API for C‬‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫‪3‬‬
‫‪3-24‬‬
4
xPC Target API for COM
• “Using the COM API” on page 4-2
• “Visual Basic GUI Using COM Objects” on page 4-4
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4
xPC Target™ API for COM
Using the COM API
Note The xPC Target COM API is no longer being enhanced. You should use
the xPC Target API for Microsoft .NET Framework instead. See “xPC Target
API for Microsoft .NET Framework” on page 1-3.
This topic describes how to write a custom application using the xPC Target
COM API. This COM API enables you to write COM applications to load, run,
and control an xPC Target application.
Before you start, read this section for guidelines on writing custom
applications based on the xPC Target COM API. You do not need to be a
seasoned C or C++ programmer to follow these procedures or to write custom
applications with the xPC Target COM API. You should, however, have
some rudimentary programming knowledge. For this topic, you will be using
Microsoft Visual Basic.
This example uses the model xpctank. If you want to rebuild this model, or
otherwise use the MATLAB software, you must have xPC Target software
version 2.0 or higher.
To determine which version of the software you are currently using, at the
MATLAB command line, type
xpclib
This opens the xPC Target Simulink blocks library. The xPC Target software
version of should be at the bottom of the window.
You can work with xPC Target applications with either the MATLAB software
or an xPC Target COM API application. If you are working with an xPC
Target application using an xPC Target COM API application simultaneously
with a MATLAB session interacting with the target, keep in mind that only
one application can access the target computer at a time. To move from the
MATLAB session to your application, in the MATLAB Command Window,
type
close(xpc)
4-2
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Using the COM API
This frees the connection to the target computer for use by your xPC Target
COM API application. Conversely, you will need to have your COM API
application call the Close method to enable access to the target from a
MATLAB session.
Although you are building an xPC Target COM API application, you still
need to access the xpcapi.dll. When distributing the xPC Target COM API
application, place this file in one of the following, in order of preference:
• Folder from which application is loaded
• Windows system folder
To create the target application and build associated COM objects from
the tagged signals and parameters, use a supported Microsoft Visual C++
compiler to generate code.
Note You can use an Express edition of a compiler to reference the COM API
and generated signals and parameters when creating models. However, you
cannot use an Express edition of a compiler to generate code for these COM
objects.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-3
4
xPC Target™ API for COM
Visual Basic GUI Using COM Objects
In this section...
“Target Application” on page 4-5
“Simulink Water Tank Model” on page 4-5
“Creating a Simulink Target Model” on page 4-7
“Tagging Block Parameters” on page 4-8
“Tagging Block Signals” on page 4-11
“Creating the Target Application and Model-Specific COM Library” on page
4-13
“Model-Specific COM Interface Library (model_nameCOMiface.dll)” on
page 4-16
“Creating a New Microsoft® Visual Basic® Project” on page 4-18
“Referencing the xPC Target COM API and Model-Specific COM Libraries”
on page 4-20
“Creating the Graphical Interface” on page 4-22
“Setting Properties” on page 4-24
“Writing Code” on page 4-25
“Creating the General Declarations” on page 4-26
“Creating the Load Procedure” on page 4-26
“Creating Event Procedures” on page 4-27
“Referencing Parameters and Signals Without Using Tags” on page 4-33
“Testing the Visual Basic Application” on page 4-37
“Building the Visual Basic Application” on page 4-38
“Deploying the API Application” on page 4-38
“Creating a New Visual Basic Project Using Microsoft® Visual Studio® 8.0”
on page 4-40
4-4
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
Target Application
Note
• The xPC Target COM API is no longer being enhanced. You should use the
xPC Target API for Microsoft .NET Framework instead. See “xPC Target
API for Microsoft .NET Framework” on page 1-3.
• These topics assume that you know how to create projects and forms in
Microsoft Visual Basic, and that you are familiar with the concept of
automatic code completion. For further details on Microsoft Visual Basic,
refer to your Microsoft product documentation.
These topics use the Simulink model xpctank and requests that you enter
tags for signals and parameters to create the Simulink model xpc_tank1.
You will then build the real-time target application xpc_tank1.dlm and the
GUI xpc_tank1_COM.exe application using the xPC Target COM API library
and Microsoft Visual Basic.
Simulink Water Tank Model
The xPC Target software includes the Simulink model xpctank. This is a
model of a water tank with a pump, drain, and valve controller.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-5
4
xPC Target™ API for COM
TankLevel — The water level in the tank is modeled using a limited
integrator named TankLevel.
PumpSwitch — The pump can be turned off manually to override the action
of the controller. This is done by setting PumpSwitch to 0. When PumpSwitch
is 1, the controller can use the control valve to pump water into the tank.
ValveSwitch (drain valve) — The tank has a drain valve that allows water
to flow out of the tank. Think of this as water usage or consumption that
reduces the water level. This behavior is modeled with the constant block
named ValveSwitch, the gain block Gain2, and a summing junction. The
minus sign on the summing junction produces a negative flow rate (drain),
which reduces the water level in the tank.
When ValveSwitch is 0 (closed), the valve is closed and water cannot flow out
of the tank. When ValveSwitch is 1 (open), the valve is open and the water
level is reduced by draining the tank.
Controller — The controller is very simple. It is a bang-bang controller and
can only maintain the selected water level by turning the control valve (pump
valve) on or off. A water level set point defines the desired median water
level. Hysteresis enables the pump to avoid high-frequency on and off cycling.
This is done using symmetric upper and lower bounds that are offsets from
the median set point. As a result, the controller turns the control valve (pump
4-6
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
valve) on whenever the water level is below the set point minus the offset.
The summing junction compares this lower bound against the tank water
level to determine whether or not to open the control valve. If the pump is
turned on (PumpSwitch is 1) water is pumped into the tank. When the water
level reaches or exceeds the set point plus the upper bound, the controller
turns off the control valve. When the water level reaches this boundary, water
stops pumping into the tank.
Scope blocks — A standard Simulink Scope block is added to the model for
you to view signals during a simulation. xPC Target Scope blocks are added
to the model for you to view signals while running the target application.
Scope id:1displays the actual water level and the selected water level in the
tank. Scope id:2 displays the control signals. Both scopes are displayed on the
target computer using a target scope.
The xpctank model is built entirely from standard Simulink blocks and scope
blocks from the xPC Target software. It does not differ from a model you
would normally use with the software.
Creating a Simulink Target Model
A target application model is a Simulink model that describes your physical
system and its behavior. You use this model to create a real-time target
application, and you use this model to select the parameters and signals you
want to connect to a custom graphical interface.
You do not have to modify this model when you use it with Simulink 3D
Animation™ or other third-party graphical elements.
Create a target application model before you tag block parameters and block
signals to create a custom graphical interface:
1 In the MATLAB Command Window, type
xpctank
A Simulink model for a water tank opens. This model contains a set of
equations that describe the behavior of a water tank and a simple controller.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-7
4
xPC Target™ API for COM
The controller regulates the water level in the tank. This model contains
only standard Simulink blocks and you use it to create the xPC Target
application.
2 From the File menu, click Save as and enter a new filename. For example,
enter xpc_tank1 and then click OK.
Note If you save your own copy of xpctank, be sure to be in the folder that
contains that model before calling it from the MATLAB window.
Your next task is to mark the block properties and block signals. See
“Tagging Block Parameters” on page 4-8 and “Tagging Block Signals” on page
4-11. Building an xPC Target application that has been tagged generates a
model-specific COM library, model_nameifaceCOM.dll, which you can later
reference when writing your xPC Target COM API application.
Tagging Block Parameters
Tagging parameters in your Simulink model enables you to generate a
model-specific COM library to provide access to model parameter IDs via the
xPC Target COM API library. These interface blocks contain the parameters
you connect to control devices (such as sliders) in your model. Tagging
parameters makes it easier for you to refer to these parameters later, when
you write your xPC Target COM API application.
Note If you do not tag parameters before you generate your Simulink model,
you must specify model parameters manually. See “Referencing Parameters
and Signals Without Using Tags” on page 4-33 for this procedure.
This procedure uses the modelxpc_tank1 (or xpctank) as an example. See
“Creating a Simulink Target Model” on page 4-7.
4-8
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
Tip The xpctank model blocks and signals may contain placeholder tags
illustrating the syntax. As you create your own copy of the model using these
procedures, replace these tags with your new tags or add the new tags using
the multiple label syntax.
1 Open a Simulink model. For example, in the MATLAB window type
xpc_tank1 or xpctank.
2 Point to a Simulink block, and then right-click. For example, right-click the
SetPoint block.
3 From the menu, click Properties.
A block properties dialog box opens.
4 In the Description box, delete the existing tag and enter a tag to the
parameters for this block.
For example, the SetPoint block is a constant with a single parameter that
selects the level of water in the tank. Enter the tag:
xPCTag(1)=water_level;
Tags have the following format:
xPCTag(1, . . . index_n)= label_1 . . . label_n;
• index_n — Index of a block parameter. Begin numbering parameters
with an index of 1.
• label_n — Name for a block parameter to connect to a property for
the parameter you tag in the model. Separate the labels with a space,
not a comma.
label_1...label_n must consist of the same identifiers as those used by
C/C++ to name functions, variables, and so forth. Do not use names like
-foo.
You can assign multiple labels to one tag, such as
xPCTag(1)=label;xPCTag(1)=label2;
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-9
4
xPC Target™ API for COM
You might want to assign multiple labels if you want to tag a parameter
for different purposes. For example, you can tag a parameter to create
a model-specific COM library. You might also want to tag a parameter
to enable the function xpcsliface to generate a user interface template
model.
You can also issue one tag definition per line, such as
xPCTag(1)=label;
xPCTag(2)=label2;
5 Repeat step 4 for the remaining parameters you want to tag.
For example, for the Controller block, enter the tags:
xPCTag(1,2,3)=upper_water_level lower_water_level
pump_flowrate;
For the PumpSwitch and ValveSwitch blocks, enter the tags:
xPCTag(1)=pump_switch;
and
xPCTag(1)=drain_valve;
To tag a block with four properties, use the following syntax:
xPCTag(1,2,3,4)=label_1 label_2 label_3 label_4;
To tag a block with at least four properties for the second and fourth
properties, use the following syntax:
xPCTag(2,4)=label_1 label_2;
4-10
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
6 From the File menu, click Save as. Enter a filename for your model. For
example, enter
xpc_tank1
You next task is to tag block signals, if you have not already done so; then,
create the model. See “Tagging Block Signals” on page 4-11.
Tagging Block Signals
Tagging signals in your Simulink model enables you to generate a
model-specific COM library to provide access to model signal IDs via the
COM API library. These interface blocks contain the signals you connect
to display devices (such as labels) in your model. Tagging signals makes it
easier for you to refer to these signals later, when you write your xPC Target
COM API application. After you tag signals, you will be ready to build your
xPC Target application.
Note If you do not tag signals before you generate your Simulink model,
you must specify model signals manually. See “Referencing Parameters and
Signals Without Using Tags” on page 4-33 for this procedure.
This procedure uses the model xpc_tank1 (or xpctank) as an example. See
“Creating a Simulink Target Model” on page 4-7.
Tip The xpctank model blocks and signals may contain placeholder tags
illustrating the syntax. As you create your own copy of the model using these
procedures, replace these tags with your new tags or add the new tags using
the multiple label syntax.
Notice that you cannot select signals on the output ports of virtual blocks,
such as Subsystem and Mux blocks. Also, you cannot select signals on
function call signal output ports.
1 Open a Simulink model. For example, in the MATLAB window type
xpc_tank1 or xpctank.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-11
4
xPC Target™ API for COM
2 Point to a Simulink signal line, and then right-click.
3 From the menu, click Signal Properties. For example, right-click the
signal line from the TankLevel block.
A Signal Properties dialog box opens.
4 Select the Documentation tab.
5 In the Description box, enter a tag to the signals for this line. For
example, the TankLevel block is an integrator with a single signal that
indicates the level of water in the tank. Enter the tag:
xPCTag(1)=water_level;
6 Repeat step 5 for the remaining signals you want to tag. For example, for
the signal from the ControlValve block, enter the tag:
xPCTag=pump_valve;
Signal tags have the following syntax:
xPCTag(1, . . . index_n)=label_1 . . . label_n;
• index_n — Index of a signal within a vector signal line. Begin numbering
signals with an index of 1.
• label_n — Name for a signal to connect to a property for the signal you
tag in the model. Separate the labels with a space, not a comma.
label_1...label_n must consist of the same identifiers as those used by
C/C++ to name functions, variables, and so forth. Do not use names like
-foo.
For single-dimension ports, the following syntax is also valid:
XPCTag=label;
4-12
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
You can assign multiple labels to one tag, such as
xPCTag(1)=label;xPCTag(1)=label2;
You might want to assign multiple labels if you want to tag a signal
for different purposes. For example, you can tag a signal to create a
model-specific COM library. You might also want to tag a signal to enable
the function xpcsliface to generate a user interface template model.
You can also issue one tag definition per line, such as
xPCTag(1)=label;
xPCTag(2)=label2;
To tag a signal line with four signals (port dimension of 4) use the following
syntax:
xPCTag(1,2,3,4)=label_1 label_2 label_3 label_4;
To tag the second and fourth signals in a signal line with at least four
signals, use the following syntax:
xPCTag(2,4)=label_1 label_2;
7 From the File menu, click Save as. Enter a filename for your model. For
example, enter
xpc_tank1
Create the target application. See “Creating the Target Application and
Model-Specific COM Library” on page 4-13.
Creating the Target Application and Model-Specific
COM Library
Use this procedure to create a target application that you want to connect
to a GUI application and the model-specific COM interface library
(model_nameCOMiface.dll).
After you copy a Simulink model and tag the block parameters and block
signals, you can create a target application and download it to the target
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-13
4
xPC Target™ API for COM
computer. This procedure uses the Simulink model xpc_tank1 (or xpctank)
as an example (see “Creating a Simulink Target Model” on page 4-7).
1 If this is a new release of the product, configure the host computer with the
required settings, including the compiler.
2 Start or reset the target computer with the boot media (CD, DVD, or network
image). Close other applications loaded on the target computer.
3 In the MATLAB window, type xpc_tank1 or xpctank.
A Simulink window opens with the model file.
4 From the Simulation menu, click Model Configuration Parameters.
The Configuration Parameters dialog is displayed for the model.
5 In the left pane, click the Code Generation node.
6 In the Target selection section, click the Browse button at the System
target file list. Click xpctarget.tlc. The Code Generation pane looks like
this:
4-14
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
Click OK.
7 In the left pane, click the xPC Target options node.
The xPC Target options pane is displayed. Verify that the options
Automatically download application after building and Download to
default target PC are set.
8 Click the Solver node.
The Solver pane is displayed.
9 Check that the Stop time is long enough for you to interact with the target
application.
10 Click OK to save and exit.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-15
4
xPC Target™ API for COM
11 From the Code menu, click C/C++ Code > Build Model.
The Simulink Coder, xPC Target, and a third-party C compiler create
the target application xpc_tank1.dlm and the COM object library
xpc_tank1COMiface.dll. The target application is also downloaded to the
target computer.
12 If you want, you can close the MATLAB Command Window.
Your next task is to create a Microsoft Visual Basic API application using
COM objects. This API application connects and controls the target
application. See “Creating a New Microsoft® Visual Basic® Project” on page
4-18. For more information about model-specific COM interface library,
refer to “Model-Specific COM Interface Library (model_nameCOMiface.dll)”
on page 4-16.
Model-Specific COM Interface Library
(model_nameCOMiface.dll)
The generated model-specific COM interface library is a DLL component
server library that enhances programming using the xPC Target COM API
library. A model-specific COM interface library is specific to the model from
which it is generated; do not reference a model-specific library for another
model. If you choose not to generate a model-specific COM interface library,
refer to “Referencing Parameters and Signals Without Using Tags” on page
4-33 for a description of how to otherwise reference parameters and signals in
the xPC Target COM API application.
The mode-specific COM interface library allows users easy access to
preselected tagged signals and desired tagged parameters for use in
conjunction with the xPC Target COM API xPC Target and xPCScope
object signal monitoring and parameter member functions such as
xPCTarget.GetParam, xPCTarget.SetParam, and xPCTarget.GetSignal.
The xPC Target COM generated objects are of two types:
• model_namebio
• model_namept
4-16
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
where model_name is the name of the Simulink model. The model_namebio
type is for tagged block I/O signals and the model_namept type is for tagged
parameters.
Model-Specific COM Signal Object Classes
Model-specific COM signal classes have two types of members in which you
are interested, the Init function and class properties. You will find these
members in the model_namebio class, where model_name is the name of
your model.
The Init function invokes the Init method once, passing it the Ref
property from the xPCProtocol class. This method initializes the object to
communicate with the target computer to access the signal identifiers when
accessing the object’s properties. Refer to the call in the Microsoft Visual
Basic code example in “Creating the Load Procedure” on page 4-26.
Each class has a list of properties (specified in the Tag syntax in the
Description field of the signal property). These properties return the
xPC Target signal identifiers or signal numbers of the tagged signals.
The generated property name is the name specified in the tagged signal
description using the following syntax:
xPCTag=Property name;
For example, in the model xpc_tank1, there are two signal tags in the
Description field:
• The output from the integrator block labeled TankLevel is tagged
xPCTag=water_level.
• The output from the multiply block labeled ControlValve is tagged
xPCTag=pump_valve.
Model-Specific COM Parameter Object Classes
Model-specific COM signal classes have two types of members in which you
are interested, the Init function and class properties. You will find these
members in the model_namept class, where model_name is the name of your
model.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-17
4
xPC Target™ API for COM
The Init function invokes the Init method once, passing it as input the Ref
property from the xPCProtocol class. This method initializes the object to
communicate with the target computer to access the parameter identifiers
when accessing the object’s properties. Refer to the call in the Microsoft
Visual Basic code example in “Creating the Load Procedure” on page 4-26.
Each class has a list of properties (specified in the Tag syntax in the
Description field of the block property). These properties return the xPC
Target parameter identifiers of the tagged parameters. The generated
property name is the name specified in the tagged signal description using
the following syntax:
xPCTag(1)=Property name;
For example, in the model xpc_tank1, there are two parameter tags in the
Description field:
• The parameter for SetPoint blocks is tagged xPCTag=set_water_level;
• The parameters for the Controller block are tagged
xPCTag(1,2,3,)=upper_water_level lower_water_level
pump_flowrate;
Creating a New Microsoft Visual Basic Project
The following procedures describe how you can create a Microsoft Visual Basic
project to take advantage of the xPC Target COM API to create a custom
GUI for the xPC Target application. The procedures build on the xpctank
(xpc_tank1) model you saved earlier (see “Creating the Target Application
and Model-Specific COM Library” on page 4-13). The Microsoft Visual Basic
environment allows you to interact with your target application using a GUI
while the target application is running in real time on the target computer.
The procedures for the following topics apply to Microsoft Visual Studio 6.0.
To use Microsoft Visual Studio 8.0 instead, see “Creating a New Visual Basic
Project Using Microsoft® Visual Studio® 8.0” on page 4-40.
1 Create a new project folder.
4-18
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
From the folder matlabroot\toolbox\rtw\targets\xpc\api, copy the file
xpcapi.dll (API library) to this new project folder. Alternatively, you can
copy the file xpcapi.dll into the Windows system folder.
You do not need to copy xpcapiCOM.dll (the COM API library) into the
current folder, but register it in your system (see “Registering Dependent
Dynamic Link Libraries” on page 4-39.)
2 From your MATLAB working folder, copy the files model_name.dlm (target
application) and model_nameCOMiface.dll (model-specific COM library) to
the new project folder.
3 While in this project folder, open Microsoft Visual Basic. From the File
menu, click New Project.
The New Project dialog box opens.
Note
• Microsoft product screen shots reprinted with permission from Microsoft
Corporation.
• Be sure to open the Microsoft Visual Basic project from the project folder
itself, not from Microsoft Visual Basic.
4 Select Standard EXE, and then click OK.
The Microsoft Visual Basic Integrated Development Environment opens
with a blank form.
5 From the File menu, click Save Project As and enter a filename for the
form and the project. For example, for the form, enter
xpc_tank1_COM.frm
At the project prompt, enter
xpc_tank1_COM.vbp
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-19
4
xPC Target™ API for COM
Referencing the xPC Target COM API and
Model-Specific COM Libraries
You need to reference the xPC Target COM API and model-specific COM
libraries so that Microsoft Visual Basic will use them in the current project.
Assuming that you created the Visual Basic project as described in the
preceding procedure, reference the library as described in this procedure:
1 From the Project menu, click References.
The References dialog box opens.
2 Select the COM tab.
3 Scroll down the Component Name list to the bottom. Select the xPC
Target API COM Type Library check box.
4 Click Select.
5 Click OK.
The xPC Target COM API Type library (xpcapiCOM.dll) is now available
for use in your project.
6 To add the model-specific COM library, click References again from the
Project menu.
The References dialog box opens.
7 Scroll to find your model name. Select the check box xpc_tank1COMiface
1.0 Type Library.
8 Click Select.
9 Click OK.
The model-specific COM API Type Library (xpc_tank1COMiface.dll) is
now available for use in your project. Sections “Viewing Model-Specific
COM Signal Object Classes” on page 4-21 and “Viewing Model-Specific
COM Parameter Object Classes” on page 4-21 describe how to look at class
objects.
4-20
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
Because the xPC Target COM API is an add-on to Visual Basic, it might
help to know a bit about Visual Basic before going much farther with using
the COM API. The section “Creating the Graphical Interface” on page 4-22
shows you how to use Visual Basic to create a project for the xpctank or
(xpc_tank1) model.
Viewing Model-Specific COM Signal Object Classes
After you create a Visual Basic project and reference the xPC Target COM
API and model-specific COM libraries, you can use the Visual Basic Object
browser (click the View menu and select Object Browser) to look at the
objects for the xpctankbio or xpc_tank1bio class:
1 From the View menu, select Object Browser.
A dialog box pops up with a drop-down list containing the type library
information for a project.
2 Select the drop-down list for the project/library.
A list of the project libraries appears.
3 Select model_nameCOMIFACELib.
The classes in your model appear.
4 To view the objects of a class, select that class.
The objects in your class appear.
The xpctankbio (or xpc_tank1bio) class contains the function Init and
the two properties
• water_level
• pump_valve
Viewing Model-Specific COM Parameter Object Classes
After you create a Visual Basic project and reference the xPC Target COM
API and model-specific COM libraries, you can use the Visual Basic Object
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-21
4
xPC Target™ API for COM
browser (click the View menu and select Object Browser) to look at the
objects for the xpctankpt or xpc_tank1pt class:
1 From the View menu, select Object Browser.
A dialog box pops up with a drop-down list containing the type library
information for a project.
2 Select the drop-down list for the project/library.
A list of the project libraries appears.
3 Select model_nameCOMIFACELib.
The classes in your model appear.
4 To view the objects of a class, select that class.
The objects in your class appear.
The xpctankpt (or xpc_tank1pt) class contains the method Init and the
member properties
• pump_switch
• upper_water_level
• lower_water_level
• pump_flowrate
• water_level
• drain_valve
Creating the Graphical Interface
Forms are the foundation for creating the interface of a Visual Basic
application. You can use forms to add windows and dialog boxes to your
Visual Basic application. You can also use them as containers for items that
are not a visible part of the application’s interface. For example, you might
have a form in your application that holds a timer object.
4-22
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
The first step in building a Visual Basic application is to create the forms that
are the basis for your application’s interface. Then you create the objects that
make up the interface on the forms. This section assumes that you have a
Visual Basic project (see “Creating a New Microsoft® Visual Basic® Project”
on page 4-18). For this first application, you will use four types of controls
from the toolbox:
• Button
• Timer
• Label
• Scroll bar
1 Open xpc_tank1_COM.vbp.
2 On the left, from the General tool panel, click and drag the Button
icon
to the form to create a button.
3 Repeat for a second button.
4 If you want to view signal data on the host, return to the General tool
panel and click and drag the Timer icon
to the form to create a timer.
5 If you want to view signal data on the host, add a Label control to the form.
to
Return to the General tool panel and click and drag the Label icon
the form to create a label.
6 If you want to be able to vary the parameter input to the target, return to
the General tool panel and click and drag the HScrollBar icon
the form.
to
7 Next, name your new form objects. Right-click the first button and select
Properties. This brings up the Properties dialog box. In the Caption box,
enter Load. Repeat for the second button, but enter Start. Repeat for the
third button, but enter Stop. (If you are unsure about how to work with
properties, refer to the procedure “Setting Properties” on page 4-24.)
After you name your new form objects and set whatever other parameters
you want (for example, if you use a timer you must increase the Interval
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-23
4
xPC Target™ API for COM
parameter), you can write the code behind these objects using the Visual
Basic code editor window (refer to “Writing Code” on page 4-25).
Note If you add a timer, remember to increase the interval of the timer to
a value greater than the default value of 0. Right-click the timer and select
Properties. This brings up the Properties dialog box. In the Interval box,
enter a value greater than 0, for example, 100.
Setting Properties
This procedure describes how to set properties for the Visual Basic objects you
created on your form. If you already know how to set properties for Visual
Basic objects, proceed to “Writing Code” on page 4-25.
The Properties window in the following figure provides an easy way to
set properties for the objects on a form. To open the Properties window,
choose the Properties Window command from the View menu, click the
Properties Window button on the toolbar, or use the context menu for the
control.
The Properties window consists of the following elements:
• Object box — Displays the name of the object for which you can set
properties. Click the arrow to the right of the object box to display the
list of objects for the current form.
• Sort tabs — Choose an alphabetic listing of properties or a hierarchical
view divided by logical categories, such as those dealing with appearance,
fonts, or position.
• Properties list — The left column displays the properties for the selected
object. You can edit and view settings in the right column.
To set properties from the Properties window,
1 From the View menu, choose Properties, or click the Properties button
on the toolbar.
The Properties window displays the settings for the selected form or
control.
4-24
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
2 From the properties list, select the name of a property.
3 In the right column, type or select the new property setting.
Enumerated properties have a predefined list of settings. You can display
the list by clicking the down arrow at the right of the settings box, or you
can cycle through the list by double-clicking a list item.
You can also set object properties directly in the code by using the following
dot notation: Object.propertyname=value.
Writing Code
The code editor window is where you write Visual Basic code for your
application. Code consists of language statements, constants, and
declarations. Using the code editor window, you can quickly view and edit
the code in your application.
The code editor window has three panes. The top leftmost pane is the object
list box. It is a drop-down list that contains the form controls in your project,
plus a general section for generic declarations. The top rightmost pane
contains a procedure list box. For the selected or active control in the object
list box, the procedure list box displays the available procedures, or events.
Visual Basic predefines the possible procedures. The third pane contains the
code for the Visual Basic application.
In the general declarations section, declare a reference to the xPC Target
COM objects that you are using to interface with the xPC Target objects. The
following are the objects you need to declare:
• xPCProtocol — Reference the classes corresponding to the target computer
running the target application and initialize the xPC Target API dynamic
link library. At a minimum, you must declare this object.
• xPCTarget — Reference the classes for interfacing with the target
application. At a minimum, you must declare this object.
• xPCScope — If the API application requires signal data, reference the class
for interfacing with xPC Target scopes. You need to declare a scope if you
want to acquire data from scopes or display data on scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-25
4
xPC Target™ API for COM
• model_namept — This is the COM object for tunable model/application
parameters.
• model_namebio — This is the COM object for model/target application
signals.
Creating the General Declarations
This procedure describes how to create the general object declarations for
the xpctank (or xpc_tank1) model:
1 Double-click the form or, from the View menu, select Code.
The code editor window box opens for the control.
2 Select the General object.
3 Select Declarations in the procedure list box.
A template for the declarations procedure is now displayed in the code
editor window.
4 Enter declarations for the xPC Target COM objects you are using.
Public protocol_obj As xPCProtocol
Public target_obj As xPCTarget
Public scope_obj As xPCScopes
5 Enter declarations for the model-specific COM objects you are using.
Public parameters_obj As xpc_tank1pt
Public signals_obj As xpc_tank1bio
Creating the Load Procedure
This procedure describes how to program a load target application procedure
for the form. You might or might not want to allow users to download
target applications to the target computer. However, if you do want to allow
this action, you need to provide a control on the GUI for the user to do so.
“Creating Event Procedures to Load Applications” on page 4-28 describes
how to provide such a control.
1 In the project window, double-click the Form object.
4-26
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
The code editor window opens.
2 In the procedure list box, select Load.
3 Create and initialize the objects for the Load method in the form. Note that
the following code also checks that the initialization of the protocol_obj
succeeds. If it does not succeed, an error message is returned and the
application will exit.
Private Sub Form_Load()
Set protocol_obj = New xPCProtocol
Set target_obj = New xPCTarget
Set scope_obj = New xPCScopes
Set parameters_obj = New xpc_tank1pt
Set signals_obj = New xpc_tank1bio
stat = protocol_obj.Init
If stat < 0 Then
MsgBox("Could not load api") 'We can no longer continue.
End
End If
stat = protocol_obj.RS232Connect(0, 0)
stat = target_obj.Init(protocol_obj)
stat = scope_obj.Init(protocol_obj)
stat = parameters_obj.Init(protocol_obj.Ref)
stat = signals_obj.Init(protocol_obj.Ref)
End Sub
You can add more code to the Load method. This is the minimum code
you should enter for this method.
Creating Event Procedures
Code in a Visual Basic application is divided into smaller blocks called
procedures. Event procedures, such as those you create here, contain code
that mainly calls the xPC Target API component methods. For example, when
a user clicks a button, that action starts the xPC Target application.
This code is also responsible for the feedback action (such as enabling a
timer control, disabling/enabling controls) when an event occurs. An event
procedure for a control combines the control’s name (specified in the Name
property), an underscore (_), and the event name. For example, if you want
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-27
4
xPC Target™ API for COM
a command button named Command1 to invoke an event procedure when
it is clicked, call the procedure Command1_Click. The following procedures
illustrate how to create event procedures, using the xpctank (or xpc_tank1)
model as an example.
Creating Event Procedures to Load Applications
This procedure describes how to program the command button Command1
to load an application to the target computer through a serial connection.
Provide a procedure like this to allow users to download target applications to
the target computer.
1 Double-click the form or, from the View menu, select Code.
2 From the object list box, select the name of an object in the active form.
(The active form is the form that currently has the focus.) For this example,
choose the command button Command1.
3 In the procedure list box, select the name of an event for the selected object.
The Click procedure is the default procedure for a command button.
4 To load the target application, enter the path to the target application. If
the target application is in the same folder as the API application, enter ".".
Enter the name of the target application without the extension.
stat = target_obj.LoadApp(".", "xpc_tank1")
When you are done, the contents of your code editor window should look
similar to the code below:
Private Sub Command1_Click()
stat = target_obj.LoadApp(".", "xpc_tank1")
End Sub
Creating Event Procedures to Start and Stop Applications
This procedure describes how to program the command buttons Command2
and Command3 to start and stop an application on a target computer:
1 If you are not already in the code editor window, double-click the form or,
from the View menu, select Code.
4-28
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
2 From the object list box, select the name of an object in the active form.
(The active form is the form that currently has the focus.) For this example,
choose the command button Command2.
3 In the procedure list box, select the name of an event for the selected object.
Here, select the Click procedure.
4 To start the target application, select the StartApp method for the
command button Command2 (this is the button you named Start).
stat = target_obj.StartApp
5 To stop the target application, select the StopApp method for the command
button Command3 (this is the button you named Stop). Be sure to select
the Click procedure in the procedure list box.
stat = target_obj.StopApp
When you are done, the contents of your code editor window should look
similar to the code below:
Private Sub Command2_Click()
stat = target_obj.StartApp
End Sub
Private Sub Command3_Click()
stat = target_obj.StopApp
End Sub
Creating Event Procedures to Vary Input Values
You can provide controls to allow users to vary the parameters of their
applications. The Scroll procedure is one way of varying input. The following
code uses the Visual Basic HScrollBar object to vary the water_level
parameter. It takes the value from the HScrollBar object and sends that
value to the target as a parameter change.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-29
4
xPC Target™ API for COM
Note This section assumes that you have tagged block parameters and
created your own model-specific COM library. Refer to “Getting Parameter
IDs with the GetParamIdx Method” on page 4-33 for a description of how to
manually perform the equivalent of using tagged parameters.
1 If you are not already in the code editor window, double-click the form or,
from the View menu, select Code.
2 From the object list box, select the name of an object in the active form.
(The active form is the form that currently has the focus.) For this example,
select the HScroll1 object.
The cursor jumps to the HScroll1 object template of the code editor window.
3 In the procedure list box, select the name of an event for the selected object.
Here, select the Scroll procedure.
4 Declare the slideVal variable as a double. The slideVal variable will
contain the value of the scroll bar.
Dim slideVal(0) As Double
5 Assign to the slideVal variable the result of CDbl. The CDbl function
reads the value of an object property. In this example, the object HScroll1
has the property slideVal(0). CDbl reads the value of HScroll1.Value
and returns that value to slideVal.
slideVal(0) = CDbl(HScroll1.Value)
6 Set the value of water_level to the scroll bar value slideVal, which is
from HScrollBar. The COM object target_obj has the method SetParam,
which has the syntax SetParam(parIdx, newparVal). The SetParam method
references parIdx from the model-specific COM object (type xpc_tank1pt).
To set the value of water_level to the scroll bar value slideVal, select
SetParam and continue typing. A list of the parameters you tagged in
the Simulink model then pops up, and you can select the parameter
water_level and continue typing.
The call to SetParam should look like the following:
4-30
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
stat = target_obj.SetParam(parameters_obj.water_level,
slideVal)
When you are done, the contents of your code editor window should look
similar to the code below:
Private Sub HScroll1_Scroll()
Dim slideVal(0) As Double
slideVal(0) = CDbl(HScroll1.Value)
stat = target_obj.SetParam(parameters_obj.water_level,
slideVal)
End Sub
Creating Event Procedures to Display Signal Values at the Host
You can provide controls to view signal values at the host. To do this, use a
combination of the timer and label controls. The following code uses the Visual
Basic timer control to display the water_level signal on the label control.
Note This section assumes that you have tagged signals and created your
own model-specific COM library. Refer to “Getting Signal IDs with the
GetSignalIdx Method” on page 4-35 for a description of how to manually
perform the equivalent of using tagged signals.
Before you start, check that the Timer1 Interval property is greater than 0.
1 From the object list box, select the Timer1 object.
2 Assign to the Label1.Caption object the value of the water_level signal.
The COM object target_obj has the method GetSignal(sigNum). Reference
the sigNum parameter by passing it signals_obj.water_level. The CStr
function converts the returned value to a string so that it can be displayed
on the Label1 object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-31
4
xPC Target™ API for COM
When you are done, the contents of your code editor window should look
similar to the code below:
Private Sub Timer1_Timer()
Label1.Caption =
CStr(target_obj.GetSignal(signals_obj.water_level))
End Sub
Note Although you add both a timer and label object to the Visual Basic
application, only the label appears on the GUI itself when the Visual Basic
application is run. The timer is not visible.
Creating Unload and Termination Procedures
You should write Form Unload and Termination procedures to stop and
unload the application and to close the communication channel between the
host computer and target computer.
Note The Form Unload and Termination procedures must close the
communication channel between the host computer and target computer
between each run of the GUI application.
The Terminate procedure controls the behavior of the Visual Basic Run
menu End option. The Unload procedure controls the behavior of the Visual
Basic Close button.
1 From the object list box, select the Form object.
2 From the procedure list box, select Terminate.
3 You are going to close the connection with the target computer, so type
protocol_obj and select the Close method for that object.
protocol_obj.Close
4 From the procedure list box, select Unload.
4-32
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
5 Repeat step
When you are done, the contents of your code editor window should look
similar to the code below:
Private Sub Form_Terminate()
protocol_obj.Close
End Sub
Private Sub Form_Unload(Cancel As Integer)
protocol_obj.Close
End Sub
Referencing Parameters and Signals Without Using
Tags
The sample code in “Creating Event Procedures to Vary Input Values” on
page 4-29 and “Creating Event Procedures to Display Signal Values at the
Host” on page 4-31 illustrates how to reference parameters that you tagged
before building the Simulink model. This section describes how to reference
these same parameters and signals from the COM API application code if you
did not opt to tag signals and parameters.
Getting Parameter IDs with the GetParamIdx Method
When working with parameters in the context of varying input values, you
use the SetParam and GetParamIdx methods. The SetParam method has
the syntax
SetParam(ByVal parIdx As Integer, ByRef newparVal As
System.Array) As Long
where parIdx is the identifier that corresponds to the parameter you want to
set. To obtain the parameter ID, parIdx, for SetParam, you need to call the
GetParamIdx method. This method has the syntax
GetParamIdx(ByVal blockName As String, ByVal paramName As
String) As Long
The following procedure describes how to obtain the GetParamIdx block name
and parameter name for the Visual Basic HScrollBar object. You need to
reference the block name and parameter from the model_namept.m file.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-33
4
xPC Target™ API for COM
1 Open a DOS window.
2 Change the folder to the folder that contains your prebuilt model.
3 Open the file model_namept.m. For example, you can use the notepad
text editor.
notepad xpc_tank1pt.m
The editor opens for that file. If you are not in the folder in which the
xpc_tank1pt.m file resides, be sure to type the full path for xpc_tank1pt.m.
4 Search for and copy the string for the block of the parameter you want to
reference. For the xpc_tank1 example, search for the SetPoint block if you
want to reference the water level. For example,
SetPoint
5 Return to the code editor window for your project.
6 In the line that contains the call to GetParamIdx, enter the path for the
blockName variable.
7 Return to the editor window for model_namept.m.
8 Search for and copy the string for the name of the parameter you are
interested in. For example,
Value
If you do not know the name of the block parameter you are interested in,
refer to “Common Block Properties” or “Block-Specific Parameters”.
9 Return to the code editor window for your project.
10 In the line that contains the call to GetParamIdx, enter the path for the
paramName variable. For example,
stat = target_obj.SetParam(target_obj.GetParamIdx
("SetPoint", "Value"), slideVal)
4-34
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
When you are done, the contents of your code editor window should look
similar to the code below:
Private Sub HScroll1_Scroll()
Dim slideVal(0) As Double
slideVal(0) = CDbl(HScroll1.Value)
stat =
target_obj.SetParam(target_obj.GetParamIdx
("SetPoint", "Value"), slideVal)
End Sub
Note, if you want to retrieve the full block path and parameter name of a
block, use the GetParamName method. The GetParamName method returns
a variant data type object with two elements. The first element contains
the full block path, the second element contains the parameter name. The
following example illustrates how to use the GetParamName method to get
the block path and parameter name:
Dim Pname As Variant
Pname=xpc_tank1.GetParamName(GetParamIdx(Idx)
BlockPathString=CStr(Pname(0))
ParameterNameString=CStr(Pname(1))
In this example,
• Idx is the index to a parameter.
• BlockPathString contains the full block path string.
• ParameterNameString contains the parameter name string.
Getting Signal IDs with the GetSignalIdx Method
When working with signals in the context of displaying signal values, you
use the GetSignal and GetSignalIdx methods. The GetSignal method has
the syntax
GetSignal(sigNum As Long) As Double
where sigNum is the identifier that corresponds to the signal you want to set.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-35
4
xPC Target™ API for COM
To obtain the signal ID sigNum for GetSignal, you call the GetSignalIdx
method. This method has the syntax
GetSignalIdx(sigName As String) As Long
The following procedure describes how to obtain the GetSignalIdx block
name for the Visual Basic timer object. You need to reference the block name
and signal from the model_namebio.m file.
1 Open a DOS window.
2 Change the folder to the folder that contains your prebuilt model.
3 Open the file model_namebio.m. For example,
notepad xpc_tank1bio.m
The editor opens for that file. If you are not in the folder in which
the xpc_tank1bio.m file resides, be sure to type the full path for
xpc_tank1bio.m.
4 Search for and copy the string for the block of the signal you want to
reference. For the xpc_tank1 example, search for the TankLevel block to
reference the tank level. For example,
TankLevel
5 Return to the code editor window for your project.
6 In the line that contains the call to GetSignalIdx, enter the path for the
SigName variable.
When you are done, the contents of your code editor window should look
similar to the code below:
Private Sub Timer1_Timer()
Label1.Caption =
CStr(target_obj.GetSignal(target_obj.GetSignalIdx("TankLevel"
)))
End Sub
4-36
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
Testing the Visual Basic Application
While creating your Visual Basic application, you might want to see how the
application is progressing. Visual Basic allows you to run your application
while still in the Visual Basic project. From the Visual Basic task bar, you
can click the Run button
. Alternatively, you can follow the procedure:
1 If you have the MATLAB interface and a target object connected, close the
port. For example, at the MATLAB command line, type
tg.close
2 Close any previous version of the application. Only one version of the
application should run at a given time.
3 From within the project, go to the Run menu.
4 Select Start or Start with Full Compile. The Start option starts your
application immediately. The Start with Full Compile option starts
the application after compilation.
The form you are working on pops up. Test your application. To stop the
application from within Visual Basic, you can click the End button
from
the task bar. Alternatively, you can go to the Run menu and select End.
Note
• If the Visual Basic application opens a communication channel between
the host and target computers for the target application, close that open
channel between test runs of the Visual Basic application. Not doing so can
cause subsequent runs of the Visual Basic application to fail.
• See “Creating Unload and Termination Procedures” on page 4-32 for how to
write a procedure to disconnect from the target computer. If you want to
return control to the MATLAB interface, close the Visual Basic project first.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-37
4
xPC Target™ API for COM
Building the Visual Basic Application
After you finish designing, programming, and testing your Visual Basic
GUI application, build your application. You can later distribute the GUI
application to users, who can then use it to work with target applications.
1 From within the project, go to the File menu.
2 Select Make project_name_COM.exe, where project_name is the name of
the Visual Basic project you have been working on.
3 At the pop-up box, select the folder in which you want to save the
executable. Optionally, you can also rename the executable.
The compiler generates the project_name_COM.exe file in the specified
folder.
Deploying the API Application
This section assumes that you have built your xPC Target application and
your Visual Basic xPC Target COM GUI application. If you have not yet
done so, refer to “Creating the Target Application and Model-Specific COM
Library” on page 4-13 and “Building the Visual Basic Application” on page
4-38, respectively.
When distributing the Visual Basic model application, provide the following
files:
• project_name_COM.exe, the executable for the Visual Basic application
• model_name.dlm
4-38
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
Tip
-
Provide model_name.dlm if you expect the end user to download the
target application to the target computer. Also enable an application
load event on the Visual Basic interface (refer to “Creating the Load
Procedure” on page 4-26).
-
If you expect the target application to already be loaded on the target
computer when the end user runs the Visual Basic GUI application, you
might not want him or her to be able to load the target application to
the target computer.
• model_nameCOMiface.dll, if you tag the signals and parameters in the
model
• xpcapiCOM.dll, the xPC Target COM API dynamic link library
• xpcapi.dll, the xPC Target API dynamic link library
All the files must be located in the same folder before the user executes the
Visual Basic application.
The end user must know how to register the application-dependent dynamic
link libraries (refer to “Registering Dependent Dynamic Link Libraries” on
page 4-39).
To run the application and download an xPC Target application, users need
to have project_name_COM.exe and model_name.dlm (if provided) in the
same folder.
Registering Dependent Dynamic Link Libraries
This procedure uses xpc_tank1 as an example.
1 Open a DOS window.
2 Change the folder to the folder containing the API application files.
3 From the folder in which xpcapiCOM.dll resides, register the xPC Target
COM API DLL by typing
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-39
4
xPC Target™ API for COM
regsvr32 xpcapiCOM.dll
DOS displays the message
DllRegisterServer in xpcapiCOM.dll succeeded
Creating a New Visual Basic Project Using Microsoft
Visual Studio 8.0
The procedures for the preceding topics apply to Microsoft Visual Studio
6.0 (“Creating a New Microsoft® Visual Basic® Project” on page 4-18). The
procedures to use Microsoft Visual Studio 8.0 is similar, with the following
exceptions.
• You can open a Microsoft Visual Studio 6.0 project under Microsoft Visual
Studio .NET 2003. Microsoft Visual Studio .NET 2003 automatically
converts the project.
• If you first create a new Visual Basic project, select Windows Application
as the template.
• When referencing the xPC Target COM API and model-specific COM
libraries, do the following
1 From the Project menu, click Add Reference.
The Add Reference dialog box opens.
2 Select the COM tab.
3 Scroll down the Component Name list to the bottom and select the
xPC Target API COM Type Library item.
4 Click Select.
xPC Target API COM Type Library appears in the Selected
Components pane.
5 Click OK.
• When creating a reference to the xPC Target interface objects, include the
COM library. The following illustrates example code on how to reference
these objects in Microsoft Visual Studio .NET 2003 and Microsoft Visual
Studio 6.0:
4-40
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM Objects
Microsoft Visual Studio .NET 2003
Public protocol_obj As XPCAPICOMLib.xPCProtocol
Public target_obj As XPCAPICOMLib.xPCTarget
Public scope_obj As XPCAPICOMLib.xPCScopes
Microsoft Visual Studio 6.0
Public protocol_obj As xPCProtocol
Public target_obj As xPCTarget
Public scope_obj As xPCScopes
• When creating an instance of the xPC Target interface objects, include
the COM library. The following illustrates example code on how to create
an instance of these objects in Microsoft Visual Studio .NET 2003 and
Microsoft Visual Studio 6.0:
Microsoft Visual Studio .NET 2003
protocol_obj = New XPCAPICOMLib.xPCProtocol
target_obj = New XPCAPICOMLib.xPCTarget
scope_obj = New XPCAPICOMLib.xPCScopes
Microsoft Visual Studio 6.0:
Set protocol_obj = New xPCProtocol
Set target_obj = New xPCTarget
Set scope_obj = New xPCScopes
• Microsoft Visual Studio .NET 2003 builds applications into the bin folder
of your project area. You cannot choose another location to place your
executable.
• When distributing the Visual Basic model application to users, provide the
following files in addition to those listed in “Deploying the API Application”
on page 4-38:
-
Interop.model_nameACOMIFACELib.dll
Interop.XPCAPICOMLib.dll
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
4-41
‫‪xPC Target™ API for COM‬‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫‪4‬‬
‫‪4-42‬‬
5
xPC Target API Examples
• “Visual Basic GUI Using .NET” on page 5-2
• “Visual Basic GUI Using COM” on page 5-5
• “Command Line Scripts Using COM API” on page 5-8
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
5
xPC Target™ API Examples
Visual Basic GUI Using .NET
To help you better understand and quickly begin to use .NET
API functions to create custom GUI applications, the xPC Target
environment provides a number of API examples and scripts in the
C:\matlabroot\toolbox\rtw\targets\xpc\api folder. This topic briefly
describes those examples and scripts.
The Microsoft Visual Basic .NET example illustrates how to create a custom
GUI that connects to a target computer with a downloaded target application.
The solution file for this example is located in
C:\matlabroot\toolbox\rtw\targets\xpc\api\VBNET\SigsAndParamsDemo
• bin — Contains the executable for the Demo project and the xpcapi.dll file
• Demo.sln — Contains a solution file for the Demo project
The Demo.sln file contains the Visual Basic .NET files required to run the
windows form application. This example is a functional application that you
can use as a template to create your own custom GUIs.
In this section...
“Before Starting” on page 5-2
“Accessing the Demo Project Solution” on page 5-3
“Rebuilding the Demo Project Solution” on page 5-3
“Using the Demo Executable” on page 5-4
Before Starting
To use the Demo solution, you need
• A target computer running a current xPC Target kernel
• A host computer running the MATLAB software interface, connected to the
target computer via RS-232 or TCP/IP
• A target application loaded on the target computer
5-2
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using .NET
The xPC Target product ships with an executable version of the example.
If you want to rebuild the Demo solution, of if you want to write your own
custom GUIs like this one, you need Microsoft Visual Basic .NET installed
on the host computer.
Note The xPC Target software allows you to create applications, such as
GUIs, to interact with a target computer with COM API functions. “xPC
Target COM API” on page 1-7 describes this in detail. To deploy a GUI
application to other host computer systems that do not have your licensed
copy of the xPC Target product, you need the xPC Target Embedded Option.
If you do not have the xPC Target Embedded Option and would like to deploy
your GUI application, contact your MathWorks representative.
Accessing the Demo Project Solution
To access the Demo solution,
1 Copy the contents of the VBNET folder to a writable folder of your choice.
2 Change folder to the one that contains your copy of the Demo solution.
3 Double-click demo.sln.
The Microsoft Development Environment for Visual Basic application
starts.
4 In the Solution Explorer pane, double-click Form1.vb to display the
Demo solution form.
The form is displayed. You can inspect the layout of the example.
5 To inspect the form code, select the View menu Code option.
The Visual Basic code for the form is displayed.
Rebuilding the Demo Project Solution
To rebuild the Demo solution,
1 Double-click demo.sln.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
5-3
5
xPC Target™ API Examples
The Microsoft Development Environment for Visual Basic application
starts.
2 Select the Build menu Build Solution option.
Using the Demo Executable
To use the Demo solution executable,
1 Change folder to the one that contains your copy of the Demo solution.
2 Change folder to the bin folder.
3 Double-click Demo1.exe.
The GUI is displayed.
5-4
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM
Visual Basic GUI Using COM
The Microsoft Visual Basic 6.0 sf_car_xpc example illustrates how to create
a custom GUI that connects to a target computer. The files for this example
are located in
C:\matlabroot\toolbox\rtw\targets\xpc\api\VisualBasic\Models\sf_car_xpc*
This application interfaces with the xPC Target application sf_car_xpc.dlm,
built from the Simulink model sf_car_xpc. This model simulates an
automatic transmission control system composed of modules that represent
the engine, transmission, and vehicle, with an additional logic block to control
the transmission ratio. User inputs to the model are in the form of throttle
(%) and brake torque (pound-foot).
This example illustrates how you can use the COM API to create a GUI that
• Connects to the target computer via an RS-232 or TCP/IP connection
• Loads the sf_car_xpc.dlm target application to the target computer
• Starts and starts the target application engine
• Edits the stop time of the target application
• Edits the sample time of the target application
• Displays the speed, RPM, and gear of the target application engine
Note For detailed information on the project, see the readme.txt files located
in C:\matlabroot\toolbox\rtw\targets\xpc\api\VisualBasic\Models\
sf_car_xpc*.
In this section...
“Before Starting” on page 5-6
“Accessing the sf_car_xpc Project” on page 5-6
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
5-5
5
xPC Target™ API Examples
In this section...
“Rebuilding the sf_car_xpc Project” on page 5-7
“Using the sf_car_xpc Executable” on page 5-7
Before Starting
To use the sf_car_xpc project, you need
• A target computer running a current xPC Target kernel
• A host computer running the MATLAB interface, connected to the target
computer via RS-232 or TCP/IP
The xPC Target product ships with an executable version of the sf_car_xpc
project. If you want to rebuild the sf_car_xpc project, you need Microsoft
Visual Basic 6.0 Professional installed on the host computer. If you want to
view or edit the model, you need to have the Stateflow® product installed
on the host computer.
Note The xPC Target environment allows you to create applications, such
as GUIs, to interact with a target computer with COM API functions. “xPC
Target COM API” on page 1-7 describes this in detail. To deploy a GUI
application to other host computer systems that do not have your licensed copy
of the xPC Target product, you need the xPC Target Embedded Option license.
If you do not have the xPC Target Embedded Option license and would like to
deploy your GUI application, contact your MathWorks representative.
Accessing the sf_car_xpc Project
To access the sf_car_xpc project,
1 Copy the contents of the VisualBasic folder to a writable folder of your
choice.
2 Change folder to the one that contains your copy of the sf_car_xpc project.
3 Double-click the Visual Basic project. For example, double-click
sf_car_xpc_COM.vbp.
5-6
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Visual Basic® GUI Using COM
The Microsoft Visual Basic application starts.
4 In the right Project pane, expand the Forms folder.
5 Double-click the form you want to look at.
The form is displayed. You can inspect the layout of it.
6 To inspect the form code, select the View menu Code option.
The Visual Basic code for the form is displayed.
Rebuilding the sf_car_xpc Project
To rebuild the sf_car_xpc project,
1 Double-click the Visual Basic project. For example, double-click
sf_car_xpc_COM.vbp.
The Microsoft Visual Basic application starts.
2 Select the File menu Make sf_car_xpc.exe.
Using the sf_car_xpc Executable
To use the sf_car_xpc project executable,
1 Change folder to the one that contains your copy of the sf_car_xpc project.
2 Change folder to the bin folder.
3 Double-click sf_car_xpc.exe.
The GUI is displayed.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
5-7
5
xPC Target™ API Examples
Command Line Scripts Using COM API
In this section...
“Tcl/Tk Scripts” on page 5-8
“Required Tcl/Tk Software” on page 5-9
“Using the Scripts” on page 5-9
Tcl/Tk Scripts
The Tcl/Tk examples are scripts that illustrate how to directly access xPC
Target COM API functions through a command-line interpreter like Tcl/Tk.
With Tcl/Tk, you can:
• Write simple command-line scripts that communicate with a target
computer and the target application downloaded on that target computer.
• Write simple GUIs that you can use to interact with a target application
downloaded on a target computer.
The files for this scripts are located in
C:\matlabroot\toolbox\rtw\targets\xpc\api\tcltk
• xpcapi.dll — The xPC Target API DLL file. This file must be in the
current (pwd) folder. Alternatively, you can copy the file xpcapi.dll into
the Windows system folder.
• xpcbase.tcl — Contains utility procedures used by the other scripts in
the series
• xpclists.tcl — Generates a list of signals or parameters for the target
application currently loaded on the target computer
• xpcload.tcl — Loads the specified target application to the connected
target computer
• xpcoutputlog.tcl — Reads log data from the target computer and plots
the data on the host computer
• xpcstart.tcl — Starts the target application loaded on the target
computer
5-8
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Command Line Scripts Using COM API
• xpcstop.tcl — Stops the target application loaded on the target computer
• xpctargetping.tcl — Tests the communication between the host and
target computers
• xpctargetscope.tcl — Creates a simple GUI that enables you to add
and control a target scope
• xpctune.tcl — Creates a simple GUI slider that enables you to manipulate
a parameter value for the target computer application
Required Tcl/Tk Software
To use these Tcl/Tk scripts, or to write your own Tcl/Tk scripts, you need
• An installation of a Tcl/Tk distribution on the host computer.
• An add-on package to the Tcl/Tk interpreter so that the
scripts can access the COM API objects. For example, the
tcom package was used to create the example scripts in the
C:\matlabroot\toolbox\rtw\targets\xpc\api\tcltk folder.
• The math::statistics package. This package is required for the
xpcoutputlog.tcl file.
Note There are Tcl/Tk distributions that include required and useful
packages for use with the xPC Target software. For example, the Tcl/Tk
distribution at http://www.activestate.com/activetcl contains these
packages.
Using the Scripts
The top of each Tcl/Tk script file contains directions on how to use each Tcl/Tk
script. In general:
1 Copy the contents of the tcltk folder to a writable folder of your choice.
2 Change folder to the one that contains your copy of the Tcl/Tk script files.
3 Start your Tcl/Tk interpreter.
4 Load the Tcl/Tk script with the source command. For example,
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
5-9
5
xPC Target™ API Examples
source xpctargetping.tcl
5 Run the loaded script. For example,
xpctargetping 192.168.0.10 22222
The selected script executes. In this example, xpctargetping.tcl tests
the communication between the host and target computer and returns a
success or failure message.
5-10
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6
xPC Target API Reference
for Microsoft .NET
Framework
• “xPC Target API for Microsoft .NET Framework Classes” on page 6-2
• “xPC Target API for Microsoft .NET Framework — Alphabetical List” on
page 6-7
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6
xPC Target™ API Reference for Microsoft® .NET Framework
xPC Target API for Microsoft .NET Framework Classes
Namespace: MathWorks.xPCTarget.FrameWork
In this section...
“Target Computers” on page 6-2
“Target Applications” on page 6-3
“Scopes” on page 6-3
“Parameters” on page 6-4
“Signals” on page 6-4
“Data Logs” on page 6-5
“File Systems” on page 6-5
“Errors” on page 6-6
Target Computers
ConnectCompletedEventArgs Class
DisconnectCompletedEventArgs
Class
LoadCompletedEventArgs Class
RebootCompletedEventArgs Class
UnloadCompletedEventArgs Class
6-2
xPCProtocol Enumerated Data Type
Host computer and target computer
communication medium
xPCRS232BaudRate Enumerated
Data Type
Serial communication baud rate
xPCRS232Comport Enumerated
Data Type
Serial communication port
xPCTargetPC Class
Access
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ API for Microsoft® .NET Framework Classes
Target Applications
xPCApplication Class
Access to target application loaded
on target computer
xPCAppStatus Enumerated Data
Type
Target application status return
values
Scopes
SCDISPLAYMODE Enumerated
Data Type
Target scope display mode values
SCFILEMODE Enumerated Data
Type
Write mode values for when file
allocation table entry is updated
SCSTATUS Enumerated Data Type
Scope status values
SCTRIGGERMODE Enumerated
Data Type
Scope trigger mode values
SCTRIGGERSLOPE Enumerated
Data Type
Scope trigger slope values
SCTYPE Enumerated Data Type
Scope type
xPCFileScope Class
Access to file scopes
xPCFileScopeCollection Class
Collection of xPCFileScope objects
xPCFileScopeSignal Class
Access to file scope signals
xPCFileScopeSignalCollection Class
Collection of xPCFileScopeSignal
objects
xPCHostScope Class
Access to host scopes
xPCHostScopeCollection Class
Collection of xPCHostScope objects
xPCHostScopeSignal Class
Access to host scope signals
xPCHostScopeSignalCollection
Class
Collection of xPCHostScopeSignal
objects
xPCScope Class
Access
xPCScopeCollectionEventArgs Class
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-3
6
xPC Target™ API Reference for Microsoft® .NET Framework
xPCScopeRemCollectionEventArgs
Class
xPCScopes Class
Access scope objects
xPCScopeSignalCollectionEventArgs
Class
xPCTargetScope Class
Access to target scopes
xPCTargetScopeCollection Class
Collection of xPCTargetScope objects
xPCTargetScopeSignalCollection
Class
Collection of xPCHostScopeSignal
objects
xPCTgtScopeSignal Class
Access to target scope signals
Parameters
CancelPropertyNotificationEventArgs
Class
GetParamCompletedEventArgs
Class
PropertyNotificationEventArgs
Class
SetParamCompletedEventArgs
Class
xPCParameter Class
Single run-time tunable parameter
xPCParameters Class
Access run-time parameters
Signals
6-4
xPCSignal Class
Access signal objects
xPCSignals Class
Access signal objects
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ API for Microsoft® .NET Framework Classes
Data Logs
GetFileScSignalDataObjectCompletedEventArgs
Class
GetHostScSignalDataObjectCompletedEventArgs
Class
GetLogDataCompletedEventArgs
Class
xPCAppLogger Class
Access to target application loggers
xPCDataFileScSignalObject Class
Object that holds logged file scope
signal data
xPCDataHostScSignalObject Class
Object that holds logged host scope
signal data
xPCDataLoggingObject Class
Object that holds logged data
xPCLog Class
Base class
xPCLogMode Enumerated Data
Type
Specify log mode values
xPCLogType Enumerated Data Type
Logging type values
xPCOutputLogger Class
Access to output logger
xPCStateLogger Class
Access to state log
xPCTETLogger Class
Access to TET logger
xPCTimeLogger Class
Access to output log
File Systems
xPCDirectoryInfo Class
Access folders and subfolders of
target computer file system
xPCDriveInfo Class
Information for target computer
drive
xPCFileInfo Class
Access to file and xPCFileStream
objects
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-5
6
xPC Target™ API Reference for Microsoft® .NET Framework
xPCFileMode Enumerated Data
Type
Open file with permissions
xPCFileStream Class
Access xPCFileStream objects
xPCFileSystem Class
File system drives and folders
xPCFileSystemInfo Class
File system information
Errors
6-6
xPCException Class
Information for xPCException
xPCExceptionReason Enumerated
Data Type
Exception reasons
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPC Target™ API for Microsoft® .NET Framework — Alphabetical List
xPC Target API for Microsoft .NET Framework —
Alphabetical List
Namespace: MathWorks.xPCTarget.FrameWork
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-7
xPCFileScopeCollection.Add
Purpose
Create xPCFileScope object with next available scope ID as key
Syntax
public xPCFileScope Add()
public xPCFileScope Add(int ID)
public IList<xPCFileScope> Add(int[] arrayOfIDs)
IList
Description
Class: xPCFileScopeCollection Class
Method
Syntax Language: C#
public xPCFileScope Add() creates xPCFileScope object with the
next available scope ID as key. It then adds xPCFileScope object to
xPCFileScopeCollection object.
public xPCFileScope Add(int ID) creates xPCFileScope object with
ID as key. ID is 32-bit integer that specifies an ID for the scope object.
public IList<xPCFileScope> Add(int[] arrayOfIDs) creates an
IList of xPCFileScope objects with an array of IDs as keys. arrayOfIDs
is an array of 32-bit integers that specifies an array of IDs for scope
objects.
6-8
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileScopeSignalCollection.Add
Purpose
Add signals to file scope
Syntax
public
public
public
public
Description
Class: xPCFileScopeSignalCollection Class
xPCFileScopeSignal Add(xPCSignal signal)
xPCFileScopeSignal Add(string blkPath)
xPCFileScopeSignal Add(int sigId)
IList<xPCFileScopeSignal> Add(int[] sigIds)
Method
Syntax Language: C#
public xPCFileScopeSignal Add(xPCSignal signal) adds signals
to the file scope. It creates an xPCFileScopeSignal object with signal.
signal is the xPCSignal object that represents the actual signal. This
method returns a file scope signal object of type xPCFileScopeSignal.
public xPCFileScopeSignal Add(string blkPath) adds signal
to the file scope. It creates an xPCFileScopeSignal object that
blkPath specifies. blkPath is a string that specifies the signal name
(block path). This method returns a file scope signal object of type
xPCFileScopeSignal.
public xPCFileScopeSignal Add(int sigId) adds signals to the file
scope. It creates an xPCFileScopeSignal object specified with sigId.
sigId is a 32-bit integer that represents the actual signal. This method
returns a file scope signal object of type xPCFileScopeSignal.
public IList<xPCFileScopeSignal> Add(int[] sigIds) adds
signals to the file scope. It creates an ILIST of xPCFileScopeSignal
objects, one for each signal in the array of IDs. sigIds is an array of
32-bit integers that specifies an array of IDs that represent the actual
signals. This method returns an ILIST of xPCFileScopeSignal objects.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-9
xPCHostScopeCollection.Add
Purpose
Create xPCHostScope object with next available scope ID as key
Syntax
public xPCHostScope Add()
public xPCHostScope Add(int ID)
public IList<xPCHostScope> Add(int[] arrayOfIDs)
Description
Class: xPCHostScopeCollection Class
Method
Syntax Language: C#
public xPCHostScope Add() creates xPCHostScope object with
the next available scope ID as key. It then adds an xPCHostScope
object to xPCHostScopeCollection object. This method returns an
xPCHostScopeObject object.
public xPCHostScope Add(int ID) creates xPCHostScope object with
ID as key. ID is 32-bit integer that specifies an ID for the scope object.
This method returns an xPCHostScopeObject object.
public IList<xPCHostScope> Add(int[] arrayOfIDs) creates
an ILIST of xPCHostScope objects with an array of IDs as keys.
arrayOfIDs is an array of 32-bit integers that specifies an array of
IDs for scope objects.
Exception
6-10
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCHostScopeSignalCollection.Add
Purpose
Add signals to host scope
Syntax
public
public
public
public
Description
Class: xPCHostScopeSignalCollection Class
xPCHostScopeSignal Add(xPCSignal signal)
xPCHostScopeSignal Add(string blkpath)
xPCHostScopeSignal Add(int sigId)
IList<xPCHostScopeSignal> Add(int[] sigIds)
Method
Syntax Language: C#
public xPCHostScopeSignal Add(xPCSignal signal) adds signals
to the host scope. It creates xPCHostScopeSignal object with signal.
signal is the xPCSignal object that represents the actual signal. This
method returns an xPCHostScopeSignal object.
public xPCHostScopeSignal Add(string blkpath) adds signal
to the host scope. It creates an xPCHostScopeSignal object that
blkPath specifies. blkPath is a string that specifies the signal name
(block path). This method returns a host scope signal object of type
xPCHostScopeSignal.
public xPCHostScopeSignal Add(int sigId) adds signals to the
host scope. It creates an xPCHostScopeSignal object specified with
sigId. sigId is a 32-bit integer that represents the actual signal. This
method returns a host scope signal object of type xPCHostScopeSignal.
public IList<xPCHostScopeSignal> Add(int[] sigIds) adds
signals to the host scope. It creates an ILIST of xPCHostScopeSignal
objects, one for each signal in the array of IDs. sigIds is an array of
32-bit integers that specifies an array of IDs that represent the actual
signals. This method returns an ILIST of xPCHostScopeSignal objects.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-11
xPCTargetScopeCollection.Add
Purpose
Create xPCTargetScope object
Syntax
public xPCTargetScope Add()
public xPCTargetScope Add(int ID)
public IList<xPCTargetScope> Add(int[] arrayOfIDs)
Description
Class: xPCTargetScopeCollection Class
Method
Syntax Language: C#
public xPCTargetScope Add() creates xPCTargetScope object with
the next available scope ID as key. It then adds xPCTargetScope
object to xPCTargetScopeCollection object. This method returns an
xPCTargetScope object.
public xPCTargetScope Add(int ID) creates xPCTargetScope object
with ID as key. ID is 32-bit integer that specifies an ID for the scope
object. This method returns an xPCTargetScope object.
public IList<xPCTargetScope> Add(int[] arrayOfIDs) creates
an ILIST of xPCTargetScope objects with an array of IDs as keys.
arrayOfIDs is an array of 32-bit integers that specifies an array of IDs
for scope objects. This method returns an ILIST of xPCTargetScope
objects.
6-12
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetScopeSignalCollection.Add
Purpose
Create xPCTargetScopeSignal object
Syntax
public
public
public
public
Description
Class: xPCTargetScopeSignalCollection Class
xPCTgtScopeSignal Add(xPCSignal signal)
xPCTgtScopeSignal Add(string blkPath)
xPCTgtScopeSignal Add(int sigId)
IList<xPCTgtScopeSignal> Add(int[] sigIds)
Method
Syntax Language: C#
public xPCTgtScopeSignal Add(xPCSignal signal) creates
xPCTargetScopeSignal object with signal. It then adds
xPCTargetScopeSignal object to xPCTargetScopeSignalCollection
object. signal is of type xPCSignal. This method returns an
xPCTargetScopeSignal object.
public xPCTgtScopeSignal Add(string blkPath) adds signal to
the target scope. It creates an xPCTargetScopeSignal object that
blkPath specifies. blkPath is a string that specifies the signal name
(block path). This method returns a target scope signal object of type
xPCTgtScopeSignal.
public xPCTgtScopeSignal Add(int sigId) creates
xPCTargetScopeSignal object with sigId. It then adds
xPCTargetScopeSignal object to xPCTargetScopeSignalCollection
object. sigId is a 32-bit integer. This method returns an
xPCTargetScopeSignal object.
public IList<xPCTgtScopeSignal> Add(int[] sigIds) creates an
ILIST of xPCTargetScopeSignal objects with an array of IDs. sigIds is
an array of 32-bit integers that specifies an array of IDs for file scope
signal objects.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-13
xPCTargetScopeSignalCollection.Add
Exception
6-14
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileStream.Close
Purpose
Close current stream
Syntax
public void Close()
Description
Class: xPCFileStream Class
Method
Syntax Language: C#
public void Close() close the current stream and releases the
resources (such as file handles) associated with it.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException object
Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-15
xPCTargetPC.Connect
Purpose
Establish connection to target computer
Syntax
public void Connect()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void Connect() establishes a connection to a remote target
computer.
Exception
6-16
Exception
Condition
xPCException
When problem occurs, query xPCException object
Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.ConnectAsync
Purpose
Asynchronous request for target computer connection
Syntax
public void ConnectAsync()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void ConnectAsync() begins an asynchronous request for a
target computer connection.
Exception
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-17
xPCTargetPC.ConnectCompleted
Purpose
Event when xPCTargetPC.ConnectAsync completes
Syntax
public event ConnectCompleted ConnectCompleted
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event ConnectCompleted ConnectCompleted occurs when an
asynchronous connect operation completes.
6-18
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Connected
Purpose
Event after xPCTargetPC.Connect completes
Syntax
public event EventHandler Connected
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Connected occurs after connect
operation completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-19
xPCTargetPC.Connecting
Purpose
Event before xPCTargetPC.Connect starts
Syntax
public event EventHandler Connecting
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Connecting occurs before connect
operation completes.
6-20
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileInfo.CopyToHost
Purpose
Copies file from target computer file system to host file system
Syntax
public FileInfo CopyToHost(string HostDestFileName)
Description
Class: xPCFileInfo Class
Method
Syntax Language: C#
public FileInfo CopyToHost(string HostDestFileName) copies
file, HostDestFileName, from target computer file system to new
location on host file system. HostDestFileName is a string that specifies
the full path name for the file.
Exception
Exception
Condition
ArgumentException
HostDestFileName is empty, contains only
white spaces, or contains invalid characters.
ArgumentNullException
HostDestFileName is NULL reference.
NotSupportedException
HostDestFileName contains a colon (:) in the
PathTooLongException
The specified path, file name, or both in
HostDestFileName exceed the system-defined
maximum length. For example, on Windows
platforms, path names must be less than 248
characters. File names must be less than 260
characters.
SecurityException
Caller does not have required permission.
middle of the string.
UnauthorizedAccess- System does not allow access to
Exception
HostDestFileName.
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-21
xPCFileInfo.Create
Purpose
Create file in specified path name
Syntax
public xPCFileStream Create()
Description
Class: xPCFileInfo Class
Method
Syntax Language: C#
public xPCFileStream Create() create file in specified path name.
Exception
6-22
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.Create
Purpose
Create folder
Syntax
public xPCDirectoryInfo CreateDirectory(string path)
Description
Class: xPCFileSystem Class
Method
Syntax Language: C#
public xPCDirectoryInfo CreateDirectory(string path) creates
folder on the target computer file system. path is a string that
specifies the full path name for the new folder. This method returns an
xPCDirectoryInfo object.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-23
xPCDirectoryInfo.Create
Purpose
Create folder
Syntax
public void Create()
Description
Class: xPCDirectoryInfo Class
Method
Syntax Language: C#
public void Create() creates a folder.
6-24
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystemInfo.Delete
Purpose
Delete current file or folder
Syntax
public abstract void Delete()
Description
Class: xPCFileSystemInfo Class
Method
Syntax Language: C#
public abstract void Delete() deletes current file or folder on the
target computer file system.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-25
xPCDirectoryInfo.Delete
Purpose
Delete empty xPCDirectoryInfo object
Syntax
public override void Delete()
Description
Class: xPCDirectoryInfo Class
Method
Syntax Language: C#
public override void Delete() deletes an empty xPCDirectoryInfo
object.
6-26
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileInfo.Delete
Purpose
Permanently delete file on target computer
Syntax
public override void Delete()
Description
Class: xPCFileInfo Class
Method
Syntax Language: C#
public override void Delete() permanently deletes files from
target computer.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-27
xPCTargetPC.Disconnect
Purpose
Disconnect from target computer
Syntax
public void Disconnect()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void Disconnect() closes the connection to the target
computer.
Exception
6-28
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.DisconnectAsync
Purpose
Asynchronous request to disconnect from target computer
Syntax
public void DisconnectAsync()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void DisconnectAsync() begins an asynchronous request to
disconnect from target computer.
Exception
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-29
xPCTargetPC.DisconnectCompleted
Purpose
Event when xPCTargetPC.DisconnectAsync completes
Syntax
public event DisconnectCompletedEventHandler DisconnectComplet
ed
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event DisconnectCompletedEventHandler
DisconnectComplet ed occurs when asynchronous disconnect
operation completes.
6-30
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Disconnected
Purpose
Event after xPCTargetPC.Disconnect completes
Syntax
public event EventHandler Disconnected
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Disconnected occurs after disconnect
operation completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-31
xPCTargetPC.Disconnecting
Purpose
Event before xPCTargetPC.Disconnect starts
Syntax
public event EventHandler Disconnecting
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Disconnecting occurs before disconnect
operation completes.
6-32
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Dispose
Purpose
Clean up used resources
Syntax
public void Dispose()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void Dispose() cleans up used resources.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-33
xPCTargetPC.Disposed
Purpose
Event after xPCTargetPC.Dispose completes
Syntax
public event EventHandler Disposed
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Disposed occurs after disposal of used
resources completes.
6-34
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.GetCurrentDirectory
Purpose
Current working folder for target application
Syntax
public string GetCurrentDirectory()
Description
Class: xPCFileSystem Class
Method
Syntax Language: C#
public string GetCurrentDirectory() gets the current working
folder of the target application. This method returns the current
working folder name as a string.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-35
xPCDataLoggingObject.GetData
Purpose
Copies signal data from target computer
Syntax
public double[] GetData()
Description
Class: xPCDataLoggingObject Class
Method
Syntax Language: C#
public double[] GetData() copies logged data from the target
computer to the host computer.
6-36
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDataFileScSignalObject.GetData
Purpose
Copies file scope signal data from target computer
Syntax
public double[] GetData()
Description
Class: xPCDataFileScSignalObject Class
Method
Syntax Language: C#
public double[] GetData() copies logged file scope signal data from
the target computer to the host computer.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-37
xPCDataHostScSignalObject.GetData
Purpose
Copies host scope signal data from target computer
Syntax
public double[] GetData()
Description
Class: xPCDataHostScSignalObject Class
Method
Syntax Language: C#
public double[] GetData() copies logged host scope signal data from
the target computer to the host computer.
6-38
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDataLoggingObject.GetDataAsync
Purpose
Asynchronously copies signal data from target computer without
blocking calling thread
Syntax
public void GetDataAsync()
public void GetDataAsync(Object taskId)
Description
Class: xPCDataLoggingObject Class
Method
Syntax Language: C#
public void GetDataAsync() asynchronously copies the logged data
from the target computer without blocking the calling thread.
public void GetDataAsync(Object taskId) receives taskId
(user-defined object) when the method copies the logged data.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-39
xPCDataFileScSignalObject.GetDataAsync
Purpose
Asynchronously copies file scope signal data from target computer
without blocking calling thread
Syntax
public void GetDataAsync()
public void GetDataAsync(Object taskId)
Description
Class: xPCDataFileScSignalObject Class
Method
Syntax Language: C#
public void GetDataAsync() asynchronously copies the file scope
signal logged data from the target computer without blocking the
calling thread.
public void GetDataAsync(Object taskId) receives taskId
(user-defined object) when the method copies the file scope signal logged
data. In other words, when the asynchronous operation completes.
Exception
6-40
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDataHostScSignalObject.GetDataAsync
Purpose
Asynchronously copies host scope signal data from target computer
without blocking calling thread
Syntax
public void GetDataAsync()
public void GetDataAsync(Object taskId)
Description
Class: xPCDataHostScSignalObject Class
Method
Syntax Language: C#
public void GetDataAsync() asynchronously copies the host scope
signal logged data from the target computer without blocking the
calling thread.
public void GetDataAsync(Object taskId) receives taskId
(user-defined object) when the method copies the host scope signal
logged data. In other words, when the asynchronous operation
completes.
Exception
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-41
xPCDataLoggingObject.GetDataCompleted
Purpose
Event when xPCDataLoggingObject.GetDataAsync completes
Syntax
public event GetDataCompletedEventHandler GetDataCompleted
Description
Class: xPCDataLoggingObject Class
Event
Syntax Language: C#
public event GetDataCompletedEventHandler GetDataCompleted
occurs when the asynchronous copying of logged data completes.
6-42
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDataFileScSignalObject.GetDataCompleted
Purpose
Event when xPCDataFileScSignalObject.GetDataAsync completes
Syntax
public event GetFileScSignalDataCompletedEventHandler GetDataC
ompleted
Description
Class: xPCDataFileScSignalObject Class
Event
Syntax Language: C#
public event GetFileScSignalDataCompletedEventHandler
GetDataC ompleted occurs when the asynchronous copying of file scope
signal logged data completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-43
xPCDataHostScSignalObject.GetDataCompleted
Purpose
Event when xPCDataHostScSignalObject.GetDataAsync completes
Syntax
public event GetDataCompletedEventHandler GetDataCompleted
Description
Class: xPCDataHostScSignalObject Class
Event
Syntax Language: C#
public event GetDataCompletedEventHandler GetDataCompleted
occurs when the asynchronous copying of host scope signal logged data
completes.
6-44
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDirectoryInfo.GetDirectories
Purpose
Subfolders of current folder
Syntax
public xPCDirectoryInfo[] GetDirectories()
Description
Class: xPCDirectoryInfo Class
Method
Syntax Language: C#
public xPCDirectoryInfo[] GetDirectories() returns the
subfolders of the current folder. This method returns the list of
subfolders as an xPCDirectoryInfo array.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-45
xPCFileSystem.GetDrives
Purpose
Drive names for logical drives on target computer
Syntax
public xPCDriveInfo[] GetDrives()
Description
Class: xPCFileSystem Class
Method
Syntax Language: C#
public xPCDriveInfo[] GetDrives() retrieves the drive names of
the logical drives on the target computer. This method returns an
xPCDriveInfo array.
Exception
6-46
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDirectoryInfo.GetFiles
Purpose
File list from current folder
Syntax
public xPCFileInfo[] GetFiles()
Description
Class: xPCDirectoryInfo Class
Method
Syntax Language: C#
public xPCFileInfo[] GetFiles() returns a file list from the current
folder. This method returns the list of files as an xPCFileInfo array.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-47
xPCDirectoryInfo.GetFileSystemInfos
Purpose
File system information for files and subfolders in folder
Syntax
public xPCFileSystemInfo[] GetFileSystemInfos()
Description
Class: xPCDirectoryInfo Class
Method
Syntax Language: C#
public xPCFileSystemInfo[] GetFileSystemInfos() returns an
array of strongly typed xPCFileSystemInfo entries. These entries
represent the files and subfolders in a folder.
6-48
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCParameter.GetParam
Purpose
Gets parameter values from target computer
Syntax
public double[] GetParam()
Description
Class: xPCParameter Class
Method
Syntax Language: C#
public double[] GetParam() gets parameter values from target
computer as an array of doubles.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-49
xPCParameter.GetParamAsync
Purpose
Asynchronous request to get parameter values from target computer
Syntax
public void GetParamAsync()
public void GetParamAsync(Object taskId)
Description
Class: xPCParameter Class
Method
Syntax Language: C#
public void GetParamAsync() begins an asynchronous request to get
parameter values from the target computer. This method does not block
the calling thread.
public void GetParamAsync(Object taskId) receives a user-defined
object when it completes its asynchronous request. taskId is a
user-defined object that you can have passed to the GetParamAsync
method upon completion.
Exception
Exception
Condition
InvalidOperation- When another thread uses this method.
Exception
6-50
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCParameter.GetParamCompleted
Purpose
Event when xPCParameter.GetParamAsync completes
Description
Class: xPCParameter Class
Event
Syntax Language: C#
public event GetParamCompletedEventHandler
GetParamCompleted occurs when an asynchronous get
parameter operation completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-51
xPCSignals.GetSignals
Purpose
List of xPCSignal objects specified by array of signal identifiers
Syntax
public IList<xPCSignal> GetSignals(string[] arrayofBlockPath)
public IList<xPCSignal> GetSignals(int[] arrayOfSigId)
Description
Class: xPCSignals Class
Method
Syntax Language: C#
public IList<xPCSignal> GetSignals(string[]
arrayofBlockPath) returns list of xPCSignal objects specified by array
of signal identifiers. This method creates an ILIST of xPCSignal objects
with an array of blockpaths. arrayofBlockPath is an array of strings
that contains the full block path names to signals.
public IList<xPCSignal> GetSignals(int[] arrayOfSigId)
returns the list of xPCSignal objects specified by an array of signal
identifiers. This method creates an ILIST of xPCSignal objects with an
array of signal identifiers. arrayOfSigId is an array of 32-bit integers
that specifies an array of signal identifiers.
Exception
6-52
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSignals.GetSignalsValue
Purpose
Vector of signal values from array
Syntax
public double[] GetSignalsValue(int[] arrayOfSigId)
public double[] GetSignalsValue(IList<xPCSignals> arrayOfSigOb
js)
Description
Class: xPCSignals Class
Method
Syntax Language: C#
public double[] GetSignalsValue(int[] arrayOfSigId) returns a
vector of signal values from an array containing its signal identifiers.
arrayOfSigId is an array of 32-bit signal identifiers. This method
returns the vector as a double.
public double[] GetSignalsValue(IList<xPCSignals>
arrayOfSigOb js) returns a vector of signal values from an IList that
contains xPCSignals objects. This method returns the vector as a
double.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-53
xPCSignal.GetValue
Purpose
Value of signal at moment of request
Syntax
public virtual double GetValue()
Description
Class: xPCSignal Class
Method
Syntax Language: C#
public virtual double GetValue() returns signal value at moment
of request.
Exception
6-54
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Load
Purpose
Load target application onto target computer
Syntax
public xPCApplication Load()
public xPCApplication Load(string DLMFileName)
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public xPCApplication Load() loads a target application (.dlm file
) onto the target computer. This method returns an xPCApplication
object.
public xPCApplication Load(string DLMFileName) loads
DLMFileName onto the target computer. DLMFileName is a string that
specifies the full path name to the target application to load on the
target computer. This method returns an xPCApplication object.
Exception
Exception
Condition
ArgumentException
DLMFileName is empty, contains only white
spaces, or contains invalid characters.
xPCException
When problem occurs, query xPCException
object Reason property.
InvalidOperationException
DLMFileName is a NULL reference (empty in
NotSupportedException
DLMFileName contains a colon (:) in the
PathTooLongException
The specified path, file name, or both in
DLMFileName exceed the system-defined
maximum length. For example, on Windows
platforms, path names must be less than 248
characters. File names must be less than 260
characters.
Visual Basic) or an empty string.
middle of the string.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-55
xPCTargetPC.Load
Exception
Condition
SecurityException
Caller does not have required permission.
UnauthorizedAccess- System does not allow access to DLMFileName.
Exception
6-56
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.LoadAsync
Purpose
Asynchronous request to load target application onto target computer
Syntax
public void LoadAsync()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void LoadAsync() begins an asynchronous request to load a
target application onto a target computer.
Exception
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-57
xPCTargetPC.LoadCompleted
Purpose
Event when xPCTargetPC.LoadAsync completes
Syntax
public event LoadCompletedEventHandler LoadCompleted
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event LoadCompletedEventHandler LoadCompleted occurs
when an asynchronous load operation completes.
6-58
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Loaded
Purpose
Event after xPCTargetPC.Load completes
Syntax
public event EventHandler Loaded
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Loaded occurs after target application
onto the target computer completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-59
xPCTargetPC.Loading
Purpose
Event before xPCTargetPC.Load starts
Syntax
public event EventHandler Loading
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Loading occurs before loading of target
application completes on the target computer.
6-60
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCParameters.LoadParameterSet
Purpose
Load parameter values for target application
Syntax
public void LoadParameterSet(string fileName)
Description
Class: xPCParameters Class
Method
Syntax Language: C#
public void LoadParameterSet(string fileName) loads parameter
values for the target application in a file. fileName is a string that
represents the file that contains the parameter values to be loaded.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-61
CancelPropertyNotificationEventArgs Class
Purpose
CancelPropertyNotification event data
Syntax
public class CancelPropertyNotificationEventArgs : PropertyNot
ificationEventArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class CancelPropertyNotificationEventArgs :
PropertyNot ificationEventArgs contains data returned from the
event of cancelling a property value change.
Properties
6-62
Properties
C# Declaration Syntax
Description
Cancel
public bool Cancel
{get; set;}
Get or set value indicating
whether or not to cancel
event.
NewValue
public Object NewValue
{get;}
Get new value of property.
OldValue
public Object OldValue
{get;}
Get old value of property.
PropertyName
public virtual string
PropertyName {get;}
Get name of property that
changed.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
ConnectCompletedEventArgs Class
Purpose
xPCTargetPC.ConnectCompleted event data
Syntax
public class ConnectCompletedEventArgs : AsyncCompletedEventAr
gs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class ConnectCompletedEventArgs :
AsyncCompletedEventAr gs contains data returned from the event of
asynchronously connecting to the target computer.
Properties
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-63
DisconnectCompletedEventArgs Class
Purpose
xPCTargetPC.DisconnectCompleted event data
Syntax
public class DisconnectCompletedEventArgs : AsyncCompletedEven
tArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class DisconnectCompletedEventArgs :
AsyncCompletedEven tArgs contains data returned from the
event of asynchronously disconnecting from the target computer.
Properties
6-64
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
GetDataCompletedEventArgs Class
Purpose
GetDataCompleted event data
Syntax
public class GetDataCompletedEventArgs : AsyncCompletedEventAr
gs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class GetDataCompletedEventArgs :
AsyncCompletedEventAr gs contains data returned from the event
of asynchronously completing a data access.
Properties
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
State
public Object State
{get;}
Optional. Get user-supplied
state object.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-65
GetFileScSignalDataObjectCompletedEventArgs Class
Purpose
xPCDataFileScSignalObject.GetDataCompleted event data
Syntax
public class GetFileScSignalDataObjectCompletedEventArgs : Get
DataCompletedEventArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class GetFileScSignalDataObjectCompletedEventArgs :
Get DataCompletedEventArgs contains data returned from the event
of completing an asynchronous data access to a file scope signal object.
Properties
6-66
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Data
public double[] Data
{get;}
Get the signal data collected
by file scope.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
FileScopeSignalObject
public bool
IsScopeSignal {get;}
Get reference to parent
xPCFileScopeSignal object
IsScopeSignal
public bool
IsScopeSignal {get;}
Get if signal is a scope signal
(true) or a time signal
(false).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
GetFileScSignalDataObjectCompletedEventArgs Class
Properties
C# Declaration Syntax
Description
State
public Object State
{get;}
Optional. Get user-supplied
state object.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-67
GetHostScSignalDataObjectCompletedEventArgs Class
Purpose
xPCDataHostScSignalObject.DataObjectCompleted event data
Syntax
public class GetHostScSignalDataObjectCompletedEventArgs : Get
DataCompletedEventArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class GetHostScSignalDataObjectCompletedEventArgs :
Get DataCompletedEventArgs contains data returned by the event of
completing an asynchronous data access to a host scope signal object.
Properties
6-68
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Data
public double[] Data
{get;}
Get the signal data collected
by host scope
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
IsScopeSignal
public bool
IsScopeSignal {get;}
Get if signal is a scope signal
(true) or a time signal
(false).
ScopeSignalObject
public xPCScopeSignal
ScopeSignalObject
{get;}
Get reference to parent
xPCHostScopeSignal object
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
GetHostScSignalDataObjectCompletedEventArgs Class
Properties
C# Declaration Syntax
Description
State
public Object State
{get;}
Optional. Get user-supplied
state object.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-69
GetLogDataCompletedEventArgs Class
Purpose
xPCDataLoggingObject.GetDataCompleted event data
Syntax
public class GetLogDataCompletedEventArgs : GetDataCompletedEv
entArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class GetLogDataCompletedEventArgs :
GetDataCompletedEv entArgs contains data returned by the
event of completing an asynchronous data access to a data logging
object.
Properties
6-70
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
Index
public int Index {get;}
Get log index.
LoggedData
public double[]
LoggedData {get;}
Get logged data.
LogType
public xPClogType
LogType {get;}
Get log type as xPClogType.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
GetLogDataCompletedEventArgs Class
Properties
C# Declaration Syntax
Description
State
public Object State
{get;}
Optional. Get user-supplied
state object.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-71
GetParamCompletedEventArgs Class
Purpose
xPCParameter.GetParamCompleted event data
Syntax
public class GetParamCompletedEventArgs : AsyncCompletedEventA
rgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class GetParamCompletedEventArgs :
AsyncCompletedEventA rgs contains data returned by the event of
completing an asynchronous parameter access.
Properties
6-72
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
Result
public double[] Result
{get;}
Get data values of the
xPCParameter object
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
LoadCompletedEventArgs Class
Purpose
xPCTargetPC.LoadCompleted event data
Syntax
public class LoadCompletedEventArgs : AsyncCompletedEventArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class LoadCompletedEventArgs :
AsyncCompletedEventArgs contains data returned by the event of
asynchronously loading a target application onto the target computer.
Properties
Properties
C# Declaration Syntax
Description
Application
public xPCApplication
Application {get;}
Get reference to
xPCApplication object.
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-73
PropertyNotificationEventArgs Class
Purpose
PropertyNotification event data
Syntax
public class PropertyNotificationEventArgs : PropertyChangedEv
entArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class PropertyNotificationEventArgs :
PropertyChangedEv entArgs contains data returned by the
event of changing property values.
Properties
6-74
Properties
C# Declaration Syntax
Description
NewValue
public Object NewValue
{get;}
Get new value of property.
OldValue
public Object OldValue
{get;}
Get old value of property.
PropertyName
public virtual string
PropertyName {get;}
Get name of property that
changed.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
RebootCompletedEventArgs Class
Purpose
xPCTargetPC.RebootCompleted event data
Syntax
public class RebootCompletedEventArgs : AsyncCompletedEventArg
s
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class RebootCompletedEventArgs :
AsyncCompletedEventArg s contains data returned by the event of
asynchronously restarting the target computer.
Properties
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-75
SetParamCompletedEventArgs Class
Purpose
xPCParameter.SetParamCompleted event data
Syntax
public class SetParamCompletedEventArgs : AsyncCompletedEventA
rgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class SetParamCompletedEventArgs :
AsyncCompletedEventA rgs contains data returned by the event of
asynchronously setting a parameter value.
Properties
6-76
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
NewValue
public Object NewValue
{get;}
Get new value of property.
OldValue
public Object OldValue
{get;}
Get old value of property.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
UnloadCompletedEventArgs Class
Purpose
xPCTargetPC.UnloadCompleted event data
Syntax
public class UnloadCompletedEventArgs : AsyncCompletedEventArg
s
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class UnloadCompletedEventArgs :
AsyncCompletedEventArg s contains data returned by the event
of asynchronously unloading the target application from the target
computer.
Properties
Properties
C# Declaration Syntax
Description
Cancelled
public bool Cancelled
{get;}
Get value that indicates if
an asynchronous operation
has been cancelled.
Error
public Exception Error
{get;}
Get value that indicates
which error occurred during
asynchronous operation.
UserState
public Object UserState
{get;}
Get unique identifier for
asynchronous task.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-77
xPCApplication Class
Purpose
Access to target application loaded on target computer
Syntax
public sealed class xPCApplication : xPCBaseNotification
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public sealed class xPCApplication :
xPCBaseNotification
initializes a new instance of the xPCApplication class.
Methods
Method
Description
xPCApplication.Start
Start target application execution
xPCApplication.Stop
Stop target application execution
Events
Events
Description
xPCApplication.Started Event after xPCApplication.Start completes
xPCApplication.Starting Event before xPCApplication.Start executes
xPCApplication.Stopped Event after xPCApplication.Stop completes
xPCApplication.Stopping Event before xPCApplication.Stop executes
6-78
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCApplication Class
Properties
Properties
C# Declaration
Syntax
Description
Exception
CPUOverload
public bool
CPUOverload
{get;}
Get state of
CPUOverload.
xPCException —
When problem
occurs, query
xPCException object
Reason property.
ExecTime
public double
ExecTime {get;}
Get execution time.
xPCException —
When problem
occurs, query
xPCException object
Reason property.
Logger
public
xPCAppLogger
Logger {get;}
Get reference to the
application logging
object.
MaximumTeT
public double
MaximumTeT {get;}
Get the maximum
time. The first
element contains
the maximum TET
number; the second
element contains
how long it took to
achieve the TET
time.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCException —
When problem
occurs, query
xPCException object
Reason property.
6-79
xPCApplication Class
6-80
Properties
C# Declaration
Syntax
Description
Exception
MinimumTeT
public double
MinimumTeT {get;}
Get the minimum
time. The first
element contains
the minimum TET
number; the second
element contains
how long it took to
achieve the TET
time.
xPCException —
When problem
occurs, query
xPCException object
Reason property.
Name
public string
Name {get;}
Get the current
name of the loaded
target application
xPCException —
When problem
occurs, query
xPCException object
Reason property.
Parameters
public
xPCParameters
Parameters {get;}
Get reference to
the xPCParameters
object.
SampleTime
public double
SampleTime {get;
set;}
Get or set Sample
time
Scopes
public xPCScopes
Scopes {get;}
Get collection of
scopes assigned to
the application
Signals
public xPCSignals
Signals {get;}
Get reference to
xPCSignals object
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCException —
When problem
occurs, query
xPCException object
Reason property.
xPCApplication Class
Properties
C# Declaration
Syntax
Description
Exception
Status
public
xPCAppStatus
Status {get;}
Get simulation
status. See
xPCException —
When problem
occurs, query
xPCException object
Reason property.
StopTime
public double
StopTime {get;
set;}
Get and set stop time
Target
public
xPCTargetPC
Target {get;}
Get reference to
parent xPCTargetPC
object.
xPCAppStatus
Enumerated Data
Type.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCException —
When problem
occurs, query
xPCException object
Reason property.
6-81
xPCAppLogger Class
Purpose
Access to target application loggers
Syntax
public class xPCAppLogger : xPCApplicationObject
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCAppLogger :
xPCApplicationObject initializes a
new instance of the xPCAppLogger class.
Properties
6-82
Properties
C# Declaration Syntax
Description
LogMode
public xPCLogMode
LogMode {get; set;}
Control which data points
to log. See xPCLogMode
Enumerated Data Type.
LogModeValue
public int LogModeValue
{get; set;}
MaxLogSamples
public int
MaxLogSamples {get;}
Get or set the
value-equidistant logging.
Set the value to the
difference in signal values.
Get maximum number of
samples that can be in log
buffer.
OutputLog
public xPCOutputLogger
OutputLog {get;}
Return a reference to the
xPCOutputLogger object.
StateLog
public xPCStateLogger
StateLog {get;}
Return a reference to the
xPCStateLogger object.
TETLog
public xPCTETLogger
TETLog {get;}
Return a reference to the
xPCTETLogger object.
TimeLog
public xPCTimeLogger
TimeLog {get;}
Return a reference to the
xPCTimeLogger object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDataFileScSignalObject Class
Purpose
Object that holds logged file scope signal data
Syntax
public class xPCDataFileScSignalObject : xPCFileScopeStream,
IxPCDataService
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCDataFileScSignalObject :
xPCFileScopeStream, IxPCDataService accesses an object that holds
logged file scope signal data.
Methods
Description
Method
xPCDataFileScSignalObject.GetData
Copies file scope signal data from target computer
xPCDataFileScSignalObject.GetDataAsync
Asynchronously copies file scope signal data from target
computer without blocking calling thread
Events
Event
Description
xPCDataFileScSignalObject.GetDataCompleted
Event when xPCDataFileScSignalObject.GetDataAsync
completes
Properties
Property
C# Declaration Syntax
Description
ScopeSignalObject
public xPCFileScopeSignal
ScopeSignalObject {get;}
Get parent scope signal
xPCFileScopeSignal object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-83
xPCDataHostScSignalObject Class
Purpose
Object that holds logged host scope signal data
Syntax
public class xPCDataHostScSignalObject : xPCApplicationNotfica
tionObject, IxPCDataService, IxPCDataServiceAsync
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCDataHostScSignalObject :
xPCApplicationNotfica tionObject, IxPCDataService,
IxPCDataServiceAsync accesses an object that holds logged host scope
signal data.
Methods
Description
Method
xPCDataHostScSignalObject.GetData
Copies host scope signal data from target computer
xPCDataHostScSignalObject.GetDataAsync
Asynchronously copies host scope signal data from target
computer without blocking calling thread
Events
Event
Description
xPCDataHostScSignalObject.GetDataCompleted
Event when xPCDataHostScSignalObject.GetDataAsync
completes
6-84
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDataHostScSignalObject Class
Properties
Property
C# Declaration Syntax
Description
Decimation
public int Decimation {get;
set;}
A number n, where every nth sample
is acquired in a scope window.
NumSamples
public int NumSamples {get;
set;}
Get or set number of contiguous
samples captured during the
acquisition of a data package. If the
scope stops before capturing this
number of samples, the scope has
the collected data up to the end of
data collection. It then has zeroes
for the remaining uncollected data.
Note what type of data you are
collecting, it is possible that your
data contains zeroes.
For file scopes, this parameter
works with the autorestart setting.
If autorestart is enabled, the
file scope collects data up to
NumSamples, then starts over
again, overwriting the buffer. If
autorestart is disabled, the file
scope collects data only up to
NumSamples, then stops.
ScopeSignalObject
public xPCHostScopeSignal
ScopeSignalObject {get;}
Get parent scope signal
xPCHostScopeSignal object.
Startindex
public int StartIndex {get;
set;}
Get and set the index of the first
sample to retrieve from the log.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-85
xPCDataLoggingObject Class
Purpose
Object that holds logged data
Syntax
public class xPCDataLoggingObject : xPCApplicationNotficationO
bject, IxPCDataService, xPCDataServiceAsync
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCDataLoggingObject :
xPCApplicationNotficationO bject, IxPCDataService,
xPCDataServiceAsync accesses an object that holds logged data.
Methods
Description
Method
xPCDataLoggingObject.GetData
Copies signal data from target computer
xPCDataLoggingObject.GetDataAsync
Asynchronously copies signal data from target computer
without blocking calling thread
Events
Event
Description
xPCDataLoggingObject.GetDataCompleted
Event when xPCDataLoggingObject.GetDataAsync completes
Properties
6-86
Property
C# Declaration Syntax
Description
Decimation
public int Decimation {get;
set;}
A number n, where every nth sample
is acquired in a scope window.
LogId
public int LogId {get;}
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDataLoggingObject Class
Property
C# Declaration Syntax
Description
NumSamples
public int NumSamples {get;
set;}
Get or set number of contiguous
samples captured during the
acquisition of a data package. If the
scope stops before capturing this
number of samples, the scope has
the collected data up to the end of
data collection. It then has zeroes
for the remaining uncollected data.
Note what type of data you are
collecting, it is possible that your
data contains zeroes.
For file scopes, this parameter
works with the autorestart setting.
If autorestart is enabled, the
file scope collects data up to
NumSamples, then starts over
again, overwriting the buffer. If
autorestart is disabled, the file
scope collects data only up to
NumSamples, then stops.
Startindex
public int StartIndex {get;
set;}
Get and set the index of the first
sample to retrieve from the log.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-87
xPCDirectoryInfo Class
Purpose
Access folders and subfolders of target computer file system
Syntax
public class xPCDirectoryInfo : xPCFileSystemInfo
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCDirectoryInfo :
xPCFileSystemInfo accesses
folders and subfolders of target computer file system.
Constructor
Constructor
Description
xPCDirectoryInfo
Construct new instance of the xPCirectoryInfo class on
specified path
Methods
Method
Description
xPCDirectoryInfo.Create Create folder
xPCDirectoryInfo.Delete Delete empty xPCDirectoryInfo object
xPCDirectoryInfo.GetDirectories
Subfolders of current folder
xPCDirectoryInfo.GetFiles
File list from current folder
xPCDirectoryInfo.GetFileSystemInfos
File system information for files and subfolders in folder
6-88
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDirectoryInfo Class
Properties
Property
Description
Exception
CreationTime public override
DateTime
CreationTime {get;}
Get creation time of the
current FileSystemInfo
object.
xPCException — When
problem occurs, query
xPCException object
Reason property.
Exists
public override
bool Exists {get;}
Get a boolean value
to indicate existence
of folder. A value of
1 indicates existent, 0
indicates nonexistent.
xPCException — When
problem occurs, query
xPCException object
Reason property.
Extension
public string
Extension {get;}
Get string that
represents the
extension part of the
file.
FullName
public virtual
string FullName
{get;}
Get full path name of
the folder or file.
Name
public override
string Name {get;}
Get the name of this
xPCDirectoryInfo
instance as a string.
xPCException — When
problem occurs, query
xPCException object
Reason property.
Parent
public
xPCDirectoryInfo
Parent {get;}
Get the parent folder of
a specified subfolder.
Root
public
xPCDirectoryInfo
Root {get;}
Get the root portion of
a path.
xPCException — When
problem occurs, query
xPCException object
Reason property.
xPCException — When
problem occurs, query
xPCException object
Reason property.
C# Declaration
Syntax
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-89
xPCDriveInfo Class
Purpose
Information for target computer drive
Syntax
public class xPCDriveInfo
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCDriveInfo accesses information on a target
computer drive.
Constructor
Constructor
Description
xPCDriveInfo
Initialize new instance of xPCDriveInfo class
Methods
Method
Description
xPCDriveInfo.Refresh
Synchronize with file drives on target computer
Properties
6-90
Property
C# Declaration
Syntax
Description
Exception
AvailableFreespace
public long
AvailableFreeSpace
{get;}
Indicate amount of
available free space on
drive.
xPCException — When
problem occurs, query
xPCException object
Reason property.
DriveFormat
public string
DriveFormat {get;}
Get name of file system
type, such as FAT16 or
FAT32.
xPCException — When
problem occurs, query
xPCException object
Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDriveInfo Class
Property
C# Declaration
Syntax
Description
Exception
Name
public string Name
{get;}
Get name of drive.
xPCException — When
problem occurs, query
xPCException object
Reason property.
RootDirectory
public
xPCDirectoryInfo
RootDirectory
{get;}
public long
TotalSize {get;}
Get root folder of drive.
xPCException — When
problem occurs, query
xPCException object
Reason property.
xPCException — When
problem occurs, query
xPCException object
Reason property.
public string
VolumeLabel {get;}
Get volume label of
drive.
TotalSize
VolumeLabel
Get total size of drive
in bytes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCException — When
problem occurs, query
xPCException object
Reason property.
6-91
xPCException Class
Purpose
Information for xPCException
Syntax
public class xPCException : Exception, ISerializable
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCException :
Exception, ISerializable
accesses information on xPC Target exceptions.
Constructor
Constructor
Description
xPCException
Construct new instance of xPCException class
Properties
6-92
Property
C# Declaration Syntax
Description
Data
public virtual IDictionary
Data {get;}
Get collection of key/value
pairs that provide additional
user-defined information about
the exception.
HelpLink
public virtual string
HelpLink {get; set;}
Get or set link to the help file
associated with this exception.
InnerException
public Exception
InnerException {get;}
Get Exception instance that
caused the current exception.
Message
public override string
Message {get;}
Get exception message. Overrides
Exception.Message property.
Reason
public xPCExceptionReason
Reason {get;}
Get xPCExceptionReason reason.
See xPCExceptionReason
Enumerated Data Type.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCException Class
Property
C# Declaration Syntax
Description
Source
public virtual string
Source {get; set;}
Get or set name of target
application or object that causes
the error.
StackTrace
public virtual string
StackTrace {get;}
Get string representation of
the frames on the call stack at
the time the method emits the
current exception.
TargetPCObject
public xPCTargetPC
TargetPCObject {get;}
Get xPCTargetPC object that
raised the error.
TargetSite
public MethodBase
TargetSite {get;}
Get method that emits the
current exception.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-93
xPCFileInfo Class
Purpose
Access to file and xPCFileStream objects
Syntax
public class xPCDriveInfo
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCDriveInfo accesses information on a target
computer drive.
Constructor
Constructor
Description
xPCFileInfo
Construct new instance of xPCFileInfo class
Methods
Description
Method
xPCFileInfo.CopyToHost Copies file from target computer file system to host file system
xPCFileInfo.Create
Create file in specified path name
xPCFileInfo.Delete
Permanently delete file on target computer
xPCFileInfo.Open
Open file
xPCFileInfo.OpenRead
Create read-only xPCFileStream object
xPCFileInfo.Rename
Rename file
xPCFileInfo
Construct new instance of xPCFileInfo class
Properties
6-94
Property
C# Declaration Syntax
Description
Directory
public xPCDirectoryInfo
Directory {get;}
Get an xPCDirectoryInfo object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileInfo Class
Property
C# Declaration Syntax
Description
DirectoryName
public string DirectoryName
{get;}
Get a string that represents the
full folder path name.
Exists
public override bool Exists
{get;}
Get value that indicates whether
a file exists.
Length
public long Length {get;}
Get the size, in bytes, of the
current file.
Name
public override string Name
{get;}
Get the name of the file.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-95
xPCFileScope Class
Purpose
Access to file scopes
Syntax
public class xPCFileScope : xPCScope
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCFileScope :
xPCScope initializes a new instance
of the xPCFileScope class.
Methods
The xPCFileScope class inherits methods from xPCScope Class.
Events
The xPCFileScope class inherits events from xPCScope Class.
6-96
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileScope Class
Properties
The xPCFileScope class inherits its other properties from xPCScope
Class.
Property
C# Declaration Syntax
AutoRestart public bool
AutoRestart {get;
set;}
DataTimeObject
Description
Exception
Get or set the file scope
autorestart setting.
AutoRestart is a
boolean. Values are
'on' and 'off'.
xPCException —
public
Get data time object.
xPCDataHostScSignalObject
DataTimeObject {get;}
When problem occurs,
query xPCException
object Reason property.
xPCException —
When problem occurs,
query xPCException
object Reason property.
DynamicMode public bool
DynamicMode {get;
set;}
Get or set ability to
dynamically create
multiple log files for
file scopes. Values are
'on' and 'off' . By
default, the value is
'off'.
xPCException —
FileMode
Get or set write mode of
file. See xPCFileMode
xPCException —
public SCFILEMODE
FileMode {get; set;}
Enumerated Data
Type.
FileName
public string
FileName {get; set;}
When problem occurs,
query xPCException
object Reason property.
When problem occurs,
query xPCException
object Reason property.
Get or set file name for
scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-97
xPCFileScope Class
Property
C# Declaration Syntax
Description
Exception
MaxWriteFileSize
public uint
MaxWriteFileSize
{get; set;}
Get or set the
maximum file size
in bytes allowed before
incrementing to the
next file.
xPCException —
When the size of
a log file reaches
MaxWriteFileSize,
the software creates
a subsequently
numbered file name,
and continues logging
data to that file, up
until the highest log
file number you have
specified.
If the software cannot
create additional log
files, it overwrites the
first log file.
This value must be a
multiple of WriteSize.
Default is 536870912.
Signals
6-98
public xPCTargetScopeSignalCollection
Signals {get;}
Get collection of
file scope signals
(xPCFileScopeSignalCollection)
assigned to this scope
object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
When problem occurs,
query xPCException
object Reason property.
xPCFileScope Class
Property
C# Declaration Syntax
Description
Exception
TriggerSignal
public
xPCTgtScopeSignal
TriggerSignal {get;
set;}
Get or set file
scope signal
(xPCFileScopeSignal)
used to trigger the
scope.
xPCException —
WriteSize
public int WriteSize
{get; set;}
Get or set the unit
number of bytes for
memory buffer writes.
The memory buffer
accumulates data in
multiples of write size.
WriteSize must be
multiple of 512.
xPCException —
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
When problem occurs,
query xPCException
object Reason property.
When problem occurs,
query xPCException
object Reason property.
6-99
xPCFileScopeCollection Class
Purpose
Collection of xPCFileScope objects
Syntax
public class xPCFileScopeCollection : xPCScopeCollection<xPCFi
leScope>
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCFileScopeCollection :
xPCScopeCollection<xPCFi leScope> initializes collection of
xPCFileScope objects.
Methods
Method
Description
xPCFileScopeCollection.Add
Create xPCFileScope object with the next available scope ID
as key
xPCFileScopeCollection.Refresh
Synchronize with file scopes on target computer
xPCFileScopeCollection.StartAll
Start all file scopes in one call
xPCFileScopeCollection.StopAll
Stop all file scopes in one call
6-100
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileScopeSignal Class
Purpose
Access to file scope signals
Syntax
public class xPCFileScopeSignal : xPCScopeSignal
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCFileScopeSignal :
xPCScopeSignal initializes
access to file scope signals.
Properties
Property
C# Declaration Syntax
Description
FileScopeSignalDataObject
public
xPCDataFileScSignalObject
FileScopeSignalDataObject
{get;}
Gets the data
xPCDataFileScSignalObject
object associated with this
xPCFileScopeSignal object.
Scope
public xPCFileScope Scope
{get;}
Get parent file scope
xPCFileScope object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-101
xPCFileScopeSignalCollection Class
Purpose
Collection of xPCFileScopeSignal objects
Syntax
public class xPCFileScopeSignalCollection : xPCScopeSignalColl
ection<xPCFileScopeSignal>
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCFileScopeSignalCollection :
xPCScopeSignalColl ection<xPCFileScopeSignal> initializes
collection of xPCFileScopeSignal objects.
Methods
Method
Description
xPCFileScopeSignalCollection.Add
Add signals to file scope
xPCFileScopeSignalCollection.Refresh
Synchronize with signals for associated scope on target
computer
Properties
Property
C# Declaration
Syntax
Description
Exception
Item
public
xPCFileScopeSignal
Item[string
blkpath] {get;}
Get
xPCFileScopeSignal
object from signal name
(blkpath).
xPCException — When
problem occurs, query
xPCException object
Reason property.
blkpath is the
signal name that
represents a signal
object added to its
parent xPCHostScope
object. This property
returns the file scope
6-102
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileScopeSignalCollection Class
Property
C# Declaration
Syntax
Description
Exception
signal object as type
xPCFileScopeSignal.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-103
xPCFileStream Class
Purpose
Access xPCFileStream objects
Syntax
public class xPCFileStream : IDisposable
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
IDisposable initializes
xPCFileStream objects. These objects expose the file stream around a
file.
public class xPCFileStream :
Constructor
Constructor
Description
xPCFileStream
Construct new instance of xPCFileStream class
Methods
Method
Constructor
xPCFileStream.Close
Close current stream
xPCFileStream.Read
Read block of bytes from stream and write data to buffer
xPCFileStream.Write
Write block of bytes to file stream
xPCFileStream.WriteByte Writes byte to current position in file stream
Property
6-104
Property C# Declaration Syntax
Description
Exception
Length
Get length of file stream.
xPCException — When
public long Length
{get;}
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
problem occurs, query
xPCException object
Reason property.
xPCFileSystem Class
Purpose
File system drives and folders
Syntax
public class xPCFileSystem
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCFileSystem initializes file system drive and folder
objects.
Methods
Method
Description
xPCFileSystem.Create
Create folder
xPCFileSystem.GetCurrentDirectory
Current working folder for target application
xPCFileSystem.GetDrives Drive names for the logical drives on the target computer
xPCFileSystem.RemoveFileRemove file name from target computer
xPCFileSystem.SetCurrentDirectory
Current folder
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-105
xPCFileSystemInfo Class
Purpose
File system information
Syntax
public abstract class xPCFileSystemInfo
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public abstract class xPCFileSystemInfo initializes file system
information objects.
Constructor
Constructor
Description
xPCFileSystemInfo
Initialize new instance of xPCFileSystemInfo class
Methods
Method
Description
xPCFileSystemInfo.DeleteDelete current folder
Properties
6-106
Property
C# Declaration Syntax
Description
CreationTime
public DateTime CreationTime
{get;}
Get creation time of current
FileSystemInfo object.
Exists
public abstract bool Exists
{get;}
Get value that indicates existence
of file or folder.
Extension
public string Extension {get;}
Get string that represents file
extension.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystemInfo Class
Property
C# Declaration Syntax
Description
FullName
public virtual string FullName
{get;}
Get full path name of file or folder.
Name
public abstract string Name
{get;}
Get name of folder.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-107
xPCHostScope Class
Purpose
Access to host scopes
Syntax
public class xPCHostScope : xPCScope
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCHostScope :
xPCScope initializes a new instance
of the xPCHostScope class.
Methods
The xPCHostScope class inherits methods from xPCScope Class.
Events
The xPCHostScope class inherits events from xPCScope Class.
Properties
The xPCHostScope class inherits its other properties from xPCScope
Class.
6-108
Property
C# Declaration
Syntax
Description
DataTimeObject
public
xPCDataHostScSignalObject
DataTimeObject
{get;}
Get host scope time data
object xPCDataHostScSignalObject
associated with this
scope.
Signals
public xPCTargetScopeSignal-
Get collection of host
scope signals (xPCHost-
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Exception
xPCHostScope Class
Property
TriggerSignal
C# Declaration
Syntax
Description
Collection Signals
{get;}
ScopeSignalCollection)
assigned to this scope
object.
public xPCTgtScopeSignal TriggerSignal
{get; set;}
Get or set host scope
signal (xPCHostScopeSignal) used to trigger
the scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Exception
xPCException — When
problem occurs, query
xPCException object
Reason property.
6-109
xPCHostScopeCollection Class
Purpose
Collection of xPCHostScope objects
Syntax
public class xPCHostScopeCollection : xPCScopeCollection<xPCHo
stScope>
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCHostScopeCollection :
xPCScopeCollection<xPCHo stScope> initializes collection of
xPCHostScope objects.
Methods
Method
Description
xPCHostScopeCollection.Add
Create xPCHostScope object with the next available scope ID
as key
xPCHostScopeCollection.Refresh
Refresh host scope object state
xPCHostScopeCollection.StartAll
Start all host scopes in one call
xPCHostScopeCollection.StopAll
Stop all host scopes in one call
6-110
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCHostScopeSignal Class
Purpose
Access to host scope signals
Syntax
public class xPCHostScopeSignal : xPCScopeSignal
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCHostScopeSignal :
xPCScopeSignal initializes
access to host scope signals.
Properties
Property
C# Declaration Syntax
Description
HostScopeSignalDataObject
public
xPCDataHostScSignalObject
HostScopeSignalDataObject
{get;}
Get host scope signal data object.
Scope
public xPCHostScope Scope
{get;}
Get host scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-111
xPCHostScopeSignalCollection Class
Purpose
Collection of xPCHostScopeSignal objects
Syntax
public class xPCHostScopeSignal : xPCScopeSignal
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCHostScopeSignal :
xPCScopeSignal represents a
collection of xPCHostScopeSignal objects.
Methods
Method
Description
xPCHostScopeSignalCollection.Add
Creates xPCHostScopeSignal object
xPCHostScopeSignalCollection.Refresh
Synchronize signals for associated host scopes on target
computer
Properties
Property
C# Declaration
Syntax
Description
Exception
Item
public
xPCHostScopeSignal
Item[string
blkpath] {get;}
Get
xPCHostScopeSignal
object from signal name
(blkpath).
xPCException — When
problem occurs, query
xPCException object
Reason property.
blkpath is the signal
name that represents
a signal object
added to its parent
xPCHostScope object.
This property returns
the file scope signal
6-112
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCHostScopeSignalCollection Class
Property
C# Declaration
Syntax
Description
Exception
object as type
xPCHostScopeSignal.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-113
xPCLog Class
Purpose
Base data logging class
Syntax
public abstract class xPCLog : xPCApplicationObject
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public abstract class xPCLog :
xPCApplicationObject
represents the base data logging class.
Properties
6-114
Properties
C# Declaration Syntax
Description
IsEnabled
public abstract bool
IsEnabled {get;}
Get whether to enable or
disable logging.
NumLogSamples
public int NumLogSamples
{get;}
Get number of samples in log
buffer.
NumLogWraps
public int NumLogWraps
{get;}
Get number of times log
buffer wraps.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCOutputLogger Class
Purpose
Access to output logger
Syntax
public class xPCOutputLogger : xPCLog
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCOutputLogger :
xPCLog initializes a new
instance of the xPCOutputLogger class.
Properties
The xPCOutputLogger class inherits its other properties from xPCLog
Class.
Properties
C# Declaration Syntax
Description
DataLoggingObjects
public
Get ILIST of application data
IList<xPCDataLoggingObject>logging objects.
DataLoggingObjects
{get;}
IsEnabled
public override bool
IsEnabled {get;}
Get whether to enable or
disable logging. Overrides
xPCLog.IsEnabled.
Item
public
xPCDataLoggingObject
Item[int index ] {get;}
Get xPCDataLogging object
specified by index (index).
index is the index to the
specified logging output. This
property returns an object of
type xPCDataLoggingObject.
NumOutputs
public int NumOutputs
{get;}
Return a reference to the
xPCOutputLogger object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-115
xPCParameter Class
Purpose
Single run-time tunable parameter
Syntax
public class xPCParameter : xPCApplicationNotficationObject
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCParameter :
xPCApplicationNotficationObject initializes a new instance of the
xPCParameter class. An xPCParameter object represents a single
specific target application parameter. You can tune the parameter
using xPCParameter objects.
Methods
Method
Description
xPCParameter.GetParam
Gets parameter values from target computer
xPCParameter.GetParamAsync
Asynchronous request to get parameter values from target
computer
xPCParameter.SetParam
Change value of parameter on target computer
xPCParameter.SetParamAsync
Asynchronous request to change parameter value on target
computer
Events
Event
Description
xPCParameter.GetParamCompleted
Event when xPCParameter.GetParamAsync completes
xPCParameter.SetParamCompleted
Event when xPCParameter.SetParamAsync completes
6-116
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCParameter Class
Properties
Property
C# Declaration
Syntax
Description
BlockPath
public string
BlockPath {get;}
Get the full block path
name of the parameter
for an instance of an
xPCParameter object.
DataType
public string
DataType {get;}
Get the Simulink
type, as a string, of
the parameter for
an instance of an
xPCParameter object.
Dimensions
public int[]
Dimensions {get;}
Get an array that
contains elements of
dimension lengths.
Name
public string Name
{get;}
Get the name of
the parameter to
an instance of an
xPCParameter
ParameterId
public int
ParameterId {get;}
Get the numerical
index (identifier) that
maps to an instance
of an xPCParameter
object.
Rank
public int Rank
{get;}
Get the number of
dimensions of the
parameter
Value
public Array Value
{get; set;}
Get and set the
parameter value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Exception
xPCException — When
problem occurs, query
xPCException object
Reason property.
6-117
xPCParameters Class
Purpose
Access run-time parameters
Syntax
public class xPCParameters : xPCApplicationObject
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
xPCApplicationObject initializes
a new instance of the xPCParameters class. An xPCParameters object
is a container to access run time parameters.
public class xPCParameters :
Methods
Description
Method
xPCParameters.LoadParameterSet
Load parameter values for target application
xPCParameters.Refresh
Refresh state of object
xPCParameters.SaveParameterSet
Save parameter values of target application
Properties
Property
C# Declaration Syntax
Description
NumParameters
public int NumParameters
{get;}
Get the total number of tunable
parameters in the target
application.
Item
public xPCParameter Item[int
paramIdx] {get;} or
Return reference to xPCParameter
object specified by its parameter
identifier (paramIdx) or parameter
name (paramname).
public xPCParameter
Item[string blkName, string
paramName] {get;}
paramIdx is a 32-bit integer
parameter identifier that
represents the actual signal.
6-118
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCParameters Class
Property
C# Declaration Syntax
Description
blkName is a string that specifies
the block path name for the actual
block that contains the parameter.
paramName is a string that specifies
the parameter name.
This method returns the
xPCParameter object that
represents the actual parameter.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-119
xPCScope Class
Purpose
Access xPC Target scopes
Syntax
public abstract class xPCScope : xPCApplicationNotficationObje
ct
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public abstract class xPCScope :
xPCApplicationNotficationObje ct initializes a new instance
of the xPCScope class.
Methods
Method
Description
xPCScope.Start
Start scope
xPCScope.Stop
Stop scope
xPCScope.Trigger
Software-trigger start of data acquisition for scopes
Events
Event
Description
xPCScope.ScopeStarted
Event after xPCScope.Start completes
xPCScope.ScopeStarting Event before xPCScope.Start executes
xPCScope.ScopeStopped
Event after xPCScope.Stop completes
xPCScope.ScopeStopping Event before xPCScope.Stop executes
6-120
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScope Class
Properties
Property
C# Declaration
Syntax
Description
Exception
Decimation
public int
Decimation {get;
set;}
Get or set a number
n, where every nth
sample is acquired in a
scope window.
xPCException —
public int
NumPrePostSamples
{get; set;}
Get or set number
of samples collected
before or after a trigger
event. The default
value is 0. Entering a
negative value collects
samples before the
trigger event. Entering
a positive value collects
samples after the
trigger event. If you
set TriggerMode to
'FreeRun', changing
this property does
not change data
acquisition.
xPCException —
NumPrePostSamples
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
When problem occurs,
query xPCException
object Reason property.
When problem occurs,
query xPCException
object Reason property.
6-121
xPCScope Class
Property
C# Declaration
Syntax
Description
Exception
NumSamples
public int
NumSamples {get;
set;}
Get or set number of
contiguous samples
captured during
the acquisition of a
data package. If the
scope stops before
capturing this number
of samples, the scope
has the collected data
up to the end of data
collection. It then
has zeroes for the
remaining uncollected
data. Note what type of
data you are collecting,
it is possible that your
data contains zeroes.
xPCException —
Num
For file scopes, this
parameter works
with the autorestart
setting. If autorestart
is enabled, the file
scope collects data
up to NumSamples,
then starts over
again, overwriting the
buffer. If autorestart is
disabled, the file scope
collects data only up
to NumSamples, then
stops.
ScopeId
6-122
public int ScopeId
{get;}
A numeric index,
unique for each scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
When problem occurs,
query xPCException
object Reason property.
xPCScope Class
Property
C# Declaration
Syntax
Description
Exception
Status
public SCSTATUS
Status {get;}
Indicate whether data
is being acquired,
the scope is waiting
for a trigger, the
scope has been
stopped (interrupted),
or acquisition is
finished. Values
are 'Acquiring',
xPCException —
When problem occurs,
query xPCException
object Reason property.
'Ready for being
Triggered',
'Interrupted', and
'Finished'.
TriggerAnySignal
public int
TriggerAnySignal
{get; set;}
Get or set xPCSignal
Class object for trigger
signal. If TriggerMode
is 'Signal', this signal
triggers the scope even
if it was not added to
the scope.
xPCException —
TriggerLevel
Get or set trigger level.
If TriggerMode is
'Signal', indicates
the value the signal
has to cross to trigger
the scope and start
acquiring data. You
can cross the trigger
level with either a
rising or falling signal.
xPCException —
public double
TriggerLevel {get;
set;}
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
When problem occurs,
query xPCException
object Reason property.
When problem occurs,
query xPCException
object Reason property.
6-123
xPCScope Class
Property
C# Declaration
Syntax
Description
Exception
TriggerMode
public
SCTRIGGERMODE
TriggerMode {get;
set;}
Get or set trigger mode
for a scope. Valid
values are 'FreeRun'
(default), 'Software',
'Signal', and
'Scope'.
xPCException —
public int
TriggerScope {get;
set;}
If TriggerMode is
'Scope', identifies
the scope to use for
a trigger. You can
set a scope to trigger
when another scope
is triggered. You
do this operation
by setting the slave
scope property
TriggerScope to the
scope index of the
master scope.
xPCException —
If TriggerMode is
'Scope', specifies the
number of samples
the triggering scope
is to acquire before
triggering a second
scope. This value must
be nonnegative.
xPCException —
TriggerScope
TriggerScope- public int
Sample
TriggerScopeSample
{get; set;}
6-124
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
When problem occurs,
query xPCException
object Reason property.
When problem occurs,
query xPCException
object Reason property.
When problem occurs,
query xPCException
object Reason property.
xPCScope Class
Property
C# Declaration
Syntax
Description
Exception
TriggerSlope
public TRIGGERSLOPE
{get; set;}
If TriggerMode is
'Signal', indicates
whether the trigger is
on a rising or falling
signal. Values are of
type SLTRIGGERSLOPE:
xPCException —
When problem occurs,
query xPCException
object Reason property.
SLTRIGGERSLOPE.EITHER
(default),
SLTRIGGERSLOPE.RISING,
and
SLTRIGGERSLOPE.FALLING.
This property
returns the value
SCTRIGGERSLOPE.
Type
public string Type
{get;}
Get scope type as a
string.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-125
xPCScopeCollectionEventArgs Class
Purpose
xPCScopeCollection.Added event data
Syntax
public class xPCScopeCollectionEventArgs : EventArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCScopeCollectionEventArgs :
EventArgs
contains data returned by the event of adding a scope to a scope
collection.
Properties
6-126
Properties
C# Declaration Syntax
Description
Scope
public xPCScope Scope
{get;}
Get xPCScope object you
added.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopeRemCollectionEventArgs Class
Purpose
xPCScopeCollection.Removed event data
Syntax
public class xPCScopeRemCollectionEventArgs : EventArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCScopeRemCollectionEventArgs :
EventArgs
contains data returned by the event of removing a scope from a scope
collection.
Properties
Properties
C# Declaration Syntax
Description
ScopeNumber
public int ScopeNumber
{get;}
Get scope number of the
scope that you have removed.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-127
xPCScopeSignalCollectionEventArgs Class
Purpose
xPCScopeSignalCollection.Added event data
Syntax
public class xPCScopeSignalCollectionEventArgs : EventArgs
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCScopeSignalCollectionEventArgs :
EventArgs
contains data returned by the event of adding a signal to a scope signal
collection.
Properties
6-128
Properties
C# Declaration Syntax
Description
Scope
public xPCScope Scope
{get;}
Get parent xPCScope object
Signal
public xPCSignal Signal
{get;}
Get xPCSignal object that
you added to collection.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes Class
Purpose
Access scope objects
Syntax
public class xPCScopes : xPCApplicationObject
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCScopes :
xPCApplicationObject initializes a
new instance of the xPCScopes class.
Methods
Method
Description
xPCScopes.RefreshAll
Synchronize with all scopes on target computer
Properties
Property
C# Declaration Syntax
Description
FileScopes
public
xPCFileScopeCollection
FileScopes {get;}
Get collection of file scopes
(xPCFileScopeCollection).
HostScopes
public
xPCHostScopeCollection
HostScopes {get;}
Get collection of host scopes
(xPCHostScopeCollection).
ScopeObjectDict
public IDictionary<int,
xPCScope> ScopeObjectDict
{get;}
Get entire scopes object as a
Dictionary object.
ScopeObjectList
public IList<xPCScope>
ScopeObjectList {get;}
Get entire scopes object as a list.
TargetScopes
public
xPCTargetScopeCollection
TargetScopes {get;}
Get collection of target scopes
(xPCTargetScopeCollection).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-129
xPCSignal Class
Purpose
Access signal objects
Syntax
public class xPCSignal : xPCApplicationObject
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCSignal :
xPCApplicationObject initializes a
new instance of the xPCSignal class.
Methods
Method
Description
xPCSignal.GetValue
Value of signal at moment of request
xPCSignal.TryGetValue
Status of get signal value at moment of request
Properties
6-130
Property
C# Declaration Syntax
Description
BlockPath
public virtual string
BlockPath {get;}
Get block path name (signal name)
of the signal.
DataType
public virtual string DataType
{get;}
Get Simulink data type name.
Label
public virtual string Label
{get;}
Get label of signal. If no label is
associated with the signal, this
property returns an empty string.
SignalId
public virtual int SignalId
{get;}
Get numeric identifier that
represents the signal object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSignal Class
Property
C# Declaration Syntax
Description
UserData
public Object UserData {get;
set;}
Get and set user-defined object that
you can use to store and retrieve
additional information.
Width
public virtual int Width
{get;}
Get signal width.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-131
xPCSignals Class
Purpose
Access signal objects
Syntax
public class xPCSignals : xPCApplicationObject
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCSignals :
xPCApplicationObject initializes a
new instance of the xPCSignals class.
Methods
Method
Description
xPCSignals.GetSignals
List of xPCSignal objects specified by array of signal identifiers
xPCSignals.GetSignalsValue
Vector of signal values from array
xPCSignals.Refresh
Refresh state of object
Properties
Property C# Declaration Syntax
Description
NumSignalspublic int
NumSignals {get;}
Get total numbers of
signals available in
target application.
this
Return reference to
xPCSignal object
specified by its signal
identifier (signalIdx) or
signal name (blkPath).
public xPCSignal
Item[int signalIdx ]
{get;} or
public xPCSignal
Item[string blkPath
] {get;}
signalIdx is a 32–bit
integer that identifies
the signal.
6-132
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Exception
xPCException — When
problem occurs, query
xPCException object
Reason property.
ArgumentNullException
— signalIdx or
xPCSignals Class
Property C# Declaration Syntax
Description
blkPath is a string that
specifies the block path
name for the signal.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Exception
blkPath is NULL
reference.
6-133
xPCStateLogger Class
Purpose
Access to state log
Syntax
public class xPCStateLogger : xPCLog
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCStateLogger :
xPCLog initializes a new instance
of the xPCStateLogger class.
Properties
The xPCStateLogger class inherits its other properties from xPCLog
Class.
Property
C# Declaration Syntax
Description
DataLoggingObjects
public
IList<xPCDataLoggingObject>
DataLoggingObjects {get;}
Get collection of
xPCDataLoggingObject items
available for state logging.
IsEnabled
public override bool
IsEnabled {get;}
Get whether to enable or disable
logging.
Overrides xPCLog.IsEnabled.
6-134
Item
public xPCDataLoggingObject
Item[ int index ] {get;}
Get reference to the
xPCLoggingObject that
corresponds to index (state
index). index is a 32–bit integer.
NumStates
public int NumStates {get;}
Get the number of states.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC Class
Purpose
Access target computer
Syntax
public xPCTargetPC()
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public xPCTargetPC() initializes a new instance of the xPCTargetPC
class.
Constructor
Constructor
Description
xPCTargetPC
Construct xPCTargetPC object.
Methods
Method
Description
xPCTargetPC.Connect
Establish connection to target computer
xPCTargetPC.ConnectAsyncAsynchronous request for target computer connection
xPCTargetPC.Disconnect Disconnect from target computer
xPCTargetPC.DisconnectAsync
Asynchronous request to disconnect from target computer
xPCTargetPC.Dispose
Clean up used resources
xPCTargetPC.Load
Load target application onto target computer
xPCTargetPC.LoadAsync
Asynchronous request to load target application onto target
computer
xPCTargetPC.Ping
Test communication between host and target computers
xPCTargetPC.Reboot
Restart target computer
xPCTargetPC.RebootAsync Asynchronous request to restart target computer
xPCTargetPC.tcpPing
Determine TCP/IP accessibility of remote computer
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-135
xPCTargetPC Class
Method
Description
xPCTargetPC.Unload
Unload target application from target computer
xPCTargetPC.UnloadAsync Asynchronous request to unload target application from target
computer
Events
Event
Description
xPCTargetPC.ConnectCompleted
Event when xPCTargetPC.ConnectAsync completes
xPCTargetPC.Connected
Event after xPCTargetPC.Connect completes
xPCTargetPC.Connecting Event before xPCTargetPC.Connect starts
xPCTargetPC.DisconnectCompleted
Event when xPCTargetPC.DisconnectAsync completes
xPCTargetPC.DisconnectedEvent after xPCTargetPC.Disconnect completes
xPCTargetPC.Disconnecting
Event before xPCTargetPC.Disconnect starts
xPCTargetPC.Disposed
Event after xPCTargetPC.Dispose completes
xPCTargetPC.LoadCompleted
Event when xPCTargetPC.LoadAsync completes
xPCTargetPC.Loaded
Event after xPCTargetPC.Load completes
xPCTargetPC.Loading
Event before xPCTargetPC.Load starts
xPCTargetPC.RebootCompleted
Event when xPCTargetPC.RebootAsync completes
xPCTargetPC.Rebooted
Event after xPCTargetPC.Reboot completes
xPCTargetPC.Rebooting
Event before xPCTargetPC.Reboot starts
xPCTargetPC.UnloadCompleted
Event when xPCTargetPC.UnloadAsync completes
6-136
xPCTargetPC.Unloaded
Event after xPCTargetPC.Unload completes
xPCTargetPC.Unloading
Event before xPCTargetPC.Unload starts
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC Class
Properties
Property
C# Declaration
Syntax
Description
Application
public
xPCApplication
Application {get;}
Get reference to an
Exception
xPCApplication
object that you can
use to interface with
the target application.
If no communication
is established, the
property returns a
NULL object.
Communication- public int
Get or set the
TimeOut
CommunicationTimeOut communication
{get; set;}
timeout in seconds.
Component
public IComponent
Component {get;}
Get component
associated with
the ISite when
implemented by a
class.
Container
public IContainer
Container {get;}
Get the IContainer
associated with
the ISite when
implemented by a
class.
ContainerControl
public
ContainerControl
ContainerControl
{get; set;}
Provide
focus-management
functionality for
controls that can
function as containers
for other controls.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCException —
When problem occurs,
query xPCException
object Reason
property.
6-137
xPCTargetPC Class
Property
C# Declaration
Syntax
Description
DLMFileName
public string
DLMFileName {get;
set;}
Get or set the full path
to the DLM file name.
Echo
public bool Echo
{get; set;}
Get or set the target
display on the target
computer.
FileSystem
public
xPCFileSystem
FileSystem {get;}
Get a reference to
an xPCFileSystem
object that you can
use to interface with
the target file system.
If no communication
is established, the
property returns a
NULL object.
HostTargetComm
public XPCProtocol
HostTargetComm
{get; set;}
Get or set the
physical medium
for communication.
See xPCProtocol
Enumerated Data
Type.
6-138
IsConnected
public bool
IsConnected {get;}
Get connection status
(established or not)
to a remote target
computer.
IsConnectingBusy
public bool
IsConnectingBusy
{get;}
Get ConnectAsync
request status (in
progress or not).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Exception
xPCException —
When problem occurs,
query xPCException
object Reason
property.
xPCTargetPC Class
Property
C# Declaration
Syntax
Description
IsDisconnectingBusy
public bool
IsDisconnectingBusy
{get;}
Get whether a
IsLoadingBusy
public bool
IsLoadingBusy
{get;}
Gets LoadAsync
request status (in
progress or not).
IsRebootingBusy
public bool
IsRebootingBusy
{get;}
Get RebootAsync
request status (in
progress or not).
IsUnloadingBusy
public bool
IsUnloadingBusy
{get;}
Gets unLoadingAsync
request status (in
progress or not).
RS232BaudRate
public
XPCRS232BaudRate
RS232Baudrate {get;
set;}
Get or set baudrate for
serial connection. See
public
XPCRS232CommPort
RS232HostPort {get;
set;}
Get or set the
serial COM port
for connection on
host computer. The
xPC Target software
automatically
determines the
COM port on the
target computer. See
RS232HostPort
Exception
DisconnectAsync
request is in progress.
xPCRS232BaudRate
Enumerated Data
Type.
xPCRS232Comport
Enumerated Data
Type.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-139
xPCTargetPC Class
6-140
Property
C# Declaration
Syntax
Description
Exception
SessionTime
public double
SessionTime {get;}
Get the length of time
xPC Target kernel has
been running on the
target computer.
xPCException —
Site
public ISite Site
{get; set;}
Get or set site of the
control.
TargetPCName
public string
TargetPCName {get;
set;}
Get or set a value
indicating the target
computer name
associated with the
target computer.
TcpIpTargetAddress
public string
TcpIpTargetAddress
{get; set;}
Get or set a valid IP
address for your target
computer.
TcpIpTargetPort
public string
TcpIpTargetPort
{get; set;}
Get or set the TCP/IP
target port. The
default is 22222 and
should not cause
problems. This
number is higher
than the reserved area
(for example, the port
numbers reserved for
telnet or ftp). The
software uses this
value only for the
target computer.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
When problem occurs,
query xPCException
object Reason
property.
xPCTargetScope Class
Purpose
Access to target scopes
Syntax
public class xPCTargetScope : xPCScope
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCTargetScope :
xPCScope initializes a new
instance of the xPCTargetScope class.
Methods
The xPCTargetScope class inherits methods from xPCScope Class.
Events
The xPCTargetScope class inherits events from xPCScope Class.
Properties
The xPCTargetScope class inherits its other properties from xPCScope
Class.
Property
C# Declaration
Syntax
Description
Exception
DisplayMode
public SCDISPLAYMODE
DisplayMode {get;
set;}
Get or set scope mode
for displaying signals.
xPCException — When
Grid
public bool Grid
{get; set;}
Get or set status of grid
line for particular scope.
xPCException — When
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
problem occurs, query
xPCException object
Reason property.
problem occurs, query
xPCException object
Reason property.
6-141
xPCTargetScope Class
6-142
Property
C# Declaration
Syntax
Description
Signals
public
xPCTargetScopeSignalCollection
Signals {get;}
Get the collection
of target scope
signals xPCTargetScopeSignalCollection
that you assign to this
scope object.
TriggerSignal
public
xPCTgtScopeSignal
TriggerSignal {get;
set;}
Get or set target
scope signal
xPCTgtScopeSignal
used to trigger the
scope.
xPCException — When
YLimit
public double[]
YLimit {get; set;}
Get or set y-axis
minimum and maximum
limits for scope.
xPCException — When
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Exception
problem occurs, query
xPCException object
Reason property.
problem occurs, query
xPCException object
Reason property.
xPCTargetScopeCollection Class
Purpose
Collection of xPCTargetScope objects
Syntax
public class xPCTargetScopeCollection : xPCScopeCollection<xPC
TargetScope>
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCTargetScopeCollection :
xPCScopeCollection<xPC TargetScope> initializes collection of
xPCTargetScope objects.
Methods
Method
Description
xPCTargetScopeCollection.Add
Create xPCTargetScope object with the next available scope
ID as key
xPCTargetScopeCollection.Refresh
Refresh target scope object state
xPCTargetScopeCollection.StartAll
Start all target scopes in one call
xPCTargetScopeCollection.StopAll
Stop all target scopes in one call
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-143
xPCTargetScopeSignalCollection Class
Purpose
Collection of xPCHostScopeSignal objects
Syntax
public class xPCTargetScopeSignalCollection : xPCScopeSignalCo
llection
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCTargetScopeSignalCollection :
xPCScopeSignalCo llection .
Methods
Method
Description
xPCTargetScopeSignalCollection.Add
Creates xPCTargetScopeSignal object
xPCTargetScopeSignalCollection.Refresh
Synchronize signals for associated target scopes on target
computer
Properties
Property
C# Declaration
Syntax
Description
Exception
Item
public
xPCTgtScopeSignal
Item[ string
blkpath ] {get;}
Get
xPCTgtScopeSignal
object from signal name
(blkpath).
xPCException — When
problem occurs, query
xPCException object
Reason property.
blkpath is the signal
name that represents
a signal object
added to its parent
xPCTargetScope object.
This property returns
the file scope signal
6-144
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetScopeSignalCollection Class
Property
C# Declaration
Syntax
Description
Exception
object as type
xPCTgtScopeSignal.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-145
xPCTETLogger Class
Purpose
Access to task execution time (TET) logger
Syntax
public class xPCTETLogger : xPCLog
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCTETLogger :
xPCLog initializes a new instance of
the xPCTETLogger class.
Properties
The xPCTETLogger class inherits its other properties from xPCLog
Class.
Properties
C# Declaration Syntax
Description
DataLogObject
public
xPCDataLoggingObject
DataLogObject {get;}
Get TET data logging object.
IsEnabled
public override bool
IsEnabled {get;}
Get whether to enable or
disable logging.
Overrides
xPCLog.IsEnabled.
6-146
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTgtScopeSignal Class
Purpose
Access to target scope signals
Syntax
public class xPCTgtScopeSignal : xPCScopeSignal
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCTgtScopeSignal :
xPCScopeSignal initializes
access to target scope signals.
Properties
Property
C# Declaration
Syntax
Description
Exception
Numerical
Format
public string
NumericalFormat
{get; set;}
Get and set numerical
format for the numeric
displayed signal
associated with this
object.
xPCException — When
Scope
public
xPCTargetScope
Scope {get;}
Get parent target
scope xPCTargetScope
object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
problem occurs, query
xPCException object
Reason property.
6-147
xPCTimeLogger Class
Purpose
Access to output log
Syntax
public class xPCTimeLogger : xPCLog
Description
Namespace: MathWorks.xPCTarget.FrameWork
Syntax Language: C#
public class xPCTimeLogger :
xPCLog initializes a new instance of
the xPCTimeLogger class.
Properties
The xPCTimeLogger class inherits its other properties from xPCLog
Class.
Properties
C# Declaration Syntax
Description
DataLogObjects
public
xPCDataLoggingObject
DataLogObject {get;}
Get the
xPCDataLoggingObject of
the time log.
IsEnabled
public override bool
IsEnabled {get;}
Get whether to enable or
disable logging.
Overrides
xPCLog.IsEnabled.
6-148
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileInfo.Open
Purpose
Open file
Syntax
public xPCFileStream Open(xPCFileMode fileMode)
Description
Class: xPCFileInfo Class
Method
Syntax Language: C#
public xPCFileStream Open(xPCFileMode fileMode) opens file with
specified mode. This method returns the xPCFileStream object for the
file. See xPCFileMode Enumerated Data Type for file mode options.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-149
xPCFileInfo.OpenRead
Purpose
Create read-only xPCFileStream object
Syntax
public xPCFileStream OpenRead()
Description
Class: xPCFileInfo Class
Method
Syntax Language: C#
public xPCFileStream OpenRead() creates a read-only
xPCFileStream object. This method returns the xPCFileStream object
for the file.
Exception
6-150
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Ping
Purpose
Test communication between host and target computers
Syntax
public bool Ping()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public bool Ping() tests the communication between host and target
computers. This method returns a boolean value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-151
xPCFileStream.Read
Purpose
Read block of bytes from stream and write data to buffer
Syntax
public int Read(byte[] buffer, int offset, int count)
Description
Class: xPCFileStream Class
Method
Syntax Language: C#
public int Read(byte[] buffer, int offset, int count) reads
a block of bytes from the file stream. It then writes the data to the
specified buffer, buffer. buffer specifies the size in bytes and is a
byte structure (8-bit unsigned integer). When this method returns, it
contains the byte array with the values between offset and (offset +
count - 1), replaced by the bytes read from the current source. offset is
an integer. It specifies the byte offset in the array at which the method
places the read bytes. count is an integer. It specifies the number of
bytes to read from the stream. This method returns the total number
of bytes the method reads into the buffer. This number might be less
than the number of bytes requested if that number of bytes are not
currently available. It can also be zero if the method reaches the end of
the stream.
Exception
6-152
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Reboot
Purpose
Restart target computer
Syntax
public void Reboot()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void Reboot() restarts the target computer.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-153
xPCTargetPC.RebootAsync
Purpose
Asynchronous request to restart target computer
Syntax
public void RebootAsync()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void RebootAsync() begins an asynchronous request to
restart a target computer .
Exception
6-154
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.RebootCompleted
Purpose
Event when xPCTargetPC.RebootAsync completes
Syntax
public event RebootCompletedEventHandler RebootCompleted
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event RebootCompletedEventHandler RebootCompleted
occurs when asynchronous restart operation completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-155
xPCTargetPC.Rebooted
Purpose
Event after xPCTargetPC.Reboot completes
Syntax
public event EventHandler Rebooted
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Rebooted occurs after target computer
restart completes.
6-156
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Rebooting
Purpose
Event before xPCTargetPC.Reboot starts
Syntax
public event EventHandler Rebooting
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Rebooting occurs before target
computer completes restarting.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-157
xPCFileScopeCollection.Refresh
Purpose
Synchronize with file scopes on target computer
Syntax
public override void Refresh()
Description
Class: xPCFileScopeCollection Class
Method
Syntax Language: C#
public override void Refresh() synchronizes with file scopes on
target computer.
Overrides xPCScopeCollection<xPCFileScope>.Refresh().
6-158
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.RefreshAll
Purpose
Refresh state of object
Syntax
public void RefreshAll()
Description
Class: xPCScopes Class
Method
Syntax Language: C#
public void RefreshAll() refreshes state of object..
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-159
xPCDriveInfo.Refresh
Purpose
Synchronize with file drives on target computer
Syntax
public void Refresh()
Description
Class: xPCDriveInfo Class
Method
Syntax Language: C#
public void Refresh() synchronizes with file drives on target
computer.
6-160
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileScopeSignalCollection.Refresh
Purpose
Synchronize with signals for associated scope on target computer
Syntax
public override void Refresh()
Description
Class: xPCFileScopeSignalCollection Class
Method
Syntax Language: C#
public override void Refresh() synchronizes with signals for
associated file scopes on target computer.
Overrides xPCScopeCollection<xPCFileScopeSignal>.Refresh().
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-161
xPCHostScopeCollection.Refresh
Purpose
Refresh host scope object state
Syntax
public override void Refresh()
Description
Class: xPCHostScopeCollection Class
Method
Syntax Language: C#
public override void Refresh() refreshes host scope object state.
Overrides xPCScopeCollection<xPCHostScope>.Refresh().
Exception
6-162
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCHostScopeSignalCollection.Refresh
Purpose
Synchronize signals for associated host scopes on target computer
Syntax
public override void Refresh()
Description
Class: xPCHostScopeSignalCollection Class
Method
Syntax Language: C#
public override void Refresh() synchronizes signals for associated
host scopes on target computer.
Overrides xPCScopeCollection<xPCHostScope>.Refresh().
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-163
xPCParameters.Refresh
Purpose
Refresh state of object
Syntax
public override void Refresh()
Description
Class: xPCParameters Class
Method
Syntax Language: C#
public override void Refresh() refreshes the state of the object.
6-164
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSignals.Refresh
Purpose
Refresh state of object
Syntax
public void Refresh()
Description
Class: xPCSignals Class
Method
Syntax Language: C#
public void Refresh() refreshes the state of the object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-165
xPCTargetScopeCollection.Refresh
Purpose
Refresh target scope object state
Syntax
public override void Refresh()
Description
Class: xPCTargetScopeCollection Class
Method
Syntax Language: C#
public override void Refresh() refreshes target scope object state.
Overrides xPCScopeCollection<xPCTargetScope>.Refresh().
6-166
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetScopeSignalCollection.Refresh
Purpose
Synchronize signals for associated target scopes on target computer
Syntax
public override void Refresh()
Description
Class: xPCTargetScopeSignalCollection Class
Method
Syntax Language: C#
public override void Refresh() synchronizes signals for associated
target scopes on target computer.
Overrides xPCScopeSignalCollection<xPCTgtScopeSignal>.Refresh().
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-167
xPCFileSystem.RemoveFile
Purpose
Remove file name from target computer
Syntax
public void RemoveFile(string fileName)
Description
Class: xPCFileSystem Class
Method
Syntax Language: C#
public void RemoveFile(string fileName) removes the specified
file name from the target computer. fileName is a string that specifies
the full path name to the file you want to remove.
Exception
6-168
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileInfo.Rename
Purpose
Rename file
Syntax
public xPCFileInfo Rename(string newName)
Description
Class: xPCFileInfo Class
Method
Syntax Language: C#
public xPCFileInfo Rename(string newName) changes file name to
newName. newName is a string. This method returns the xPCFileInfo
object.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-169
xPCParameters.SaveParameterSet
Purpose
Save parameter values of target application
Syntax
public void SaveParameterSet(string fileName)
Description
Class: xPCParameters Class
Method
Syntax Language: C#
public void SaveParameterSet(string fileName) saves parameter
values of the target application in a file. fileName is a string that
represents the file to contain the saved parameter values.
Exception
6-170
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
SCDISPLAYMODE Enumerated Data Type
Purpose
Target scope display mode values
Syntax
public enum SCDISPLAYMODE
Description
Enumerated Data Type
Syntax Language: C#
public enum SCDISPLAYMODE specifies target scope display mode
values.
Members
Member
Description
NUMERICAL
Specifies target scope drawing mode to display numerical value.
REDRAW
Specifies target scope drawing mode to redraw mode.
SLIDING
Specifies target scope drawing mode to sliding mode.
ROLLING
Specifies target scope drawing mode to rolling mode.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-171
SCFILEMODE Enumerated Data Type
Purpose
Write mode values for when file allocation table entry is updated
Syntax
public enum SCFILEMODE
Description
Enumerated Data Type
Syntax Language: C#
public enum SCFILEMODE specifies write mode values for when file
allocation table entry is updated.
Members
6-172
Member
Description
LAZY
Enables lazy write mode.
COMMIT
Enables commit write mode.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScope.ScopeStarted
Purpose
Event after xPCScope.Start completes
Syntax
public event EventHandler ScopeStarted
Description
Class: xPCScope Class
Event
Syntax Language: C#
public event EventHandler ScopeStarted occurs after scope start
command completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-173
xPCScope.ScopeStarting
Purpose
Event before xPCScope.Start executes
Syntax
public event EventHandler ScopeStarting
Description
Class: xPCScope Class
Event
Syntax Language: C#
public event EventHandler ScopeStarting occurs before scope
completes starting.
6-174
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScope.ScopeStopped
Purpose
Event after xPCScope.Stop completes
Syntax
public event EventHandler ScopeStarting
Description
Class: xPCScope Class
Event
Syntax Language: C#
public event EventHandler ScopeStarting occurs after scope
completes manual stop command.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-175
xPCScope.ScopeStopping
Purpose
Event before xPCScope.Stop executes
Syntax
public event EventHandler ScopeStopping
Description
Class: xPCScope Class
Event
Syntax Language: C#
public event EventHandler ScopeStopping occurs before scope
completes manual stop.
6-176
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
SCSTATUS Enumerated Data Type
Purpose
Scope status values
Syntax
public enum SCSTATUS
Description
Enumerated Data Type
Syntax Language: C#
public enum SCSTATUS specifies scope status values.
Members
Member
Description
WAITTOSTART
Scope is ready and waiting to start.
WAITFORTRIG
Scope is finished with the preacquiring state and waiting for a
trigger. If the scope does not preacquire data, it enters the wait
for trigger state.
ACQUIRING
Scope is acquiring data. The scope enters this state when it
leaves the wait for trigger state.
FINISHED
Scope is finished acquiring data when it has attained the
predefined limit.
INTERRUPTED
The user has stopped (interrupted) the scope.
PREACQUIRING
Scope acquires a predefined number of samples before triggering.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-177
SCTRIGGERMODE Enumerated Data Type
Purpose
Scope trigger mode values
Syntax
public enum SCTRIGGERMODE
Description
Enumerated Data Type
Syntax Language: C#
public enum SCTRIGGERMODE specifies scope trigger mode values.
Members
Member
Description
FREERUN
There is no external trigger condition.. The scope triggers when
it is ready to trigger, regardless of the circumstances.
Only user intervention can trigger the scope, and it can do so
regardless of circumstances. No other triggering is possible.
SOFTWARE
6-178
SIGNAL
Signal must cross a value before the scope is triggered.
SCOPE
Scope is triggered by another scope at a predefined trigger point
of the triggering scope. You modify this trigger point with the
value of TriggerScopeSample.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
SCTRIGGERSLOPE Enumerated Data Type
Purpose
Scope trigger slope values
Syntax
public enum SCTRIGGERSLOPE
Description
Enumerated Data Type
Syntax Language: C#
public enum SCTRIGGERSLOPE specifies scope trigger slope values.
Members
Member
Description
EITHER
The trigger slope can be rising or falling.
RISING
The trigger signal value must be rising when it crosses the
trigger value.
FALLING
The trigger signal value must be falling when it crosses the
trigger value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-179
SCTYPE Enumerated Data Type
Purpose
Scope type
Syntax
public enum SCTYPE
Description
Enumerated Data Type
Syntax Language: C#
public enum SCTYPE specifies scope type.
Members
6-180
Member
Description
HOST
Specifies scope as type host.
TARGET
Specifies scope as type target.
FILE
Specifies scope as type file.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.SetCurrentDirectory
Purpose
Current folder
Syntax
public void SetCurrentDirectory(string path)
Description
Class: xPCFileSystem Class
Method
Syntax Language: C#
public void SetCurrentDirectory(string path) sets the current
folder to the specified path name on the target computer. path is a
string that specifies the full path name to the folder you want to make
current.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-181
xPCParameter.SetParam
Purpose
Change value of parameter on target computer
Syntax
public void SetParam(double[] values)
Description
Class: xPCParameter Class
Method
Syntax Language: C#
public void SetParam(double[] values) sets the parameter to
values. Parameter values is a vector of doubles, assumed to be the size
required by the parameter type.
Exception
6-182
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCParameter.SetParamAsync
Purpose
Asynchronous request to change parameter value on target computer
Syntax
public void SetParamAsync(double[] values)
public void SetParamAsync(double[] values, Object taskId)
Description
Class: xPCParameter Class
Method
Syntax Language: C#
public void SetParamAsync(double[] values) begins an
asynchronous request to set parameter values to values on the target
computer. This method does not block the calling thread. values is a
vector of double values to which to set the parameter values.
public void SetParamAsync(double[] values, Object taskId)
receives a user-defined object when it completes its asynchronous
request. values is a vector of double values to which to set the
parameter values. taskId is a user-defined object that you can have
passed to the SetParamAsync method upon completion.
Exception
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-183
xPCParameter.SetParamCompleted
Purpose
Event when xPCParameter.SetParamAsync completes
Description
Class: xPCParameter Class
Event
Syntax Language: C#
public event SetParamCompletedEventHandler
SetParamCompleted occurs when an asynchronous set
parameter operation completes.
6-184
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCApplication.Start
Purpose
Start target application execution
Syntax
public void Start()
Description
Class: xPCApplication Class
Method
Syntax Language: C#
public void Start() starts the target application simulation.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-185
xPCFileScopeCollection.StartAll
Purpose
Start all file scopes in one call
Syntax
public void StartAll()
Description
Class: xPCFileScopeCollection Class
Method
Syntax Language: C#
public void StartAll() sequentially starts all file scopes using one
call. This method starts all the file scopes in the xPCFileScopeCollection.
6-186
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCHostScopeCollection.StartAll
Purpose
Start all host scopes in one call
Syntax
public void StartAll()
Description
Class: xPCHostScopeCollection Class
Method
Syntax Language: C#
public void StartAll() sequentially starts all host scopes
using one call. This method starts all the host scopes in the
xPCHostScopeCollection.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-187
xPCTargetScopeCollection.StartAll
Purpose
Start all target scopes in one call
Syntax
public void StartAll()
Description
Class: xPCTargetScopeCollection Class
Method
Syntax Language: C#
public void StartAll() sequentially starts all target scopes
using one call. This method starts all the target scopes in the
xPCTargetScopeCollection.
6-188
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScope.Start
Purpose
Start scope
Syntax
public void Start()
Description
Class: xPCScope Class
Method
Syntax Language: C#
public void Start() starts execution of scope on target computer.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-189
xPCApplication.Started
Purpose
Event after xPCApplication.Start completes
Syntax
public event EventHandler Started
Description
Class: xPCApplication Class
Event
Syntax Language: C#
public event EventHandler Started occurs after target application
start command completes.
6-190
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCApplication.Starting
Purpose
Event before xPCApplication.Start executes
Syntax
public event EventHandler Starting
Description
Class: xPCApplication Class
Event
Syntax Language: C#
public event EventHandler Starting occurs before target
application start command executes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-191
xPCApplication.Stop
Purpose
Stop target application execution
Syntax
public void Stop()
Description
Class: xPCApplication Class
Method
Syntax Language: C#
public void Stop() stops the target application simulation.
Exception
6-192
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileScopeCollection.StopAll
Purpose
Stop all file scopes in one call
Syntax
public void StartAll()
Description
Class: xPCFileScopeCollection Class
Method
Syntax Language: C#
public void StartAll() stops all file scopes using one call. This
method stops all the file scopes in the xPCFileScopeCollection.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-193
xPCHostScopeCollection.StopAll
Purpose
Stop all host scopes in one call
Syntax
public void StartAll()
Description
Class: xPCHostScopeCollection Class
Method
Syntax Language: C#
public void StartAll() sequentially stops all host scopes
using one call. This method stops all the host scopes in the
xPCHostScopeCollection.
Exception
6-194
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetScopeCollection.StopAll
Purpose
Stop all target scopes in one call
Syntax
public void StartAll()
Description
Class: xPCTargetScopeCollection Class
Method
Syntax Language: C#
public void StartAll() sequentially stops all target scopes
using one call. This method stops all the target scopes in the
xPCTargetScopeCollection.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-195
xPCScope.Stop
Purpose
Stop scope
Syntax
public void Stop()
Description
Class: xPCScope Class
Method
Syntax Language: C#
public void Stop() stops execution of scope on target computer.
Exception
6-196
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCApplication.Stopped
Purpose
Event after xPCApplication.Stop completes
Syntax
public event EventHandler Stopped
Description
Class: xPCApplication Class
Event
Syntax Language: C#
public event EventHandler Stopped occurs after target application
stop command completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-197
xPCApplication.Stopping
Purpose
Event before xPCApplication.Stop executes
Syntax
public event EventHandler Stopping
Description
Class: xPCApplication Class
Event
Syntax Language: C#
public event EventHandler Stopping occurs before target
application stop command executes.
6-198
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.tcpPing
Purpose
Determine TCP/IP accessibility of remote computer
Syntax
public bool tcpPing()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public bool tcpPing() allows a target application to determine
whether a remote computer is accessible on the TCP/IP network This
method returns a boolean value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-199
xPCScope.Trigger
Purpose
Software-trigger start of data acquisition for scope
Syntax
public void Trigger()
Description
Class: xPCScope Class
Method
Syntax Language: C#
public void Trigger() software-triggers start of data acquisition
for current scope.
Exception
6-200
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSignal.TryGetValue
Purpose
Status of get signal value at moment of request
Syntax
public virtual bool TryGetValue(ref double result)
Description
Class: xPCSignal Class
Method
Syntax Language: C#
public virtual bool TryGetValue(ref double result) returns
status of get signal value at moment of request. If the software detects
an error, this method returns false. Otherwise, the method returns true.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-201
xPCTargetPC.Unload
Purpose
Unload target application from target computer
Syntax
public void Unload()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void Unload() unloads a target application from a target
computer.
Exception
6-202
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.UnloadAsync
Purpose
Asynchronous request to unload target application from target computer
Syntax
public void UnloadAsync()
Description
Class: xPCTargetPC Class
Method
Syntax Language: C#
public void UnloadAsync() begins an asynchronous request to
unload a target application from a target computer.
Exception
Exception
Condition
InvalidOperationException
When another thread uses this method.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-203
xPCTargetPC.UnloadCompleted
Purpose
Event when xPCTargetPC.UnloadAsync completes
Syntax
public event UnloadCompletedEventHandler UnloadCompleted
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event UnloadCompletedEventHandler UnloadCompleted
occurs when asynchronous target application unload operation
completes.
6-204
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC.Unloaded
Purpose
Event after xPCTargetPC.Unload completes
Syntax
public event EventHandler Unloaded
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Unloaded occurs after target application
unload from the target computer completes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-205
xPCTargetPC.Unloading
Purpose
Event before xPCTargetPC.Unload starts
Syntax
public event EventHandler Unloading
Description
Class: xPCTargetPC Class
Event
Syntax Language: C#
public event EventHandler Unloading occurs before target
application unload from target computer completes.
6-206
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileStream.Write
Purpose
Write block of bytes to file stream
Syntax
public void Write(byte[] buffer, int count)
Description
Class: xPCFileStream Class
Method
Syntax Language: C#
public void Write(byte[] buffer, int count) writes data from a
block of bytes, buffer, to the current file stream. buffer contains the
data to write to the stream. It is a byte structure. count is an integer.
It specifies the number of bytes to write to the current file stream.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-207
xPCFileStream.WriteByte
Purpose
Write byte to current position in file stream
Syntax
public void WriteByte(byte value)
Description
Class: xPCFileStream Class
Method
Syntax Language: C#
public void WriteByte(byte value) writes a byte to the current
position in the file stream. value contains the byte of data that the
method writes to the file stream.
Exception
6-208
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCAppStatus Enumerated Data Type
Purpose
Target application status return values
Syntax
public enum xPCAppStatus
Description
Enumerated Data Type
Syntax Language: C#
public enum xPCAppStatus specifies target application status return
values.
Members
Member
Description
Stopped
Target application is stopped
Running
Target application is running
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-209
xPCDirectoryInfo
Purpose
Construct new instance of xPCDirectoryInfo class on specified path
Syntax
public xPCDirectoryInfo(xPCTargetPC tgt, string path)
Description
Class: xPCDirectoryInfo Class
Constructor
Syntax Language: C#
public xPCDirectoryInfo(xPCTargetPC tgt, string path)
initializes a new instance of the xPCirectoryInfo class on the path, path.
tgt is an xPCTargetPC object that represents the target computer for
which you initialize the class. path is a string that represents the path
on which to create the xPCDirectoryInfo object.
Exception
6-210
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDriveInfo
Purpose
Construct new instance of xPCDriveInfo class
Syntax
public xPCDriveInfo(xPCTargetPC tgt, string driveName)
Description
Class: xPCDriveInfo Class
Constructor
Syntax Language: C#
public xPCDriveInfo(xPCTargetPC tgt, string driveName)
initializes a new instance of the xPCDriveInfo class. tgt is an
xPCTargetPC object that represents the target computer for which
you want to the return drive information. driveName is a string that
represents the name of the drive.
Exception
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-211
xPCException
Purpose
Construct new instance of xPCException class
Syntax
public xPCException()
public xPCException(string message)
public xPCException(string message, Exception inner)
public xPCException(SerializationInfo info,
StreamingContext context)
public xPCException(int errId, string message,
xPCTargetPC tgt)
Description
Class: xPCException Class
Constructor
Syntax Language: C#
public xPCException() initializes a new instance of the xPCException
class.
public xPCException(string message) initializes a new instance of
the xPCException class with message. message is a string that contains
the text of the error message.
public xPCException(string message, Exception inner)
initializes a new instance of the xPCException class with message and
inner. message is a string. inner is a nested Exception object.
public xPCException(SerializationInfo info,
StreamingContext context) initializes a new instance of
the xPCException class with serialization information, info, and
streaming context, context. info is a SerializationInfo object. context
is a StreamingContext object.
public xPCException(int errId, string message, xPCTargetPC
tgt) initializes a new instance of the xPCException class. errID is a
32–bit integer that contains the error ID numbers as defined in the
matlabroot\toolbox\rtw\targets\xpc\api\xpcapiconst.h file.
message is an error message string. tgt is the xPCTargetPC object
that raised the error.
6-212
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCExceptionReason Enumerated Data Type
Purpose
Exception reasons
Syntax
public enum xPCExceptionReason
Description
Enumerated Data Type
Syntax Language: C#
public enum xPCExceptionReason specifies the reasons for an
exception. See “C API Error Messages” for definitions.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-213
xPCFileInfo
Purpose
Construct new instance of xPCFileInfo class
Syntax
public xPCFileInfo(xPCTargetPC tgt, string fileName)
Description
Class: xPCFileInfo Class
Constructor
Syntax Language: C#
public xPCFileInfo(xPCTargetPC tgt, string fileName)
initializes a new instance of the xPCFileInfo class. tgt is an
xPCTargetPC object that represents the target computer for which you
want to return the file information. fileName is a string that represents
the name of the file. It is a fully qualified name of the new file, or the
relative file name in the target computer file system.
Exception
6-214
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileMode Enumerated Data Type
Purpose
Open file with permissions
Syntax
public enum xPCFileMode
Description
Enumerated Data Type
Syntax Language: C#
public enum xPCFileMode specifies how the target computer is to open
a file with permissions.
Members
Member
Description
CreateWrite
Open file for writing and discard existing contents.
CreateReadWrite
Open or create file for reading and writing and discard existing
contents
OpenRead
Open file for reading
OpenReadWrite
Open (but do not create) file for reading and writing
AppendWrite
Open or create file for writing and append data to end of file
AppendReadWrite
Open or create file for reading and writing and append data to
end of file
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-215
xPCFileStream
Purpose
Construct new instance of xPCFileStream class
Syntax
public xPCFileStream(xPCTargetPC tgt, string path,
xPCFileMode fmode)
Description
Class: xPCFileStream Class
Method
Syntax Language: C#
public xPCFileStream(xPCTargetPC tgt, string path,
xPCFileMode fmode) initializes a new instance of the xPCFileStream
class with the path name and creation mode. tgt is a reference to an
xPCTargetPC object. path is a relative or absolute path name for the
file that the current xPCFileStream object encapsulates. fmode is an
xPCFileMode constant that determines how to open or create the file.
See xPCFileMode Enumerated Data Type for file mode options.
Exception
6-216
Exception
Condition
xPCException
When problem occurs, query xPCException
object Reason property.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystemInfo
Purpose
Construct new instance of xPCFileSystemInfo class
Syntax
public xPCFileSystemInfo(xPCTargetPC tgt)
Description
Class: xPCFileSystemInfo Class
Constructor
Syntax Language: C#
public xPCFileSystemInfo(xPCTargetPC tgt) initializes a new
instance of the xPCFileSystemInfo class. tgt is an xPCTargetPC object
that represents the target computer for which you want the file system
information.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-217
xPCLogMode Enumerated Data Type
Purpose
Specify log mode values
Syntax
public enum xPCLogMode
Description
Enumerated Data Type
Syntax Language: C#
public enum xPCLogMode specifies log mode values.
Members
6-218
Member
Description
Normal
Time-equidistant logging to log data point at every time interval.
Value
Log data point only when output signal from OutputLog
increments by a specified value
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCLogType Enumerated Data Type
Purpose
Logging type values
Syntax
public enum xPCLogType
Description
Enumerated Data Type
Syntax Language: C#
public enum xPCLogType specifies logging type values.
Members
Member
Description
OUTPUTLOG
Output log
STATELOG
State log
TIMELOG
Time log
TETLOG
TET log
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-219
xPCProtocol Enumerated Data Type
Purpose
Host computer and target computer communication medium
Syntax
public enum XPCProtocol
Description
Enumerated Data Type
Syntax Language: C#
public enum XPCProtocol specifies host computer and target
computer communication medium.
Members
6-220
Member
Description
RS232
Serial communication
TCPIP
TCP/IP communication
Note RS-232 Host-Target communication mode will be removed
in a future release. Use TCP/IP instead.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCRS232BaudRate Enumerated Data Type
Purpose
Serial communication baud rate
Syntax
public enum XPCRS232BaudRate
Description
Enumerated Data Type
Syntax Language: C#
public enum XPCRS232BaudRate specifies serial communication baud
rate
Members
Member
Description
BAUD1200
1200 baud rate
BAUD2400
2400 baud rate
BAUD4800
4800 baud rate
BAUD9600
9600 baud rate
BAUD19200
19200 baud rate
BAUD38400
38400 baud rate
BAUD57600
57600 baud rate
BAUD115200
115200 baud rate
Note RS-232 Host-Target communication mode will be removed in a
future release. Use TCP/IP instead.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-221
xPCRS232Comport Enumerated Data Type
Purpose
Serial communication port
Syntax
public enum XPCRS232CommPort
Description
Enumerated Data Type
Syntax Language: C#
public enum XPCRS232CommPort specifies values of the supported
serial communication ports used for the connection on the host
computer.
Members
Member
Description
COM1
Serial port COM 0
COM2
Serial port COM 1
Note RS-232 Host-Target communication mode will be removed in a
future release. Use TCP/IP instead.
6-222
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTargetPC
Purpose
Construct new instance of xPCTargetPC class
Syntax
public xPCTargetPC()
Description
Class: xPCTargetPC Class
Constructor
Syntax Language: C#
public xPCTargetPC() initializes a new instance of the xPCTargetPC
class.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
6-223
‫‪xPCTargetPC‬‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫‪6-224‬‬
7
xPC Target API Reference
for C
• “C API Functions” on page 7-2
• “C API Error Messages” on page 7-10
• “C API Structures and Functions — Alphabetical List” on page 7-14
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7
xPC Target™ API Reference for C
C API Functions
In this section...
“Target Computers” on page 7-2
“Target Applications” on page 7-3
“Scopes” on page 7-4
“Parameters” on page 7-6
“Signals” on page 7-7
“Data Logs” on page 7-7
“File Systems” on page 7-8
“Errors” on page 7-9
Target Computers
7-2
xPCCloseConnection
Close RS-232 or TCP/IP
communication connection
xPCClosePort
Close RS-232 or TCP/IP
communication connection
xPCDeRegisterTarget
Delete target communication
properties from xPC Target API
library
xPCFreeAPI
Unload xPC Target DLL
xPCGetEcho
Return display mode for target
message window
xPCGetLoadTimeOut
Return timeout value for
communication between host
computer and target computer
xPCInitAPI
Initialize xPC Target DLL
xPCIsAppRunning
Return target application running
status
xPCOpenConnection
Open connection to target computer
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
C API Functions
xPCOpenSerialPort
Open RS-232 connection to xPC
Target system
xPCOpenTcpIpPort
Open TCP/IP connection to xPC
Target system
xPCReboot
Reboot target computer
xPCRegisterTarget
Register target with xPC Target API
library
xPCReOpenPort
Reopen communication channel
xPCSetEcho
Turn message display on or off
xPCSetLoadTimeOut
Change initialization timeout value
between host computer and target
computer
xPCTargetPing
Ping target computer
xPCUnloadApp
Unload target application
Target Applications
xPCAverageTET
Return average task execution time
xPCGetAPIVersion
Get version number of xPC Target
API
xPCGetAppName
Return target application name
xPCGetExecTime
Return target application execution
time
xPCGetSampleTime
Return target application sample
time
xPCGetSessionTime
Return length of time xPC Target
kernel has been running
xPCGetStopTime
Return stop time
xPCGetTargetVersion
Get xPC Target kernel version
xPCIsOverloaded
Return target computer overload
status
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-3
7
xPC Target™ API Reference for C
xPCLoadParamSet
Restore parameter values
xPCMaximumTET
Copy maximum task execution time
to array
xPCMinimumTET
Copy minimum task execution time
to array
xPCSaveParamSet
Save parameter values of target
application
xPCSetSampleTime
Change target application sample
time
xPCSetStopTime
Change target application stop time
xPCStartApp
Start target application
xPCStopApp
Stop target application
Scopes
7-4
scopedata
Type definition for scope data
structure
xPCAddScope
Create new scope
xPCGetNumScopes
Return number of scopes added to
target application
xPCGetNumScSignals
Returns number of signals added to
specific scope
xPCGetScope
Get and copy scope data to structure
xPCGetScopeList
Get and copy list of scope numbers
xPCGetScopes
Get and copy list of scope numbers
xPCIsScFinished
Return data acquisition status for
scope
xPCRemScope
Remove scope
xPCScAddSignal
Add signal to scope
xPCScGetAutoRestart
Scope autorestart status
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
C API Functions
xPCScGetData
Copy scope data to array
xPCScGetDecimation
Return decimation of scope
xPCScGetNumPrePostSamples
Get number of pre- or post-triggering
samples before triggering scope
xPCScGetNumSamples
Get number of samples in one data
acquisition cycle
xPCScGetNumSignals
Get number of signals in scope
xPCScGetSignalList
Copy list of signals to array
xPCScGetSignals
Copy list of signals to array
xPCScGetStartTime
Get start time for last data
acquisition cycle
xPCScGetState
Get state of scope
xPCScGetTriggerLevel
Get trigger level for scope
xPCScGetTriggerMode
Get trigger mode for scope
xPCScGetTriggerScope
Get trigger scope
xPCScGetTriggerScopeSample
Get sample number for triggering
scope
xPCScGetTriggerSignal
Get trigger signal for scope
xPCScGetTriggerSlope
Get trigger slope for scope
xPCScGetType
Get type of scope
xPCScRemSignal
Remove signal from scope
xPCScSetAutoRestart
Scope autorestart status
xPCScSetDecimation
Set decimation of scope
xPCScSetNumPrePostSamples
Set number of pre- or posttriggering
samples before triggering scope
xPCScSetNumSamples
Set number of samples in one data
acquisition cycle
xPCScSetTriggerLevel
Set trigger level for scope
xPCScSetTriggerMode
Set trigger mode of scope
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-5
7
xPC Target™ API Reference for C
xPCScSetTriggerScope
Select scope to trigger another scope
xPCScSetTriggerScopeSample
Set sample number for triggering
scope
xPCScSetTriggerSignal
Select signal to trigger scope
xPCScSetTriggerSlope
Set slope of signal that triggers scope
xPCScSoftwareTrigger
Set software trigger of scope
xPCScStart
Start data acquisition for scope
xPCScStop
Stop data acquisition for scope
xPCSetScope
Set properties of scope
xPCTgScGetGrid
Get status of grid line for particular
scope
xPCTgScGetMode
Get scope mode for displaying
signals
xPCTgScGetViewMode
Get view mode for target computer
display
xPCTgScGetYLimits
Copy y-axis limits for scope to array
xPCTgScSetGrid
Set grid mode for scope
xPCTgScSetMode
Set display mode for scope
xPCTgScSetViewMode
Set view mode for scope
xPCTgScSetYLimits
Set y-axis limits for scope
Parameters
7-6
xPCGetNumParams
Return number of tunable
parameters
xPCGetParam
Get parameter value and copy it to
array
xPCGetParamDims
Get row and column dimensions of
parameter
xPCGetParamIdx
Return parameter index
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
C API Functions
xPCGetParamName
Get name of parameter
xPCSetParam
Change value of parameter
Signals
xPCGetNumSignals
Return number of signals
xPCGetSigIdxfromLabel
Return array of signal indices
xPCGetSigLabelWidth
Return number of elements in signal
xPCGetSignal
Return value of signal
xPCGetSignalIdx
Return index for signal
xPCGetSignalLabel
Copy label of signal to character
array
xPCGetSignalName
Copy name of signal to character
array
xPCGetSignals
Return vector of signal values
xPCGetSignalWidth
Return width of signal
Data Logs
lgmode
Type definition for logging options
structure
xPCGetLogMode
Return logging mode and increment
value for target application
xPCGetNumOutputs
Return number of outputs
xPCGetNumStates
Return number of states
xPCGetOutputLog
Copy output log data to array
xPCGetStateLog
Copy state log values to array
xPCGetTETLog
Copy TET log to array
xPCGetTimeLog
Copy time log to array
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-7
7
xPC Target™ API Reference for C
xPCMaxLogSamples
Return maximum number of samples
that can be in log buffer
xPCNumLogSamples
Return number of samples in log
buffer
xPCNumLogWraps
Return number of times log buffer
wraps
xPCSetLogMode
Set logging mode and increment
value of scope
File Systems
7-8
dirStruct
Type definition for file system folder
information structure
diskinfo
Type definition for file system disk
information structure
fileinfo
Type definition for file information
structure
xPCFSCD
Change current folder on target
computer to specified path
xPCFSCloseFile
Close file on target computer
xPCFSDir
Get contents of specified folder on
target computer
xPCFSDirItems
Get contents of specified folder on
target computer
xPCFSDirSize
Return size of specified folder listing
on target computer
xPCFSDirStructSize
Get number of items in folder
xPCFSDiskInfo
Information about target computer
file system
xPCFSFileInfo
Return information for open file on
target computer
xPCFSGetFileSize
Return size of file on target computer
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
C API Functions
xPCFSGetPWD
Get current folder of target computer
xPCFSMKDIR
Create new folder on target computer
xPCFSOpenFile
Open file on target computer
xPCFSReadFile
Read open file on target computer
xPCFSRemoveFile
Remove file from target computer
xPCFSRMDIR
Remove folder from target computer
xPCFSScGetFilename
Get name of file for scope
xPCFSScGetWriteMode
Get write mode of file for scope
xPCFSScGetWriteSize
Get block write size of data chunks
xPCFSScSetFilename
Specify name for file to contain
signal data
xPCFSScSetWriteMode
Specify when file allocation table
entry is updated
xPCFSScSetWriteSize
Specify that memory buffer collect
data in multiples of write size
xPCFSWriteFile
Write to file on target computer
Errors
xPCErrorMsg
Return text description for error
message
xPCFSGetError
Get text description for error number
on target computer file system
xPCGetLastError
Return constant of last error
xPCSetLastError
Set last error to specific string
constant
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-9
7
xPC Target™ API Reference for C
C API Error Messages
The header file matlabroot\toolbox\rtw\targets\xpc\api\xpcapiconst.h
defines these error messages.
Message
Description
ECOMPORTACCFAIL
COM port access failed
ECOMPORTISOPEN
COM port is already opened
ECOMPORTREAD
ReadFile failed while reading from COM port
ECOMPORTWRITE
WriteFile failed while writing to COM port
ECOMTIMEOUT
timeout while receiving:
EFILEOPEN
Error opening file
EFILEREAD
Error reading file
EFILERENAME
Error renaming file
EFILEWRITE
Error writing file
EINTERNAL
Internal Error
EINVADDR
Invalid IP Address
EINVARGUMENT
Invalid Argument
EINVALIDMODEL
Model name does not match saved value
EINVBAUDRATE
Invalid value for baudrate
EINVCOMMTYP
Invalid communication type
EINVCOMPORT
COM port can only be 0 or 1 (COM1 or COM2)
EINVDECIMATION
Decimation must be positive
EINVFILENAME
Invalid file name
EINVINSTANDALONE
7-10
check serial link
Command not valid for StandAlone
EINVLGDATA
Invalid lgdata structure
EINVLGINCR
Invalid increment for value equidistant
logging
EINVLGMODE
Invalid Logging mode
EINVLOGID
Invalid log identifier
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
C API Error Messages
Message
Description
EINVNUMPARAMS
Invalid number of parameters
EINVNUMSIGNALS
Invalid number of signals
EINVPARIDX
Invalid parameter index
EINVPORT
Invalid Port Number
EINVSCIDX
Invalid Scope Index
EINVSCTYPE
Invalid Scope type
EINVSIGIDX
Invalid Signal index
EINVTRIGMODE
Invalid trigger mode
EINVTRIGSLOPE
Invalid Trigger Slope Value
EINVTRSCIDX
Invalid Trigger Scope index
EINVNUMSAMP
Number of samples must be nonnegative
EINVSTARTVAL
Invalid value for "start"
EINVTFIN
Invalid value for TFinal
EINVTS
Invalid value for Ts (must be between 8e-6
and 10)
EINVWSVER
Invalid Winsock version (1.1 needed)
EINVXPCVERSION
Target has an invalid version of xPC Target
ELOADAPPFIRST
Load the application first
ELOGGINGDISABLED Logging is disabled
EMALFORMED
Malformed message
EMEMALLOC
Memory allocation error
ENODATALOGGED
No data has been logged
ENOERR
No error
ENOFREEPORT
No free Port in C API
ENOMORECHANNELS
No more channels in scope
ENOSPACE
Space not allocated
EOUTPUTLOGDISABLEDOutput Logging is disabled
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-11
7
xPC Target™ API Reference for C
Message
Description
EPARNOTFOUND
Parameter not found
EPARSIZMISMATCH
Parameter Size mismatch
EPINGCONNECT
Could not connect to Ping socket
EPINGPORTOPEN
Error opening Ping port
EPINGSOCKET
Ping socket error
EPORTCLOSED
Port is not open
ERUNSIMFIRST
Run simulation first
ESCFINVALIDFNAME Invalid filename tag used for dynamic file
name
ESCFISNOTAUTO
Autorestart must be enabled for dynamic file
names
ESCFNUMISNOTMULT MaxWriteFileSize must be a multiple of the
writesize
ESCTYPENOTTGT
Scope Type is not "Target"
ESIGLABELNOTFOUND Signal label not found
ESIGLABELNOTUNIQUEAmbiguous signal label (signal labels are not
unique)
ESIGNOTFOUND
Signal not found
ESOCKOPEN
Socket Open Error
ESTARTSIMFIRST
Start simulation first
ESTATELOGDISABLED State Logging is disabled
7-12
ESTOPSCFIRST
Stop scope first
ESTOPSIMFIRST
Stop simulation first
ETCPCONNECT
TCP/IP Connect Error
ETCPREAD
TCP/IP Read Error
ETCPTIMEOUT
TCP/IP timeout while receiving data
ETCPWRITE
TCP/IP Write error
ETETLOGDISABLED
TET Logging is disabled
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
C API Error Messages
Message
Description
ETGTMEMALLOC
Target memory allocation failed
ETIMELOGDISABLED Time Logging is disabled
ETOOMANYSAMPLES
Too Many Samples requested
ETOOMANYSCOPES
Too many scopes are present
ETOOMANYSIGNALS
Too many signals in Scope
EUNLOADAPPFIRST
Unload the application first
EUSEDYNSCOPE
Use DYNAMIC_SCOPE flag at compile time
EWRITEFILE
LoadDLM: WriteFile Error
EWSINIT
WINSOCK: Initialization Error
EWSNOTREADY
Winsock not ready
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-13
7
xPC Target™ API Reference for C
C API Structures and Functions — Alphabetical List
7-14
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
dirStruct
Purpose
Type definition for file system folder information structure
Syntax
typedef struct {
char
Name[8];
char
Ext[3];
char
Day;
int Month;
int Year;
int Hour;
int Min;
int isDir;
unsigned long Size;
} dirStruct;
Fields
Name
This value contains the name of the file or
folder.
Ext
This value contains the file type of the
element, if the element is a file (isDir is 0).
If the element is a folder (isDir is 1), this
field is empty.
Day
This value contains the day the file or folder
was last modified.
Month
This value contains the month the file or
folder was last modified.
Year
This value contains the year the file or folder
was last modified.
Hour
This value contains the hour the file or folder
was last modified.
Min
This value contains the minute the file or
folder was last modified.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-15
dirStruct
7-16
isDir
This value indicates if the element is a file
(0) or folder (1). If it is a folder, Bytes has a
value of 0.
Size
This value contains the size of the file in
bytes. If the element is a folder, this value
is 0.
Description
The dirStruct structure contains information for a folder in the file
system.
See Also
API function xPCFSDirItems
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
diskinfo
Purpose
Type definition for file system disk information structure
Syntax
typedef struct {
char
char
char
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
unsigned int
} diskinfo;
Fields
Label[12];
DriveLetter;
Reserved[3];
SerialNumber;
FirstPhysicalSector;
FATType;
FATCount;
MaxDirEntries;
BytesPerSector;
SectorsPerCluster;
TotalClusters;
BadClusters;
FreeClusters;
Files;
FileChains;
FreeChains;
LargestFreeChain;
Label
This value contains the zero-terminated
string that contains the volume label. The
string is empty if the volume has no label.
DriveLetter
This value contains the drive letter, in
uppercase.
Reserved
Reserved.
SerialNumber
This value contains the volume serial
number.
FirstPhysicalSector This value contains the logical block
addressing (LBA) address of the logical drive
boot record. For 3.5-inch disks, this value is 0.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-17
diskinfo
7-18
FATType
This value contains the type of file system
found. It can contain 12 , 16 , or 32 for
FAT-12, FAT-16, or FAT-32 volumes,
respectively.
FATCount
This value contains the number of FAT
partitions on the volume.
MaxDirEntries
This value contains the size of the root folder.
For FAT-32 systems, this value is 0.
BytesPerSector
This value contains the sector size. This
value is most likely to be 512.
SectorsPerCluster
This value contains, in sectors, the size of the
smallest unit of storage that can be allocated
to a file.
TotalClusters
This value contains the number of file storage
clusters on the volume.
BadClusters
This value contains the number of clusters
that have been marked as bad. These clusters
are unavailable for file storage.
FreeClusters
This value contains the number of clusters
that are currently available for storage.
Files
This value contains the number of files,
including folders, on the volume. This
number excludes the root folder and files that
have an allocated file size of 0.
FileChains
This value contains the number of contiguous
cluster chains. On a completely unfragmented
volume, this value is identical to the value
of Files.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
diskinfo
FreeChains
This value contains the number of contiguous
cluster chains of free clusters. On a
completely unfragmented volume, this value
is 1.
LargestFreeChain
This value contains the maximum allocated
file size, in number of clusters, for a newly
allocated contiguous file. On a completely
unfragmented volume, this value is identical
to FreeClusters.
Description
The diskinfo structure contains information for file system disks.
See Also
API function xPCFSDiskInfo
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-19
fileinfo
Purpose
Type definition for file information structure
Syntax
typedef struct
int
int
int
int
char
}fileinfo;
Fields
7-20
{
FilePos;
AllocatedSize;
ClusterChains;
VolumeSerialNumber;
FullName[255];
FilePos
This value contains the current file pointer.
AllocatedSize
This value contains the currently allocated
file size.
ClusterChains
This value indicates how many separate
cluster chains are allocated for the file.
VolumeSerialNumber
This value holds the serial number of the
volume the file resides on.
FullName
This value contains a copy of the complete
path name of the file. This field is valid only
while the file is open.
Description
The fileinfo structure contains information for files in the file system.
See Also
xPCFSFileInfo
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
lgmode
Purpose
Type definition for logging options structure
Syntax
typedef struct {
int
mode;
double incrementvalue;
} lgmode;
Fields
mode
This value indicates the type of logging you want.
Specify LGMOD_TIME for time-equidistant logging.
Specify LGMOD_VALUE for value-equidistant
logging.
incrementvalue
If you set mode to LGMOD_VALUE for
value-equidistant data, this option specifies
the increment (difference in amplitude) value
between logged data points. A data point is
logged only when an output signal or a state
changes by incrementvalue.
If you set mode to LGMOD_TIME, incrementvalue
is ignored.
Description
The lgmode structure specifies data logging options. The mode variable
accepts either the numeric values 0 or 1 or their equivalent constants
LGMOD_TIME or LGMOD_VALUE from xpcapiconst.h.
See Also
API functions xPCSetLogMode, xPCGetLogMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-21
scopedata
Purpose
Type definition for scope data structure
Syntax
typedef struct {
int
number;
int
type;
int
state;
int
signals[10];
int
numsamples;
int
decimation;
int
triggermode;
int
numprepostsamples;
int
triggersignal
int
triggerscope;
int
triggerscopesample;
double triggerlevel;
int
triggerslope;
} scopedata;
Fields
number
The scope number.
type
Determines whether the scope is displayed
on the host computer or on the target
computer. Values are one of the following:
state
7-22
1
Host
2
Target
Indicates the scope state. Values are one of
the following:
0
Waiting to start
1
Scope is waiting for a trigger
2
Data is being acquired
3
Acquisition is finished
4
Scope is stopped (interrupted)
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
scopedata
5
Scope is preacquiring data
signals
List of signal indices from the target object
to display on the scope.
numsamples
Number of contiguous samples captured
during the acquisition of a data package.
decimation
A number, N, meaning every Nth sample is
acquired in a scope window.
triggermode
Trigger mode for a scope. Values are one of
the following:
0
FreeRun (default)
1
Software
2
Signal
3
Scope
numprepostsamples
If this value is less than 0, this is the number
of samples to be saved before a trigger event.
If this value is greater than 0, this is the
number of samples to skip after the trigger
event before data acquisition begins.
triggersignal
If triggermode is 2 (Signal), identifies the
block output signal to use for triggering
the scope. Identify the signal with a signal
index.
triggerscope
If triggermode is 3 (Scope), identifies the
scope to use for a trigger. A scope can be set
to trigger when another scope is triggered.
triggerscopesample
If triggermode is 3 (Scope), specifies the
number of samples to be acquired by the
triggering scope before triggering a second
scope. This must be a nonnegative value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-23
scopedata
triggerlevel
If triggermode is 2 (Signal), indicates the
value the signal has to cross to trigger the
scope to start acquiring data. The trigger
level can be crossed with either a rising or
falling signal.
triggerslope
If triggermode is 2 (Signal), indicates
whether the trigger is on a rising or falling
signal. Values are:
0
Either rising or falling (default)
1
Rising
2
Falling
Description
The scopedata structure holds the data about a scope used in the
functions xPCGetScope and xPCSetScope. In the structure, the fields
are as in the various xPCGetSc* functions (for example, state is as in
xPCScGetState, signals is as in xPCScGetSignals, etc.). The signal
vector is an array of the signal identifiers, terminated by -1.
See Also
API functions xPCSetScope, xPCGetScope, xPCScGetType,
xPCScGetState, xPCScGetSignals, xPCScGetNumSamples,
xPCScGetDecimation, xPCScGetTriggerMode,
xPCScGetNumPrePostSamples, xPCScGetTriggerSignal,
xPCScGetTriggerScope, xPCScGetTriggerLevel,
xPCScGetTriggerSlope
7-24
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCAddScope
Purpose
Create new scope
Prototype
void xPCAddScope(int port, int scType, int scNum);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scType
Enter the type of scope.
scNum
Enter a number for a new scope. Values are 1, 2, 3. . .
The xPCAddScope function creates a new scope on the target computer.
For scType, scopes can be of type host or target, depending on the
value of scType:
• SCTYPE_HOST for type host
• SCTYPE_TARGET for type target
• SCTYPE_FILE for type file
Constants for scType are defined in the header file xpcapiconst.h as
SCTYPE_HOST, SCTYPE_TARGET, and SCTYPE_FILE.
Calling the xPCAddScope function with scNum having the number of
an existing scope produces an error. Use xPCGetScopes to find the
numbers of existing scopes.
See Also
API functions xPCScAddSignal, xPCScRemSignal, xPCRemScope,
xPCSetScope, xPCGetScope, xPCGetScopes
Target object method xpctarget.xpc.addscope
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-25
xPCAverageTET
Purpose
Return average task execution time
Prototype
double xPCAverageTET(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCAverageTET function returns the average task execution time
(TET) for the target application.
Description
The xPCAverageTET function returns the TET for the target application.
You can use this function when the target application is running or
when it is stopped.
See Also
API functions xPCMaximumTET, xPCMinimumTET
xpctarget.xpc Class property AvgTET
7-26
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCCloseConnection
Purpose
Close RS-232 or TCP/IP communication connection
Prototype
void xPCCloseConnection(int port);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
The xPCCloseConnection function closes the RS-232 or
TCP/IP communication channel opened by xPCOpenSerialPort,
xPCOpenTcpIpPort, or xPCOpenConnection. Unlike xPCClosePort,
it preserves the connection information such that a subsequent
call to xPCOpenConnection succeeds without the need to
resupply communication data such as the IP address or port
number. To completely close the communication channel, call
xPCDeRegisterTarget. Calling the xPCCloseConnection function
followed by calling xPCDeRegisterTarget is equivalent to calling
xPCClosePort.
Note RS-232 Host-Target communication mode will be removed in a
future release. Use TCP/IP instead.
See Also
API functions xPCOpenConnection, xPCOpenSerialPort,
xPCOpenTcpIpPort, xPCReOpenPort, xPCRegisterTarget,
xPCDeRegisterTarget
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-27
xPCClosePort
Purpose
Close RS-232 or TCP/IP communication connection
Prototype
void xPCClosePort(int port);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
The xPCClosePort function closes the RS-232 or TCP/IP communication
channel opened by either xPCOpenSerialPort or by xPCOpenTcpIpPort.
Calling this function is equivalent to calling xPCCloseConnection and
xPCDeRegisterTarget.
Note RS-232 Host-Target communication mode will be removed in a
future release. Use TCP/IP instead.
See Also
API functions xPCOpenSerialPort, xPCOpenTcpIpPort, xPCReOpenPort,
xPCOpenConnection, xPCCloseConnection, xPCRegisterTarget,
xPCDeRegisterTarget
Target object method xpctarget.xpc.close
7-28
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCDeRegisterTarget
Purpose
Delete target communication properties from xPC Target API library
Prototype
void xPCDeRegisterTarget(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Description
The xPCDeRegisterTarget function causes the xPC Target API library
to completely “forget” about the target communication properties. You
use this at the end of a session in which you use xPCOpenConnection and
xPCCloseConnection to connect and disconnect from the target without
entering the properties each time. It works similarly to xPCClosePort,
but does not close the connection to the target machine. Before calling
this function, you must first call the function xPCCloseConnection to
close the connection to the target machine. The combination of calling
the xPCCloseConnection and xPCDeRegisterTarget functions has the
same result as calling xPCClosePort.
See Also
API functions xPCRegisterTarget, xPCOpenTcpIpPort,
xPCOpenSerialPort, xPCClosePort, xPCReOpenPort,
xPCOpenConnection, xPCCloseConnection, xPCTargetPing
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-29
xPCErrorMsg
Purpose
Return text description for error message
Prototype
char *xPCErrorMsg(int error_number, char *error_message);
Arguments
error_number
Enter the constant of an error.
error_message The xPCErrorMsg function copies the error message
string into the buffer pointed to by error_message.
error_message is then returned. You can later use
error_message in a function such as printf.
If error_message is NULL, the xPCErrorMsg
function returns a pointer to a statically allocated
string.
7-30
Return
The xPCErrorMsg function returns a string associated with the error
error_number.
Description
The xPCErrorMsg function returns error_message, which makes
it convenient to use in a printf or similar statement. Use the
xPCGetLastError function to get the constant for which you are getting
the message.
See Also
API functions xPCSetLastError, xPCGetLastError
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFreeAPI
Purpose
Unload xPC Target DLL
Prototype
void xPCFreeAPI(void);
Description
The xPCFreeAPI function unloads the xPC Target dynamic link library.
You must execute this function once at the end of the application to
unload the xPC Target API DLL. This frees the memory allocated to the
functions. This function is defined in the file xpcinitfree.c. Link this
file with your application.
See Also
API functions xPCInitAPI, xPCNumLogWraps, xPCNumLogSamples,
xPCMaxLogSamples, xPCGetStateLog, xPCGetTETLog, xPCSetLogMode,
xPCGetLogMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-31
xPCFSCD
Purpose
Change current folder on target computer to specified path
Prototype
void xPCFSCD(int port, char *dir);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
dir
Enter the path on the target computer to change to.
Description
The xPCFSCD function changes the current folder on the target computer
to the path specified in dir. Use the xPCFSGetPWD function to show the
current folder of the target computer.
See Also
API function xPCFSGetPWD
File object method xpctarget.fsbase.cd
7-32
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSCloseFile
Purpose
Close file on target computer
Prototype
void xPCFSCloseFile(int port, int fileHandle);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
fileHandle
Enter the file handle of an open file on the target
computer.
Description
The xPCFSCloseFile function closes the file associated with fileHandle
on the target computer. fileHandle is the handle of a file previously
opened by the xPCFSOpenFile function.
See Also
API functions xPCFSOpenFile, xPCFSReadFile, xPCFSWriteFile
File object method xpctarget.fs.fclose
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-33
xPCFSDir
Purpose
Get contents of specified folder on target computer
Prototype
void xPCFSDir(int port, const char *path, char
*data, int numbytes);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
path
Enter the path on the target computer.
data
The contents of the folder are stored in data, whose
allocated size is specified in numbytes.
numbytes
Enter the size, in bytes, of the array data.
Description
The xPCFSDir function copies the contents of the target computer
folder specified by path into data. The xPCFSDir function returns the
listing in the data array, which must be of size numbytes. Use the
xPCFSDirSize function to obtain the size of the folder listing for the
numbytes parameter.
See Also
API function xPCFSDirSize
File object method xpctarget.fsbase.dir
7-34
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSDirItems
Purpose
Get contents of specified folder on target computer
Prototype
void xPCFSDirItems(int port, const char *path, dirStruct
*dirs, int numDirItems);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
path
Enter the path on the target computer.
dirs
Enter the structure to contain the contents of the folder.
numDirItems Enter the number of items in the folder.
Description
The xPCFSDirItems function copies the contents of the target computer
folder specified by path. The xPCFSDirItems function copies the listing
into the dirs structure, which must be of size numDirItems. Use the
xPCFSDirStructSize function to obtain the size of the folder for the
numDirItems parameter.
See Also
API functions xPCFSDirStructSize, dirStruct
File object method xpctarget.fsbase.dir
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-35
xPCFSDirSize
Purpose
Return size of specified folder listing on target computer
Prototype
int xPCFSDirSize(int port, const char *path);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
path
Enter the folder path on the target computer.
Return
The xPCFSDirSize function returns the size, in bytes, of the specified
folder listing. If this function detects an error, it returns -1.
Description
The xPCFSDirSize function returns the size, in bytes, of the buffer
required to list the folder contents on the target computer. Use this size
as the numbytes parameter in the xPCFSDir function.
See Also
API function xPCFSDirItems
File object method xpctarget.fsbase.dir
7-36
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSDirStructSize
Purpose
Get number of items in folder
Prototype
int xPCFSDirStructSize(int port, const char *path);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
path
Enter the folder path on the target computer.
Return
The xPCFSDirStructSize function returns the number of items in
the folder on the target computer. If this function detects an error, it
returns -1.
Description
The xPCFSDirStructSize function returns the number of items in
the folder on the target computer. Use this size as the numDirItems
parameter in the xPCFSDirItems function.
See Also
API function xPCFSDir
File object method xpctarget.fsbase.dir
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-37
xPCFSDiskInfo
Purpose
Information about target computer file system
Prototype
diskinfo xPCFSDiskInfo(int
Arguments
7-38
port, const char *driveletter);
port
Enter the value returned by either the
function xPCOpenSerialPort or the
function xPCOpenTcpIpPort.
driveletter
Enter the drive letter of the file system
for which you want information.
Description
The xPCFSDiskInfo function returns disk information for the file
system of the specified target computer drive, driveletter. This
function returns this information in the diskinfo structure.
See Also
API structure xpctarget.fs.diskinfo
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSFileInfo
Purpose
Return information for open file on target computer
Prototype
fileinfo xPCFSFileInfo(int port, int fileHandle);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the
function xPCOpenTcpIpPort.
fileHandle
Enter the file handle of an open file on
the target computer.
Description
The xPCFSFileInfo function returns information about the specified
open file, filehandle, in a structure of type fileinfo.
See Also
Structure xpctarget.fs.fileinfo
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-39
xPCFSGetError
Purpose
Get text description for error number on target computer file system
Prototype
void xPCFSGetError(int port, unsigned int error_number,
char *error_message);
Arguments
Description
7-40
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
error_number
Enter the constant of an error.
error_message
The string of the message associated with the
error error_number is stored in error_message.
The xPCFSGetError function gets the error_message associated with
error_number. This enables you to use the error message in a printf
or similar statement.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSGetFileSize
Purpose
Return size of file on target computer
Prototype
int xPCFSGetFileSize(int port, int fileHandle);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
fileHandle
Enter the file handle of an open file on the target
computer.
Return
Return the size of the specified file in bytes. If this function detects an
error, it returns -1.
Description
The xPCFSGetFileSize function returns the size, in bytes, of the file
associated with fileHandle on the target computer. fileHandle is the
handle of a file previously opened by the xPCFSOpenFile function.
See Also
API functions xPCFSOpenFile, xPCFSReadFile
File object methods xpctarget.fs.fopen, xpctarget.fs.fread
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-41
xPCFSGetPWD
Purpose
Get current folder of target computer
Prototype
void xPCFSGetPWD(int port, char *pwd);
Arguments
7-42
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
pwd
The path of the current folder is stored in pwd.
Description
The xPCFSGetPWD function places the path of the current folder on the
target computer in pwd, which must be allocated by the caller.
See Also
File object method xpctarget.fsbase.pwd
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSMKDIR
Purpose
Create new folder on target computer
Prototype
void xPCFSMKDIR(int port, const char *dirname);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
dirname
Enter the name of the folder to create on the target
computer.
Description
The xPCFSMKDIR function creates the folder dirname in the current
folder of the target computer.
See Also
API function xPCFSGetPWD
File object method xpctarget.fsbase.mkdir
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-43
xPCFSOpenFile
Purpose
Open file on target computer
Prototype
int xPCFSOpenFile(int port, const char *filename,
const char *permission);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
filename
Enter the name of the file to open on the target
computer.
permission
Enter the read/write permission with which to
open the file. Values are r (read) or w (read/write).
Return
The xPCFSOpenFile function returns the file handle for the opened file.
If function detects an error, it returns -1.
Description
The xPCFSOpenFile function opens the specified file, filename, on
the target computer. If the file does not exist, the xPCFSOpenFile
function creates filename, then opens it. You can open a file for read
or read/write access.
See Also
API functions xPCFSCloseFile, xPCFSGetFileSize, xPCFSReadFile,
xPCFSWriteFile
File object methods xpctarget.fs.fclose, xpctarget.fs.filetable,
xpctarget.fs.fopen, xpctarget.fs.fread, xpctarget.fs.fwrite
7-44
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSReadFile
Purpose
Read open file on target computer
Prototype
void xPCFSReadFile(int port, int fileHandle, int start,
int numbytes, unsigned char *data);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
fileHandle
Enter the file handle of an open file on the target
computer.
start
Enter an offset from the beginning of the file from
which this function can start to read.
numbytes
Enter the number of bytes this function is to read
from the file.
data
The contents of the file are stored in data.
Description
The xPCFSReadFile function reads an open file on the target
computer and places the results of the read operation in the array
data. fileHandle is the file handle of a file previously opened by
xPCFSOpenFile. You can specify that the read operation begin at the
beginning of the file (default) or at a certain offset into the file (start).
The numbytes parameter specifies how many bytes the xPCFSReadFile
function is to read from the file.
See Also
API functions xPCFSCloseFile, xPCFSGetFileSize, xPCFSOpenFile,
xPCFSWriteFile
File object methods xpctarget.fs.fopen, xpctarget.fs.fread
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-45
xPCFSRemoveFile
Purpose
Remove file from target computer
Prototype
void xPCFSRemoveFile(int port, const char *filename);
Arguments
7-46
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
filename
Enter the name of a file on the target computer.
Description
The xPCFSRemoveFile function removes the file named filename from
the target computer file system. filename can be a relative or absolute
path name on the target computer.
See Also
File object method xpctarget.fs.removefile
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSRMDIR
Purpose
Remove folder from target computer
Prototype
void xPCFSRMDIR(int port, const char *dirname);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
dirname
Enter the name of a folder on the target computer.
Description
The xPCFSRMDIR function removes a folder named dirname from the
target computer file system. dirname can be a relative or absolute
path-name on the target computer.
See Also
File object method xpctarget.fsbase.rmdir
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-47
xPCFSScGetFilename
Purpose
Get name of file for scope
Prototype
const char *xPCFSScGetFilename(int port, int
scNum, char *filename);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
filename
The name of the file for the specified scope is stored
in filename.
Return
Returns the value of filename, the name of the file for the scope.
Description
The xPCFSScGetFilename function returns the name of the file to which
scope scNum will save signal data. filename points to a caller-allocated
character array to which the filename is copied.
See Also
API function xPCFSScSetFilename
xpctarget.xpcfs Class property Filename
7-48
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSScGetWriteMode
Purpose
Get write mode of file for scope
Prototype
int xPCFSScGetWriteMode(int port, int scNum);
Arguments
Return
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Returns the number indicating the write mode. Values are
0
Lazy mode. The FAT entry is updated only when the file is
closed and not during each file write operation. This mode
is faster, but if the system crashes before the file is closed,
the file system might not have the actual file size (the file
contents, however, will be intact).
1
Commit mode. Each file write operation simultaneously
updates the FAT entry for the file. This mode is slower, but
the file system maintains the actual file size.
Description
The xPCFSScGetWriteMode function returns the write mode of the file
for the scope.
See Also
API function xPCFSScSetWriteMode
xpctarget.xpcfs Class property WriteMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-49
xPCFSScGetWriteSize
Purpose
Get block write size of data chunks
Prototype
unsigned int xPCFSScGetWriteSize(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
Returns the block size, in bytes, of the data chunks.
Description
The xPCFSScGetWriteSize function gets the block size, in bytes, of
the data chunks.
See Also
API function xPCFSScSetWriteSize
xpctarget.xpcfs Class property WriteSize
7-50
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSScSetFilename
Purpose
Specify name for file to contain signal data
Prototype
void xPCFSScSetFilename(int port, int scNum,
const char *filename);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
filename
Enter the name of a file to contain the signal data.
Description
The xPCFSScSetFilename function sets the name of the file to which
the scope will save the signal data. The xPC Target software creates
this file in the target computer file system. Note that you can only call
this function when the scope is stopped.
See Also
API function xPCFSScGetFilename
xpctarget.xpcfs Class property Filename
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-51
xPCFSScSetWriteMode
Purpose
Specify when file allocation table entry is updated
Prototype
void xPCFSScSetWriteMode(int port, int scNum, int writeMode);
Arguments
Description
See Also
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
writeMode
Enter an integer for the write mode:
0
Enables lazy write mode
1
Enables commit write mode
The xPCFSScSetWriteMode function specifies when a file allocation
table (FAT) entry is updated. Both modes write the signal data to the
file, as follows:
0
Lazy mode. The FAT entry is updated only when the file is
closed and not during each file write operation. This mode
is faster, but if the system crashes before the file is closed,
the file system might not have the actual file size (the file
contents, however, will be intact).
1
Commit mode. Each file write operation simultaneously
updates the FAT entry for the file. This mode is slower,
but the file system maintains the actual file size.
API function xPCFSScGetWriteMode
xpctarget.xpcfs Class property WriteMode
7-52
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFSScSetWriteSize
Purpose
Prototype
Specify that memory buffer collect data in multiples of write size
void xPCFSScSetWriteSize(int port, int scNum, unsigned int
writeSize);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
writeSize
Enter the block size, in bytes, of the data chunks.
Description
The xPCFSScSetWriteSize function specifies that a memory buffer
collect data in multiples of writeSize. By default, this parameter is 512
bytes, which is the typical disk sector size. Using a block size that is the
same as the disk sector size provides better performance. writeSize
must be a multiple of 512.
See Also
API function xPCFSScGetWriteSize
xpctarget.xpcfs Class property WriteSize
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-53
xPCFSWriteFile
Purpose
Write to file on target computer
Prototype
void xPCFSWriteFile(int port, int fileHandle, int numbytes,
const unsigned char *data);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
fileHandle
Enter the file handle of an open file on the target
computer.
numbytes
Enter the number of bytes this function is to write
into the file.
data
The contents to write to fileHandle are stored in
data.
Description
The xPCFSWriteFile function writes the contents of the array data
to the file specified by fileHandle on the target computer. The
fileHandle parameter is the handle of a file previously opened by
xPCFSOpenFile. numbytes is the number of bytes to write to the file.
See Also
API functions xPCFSCloseFile, xPCFSGetFileSize, xPCFSOpenFile,
xPCFSReadFile
7-54
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetAPIVersion
Purpose
Get version number of xPC Target API
Prototype
const char *xPCGetAPIVersion(void);
Return
The xPCGetApiVersion function returns a string with the version
number of the xPC Target kernel on the target computer.
Description
The xPCGetApiVersion function returns a string with the version
number of the xPC Target kernel on the target computer. The string is
a constant string within the API DLL. Do not modify this string.
See Also
API function xPCGetTargetVersion
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-55
xPCGetAppName
Purpose
Return target application name
Prototype
char *xPCGetAppName(int port, char *model_name);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
model_name
The xPCGetAppName function copies the target
application name string into the buffer pointed to by
model_name. model_name is then returned. You can
later use model_name in a function such as printf.
Note that the maximum size of the buffer is 256
bytes. To reserve enough space for the application
name string, allocate a buffer of size 256 bytes.
Return
The xPCGetAppName function returns a string with the name of the
target application.
Description
The xPCGetAppName function returns the name of the target application.
You can use the return value, model_name, in a printf or similar
statement. In case of error, the name string is unchanged.
Examples
Allocate 256 bytes for the buffer appname.
char *appname=malloc(256);
xPCGetAppName(iport,appname);
appname=realloc(appname,strlen(appname)+1);
...
free(appname);
See Also
API function xPCIsAppRunning
Target object property Application
7-56
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetEcho
Purpose
Return display mode for target message window
Prototype
int xPCGetEcho(int port);
Arguments
Return
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
The xPCGetEcho function returns the number indicating the display
mode. Values are
1
Display is on. Messages are displayed in the message
display window on the target.
0
Display is off.
Return
The xPCGetEcho function the display mode of the target computer
using communication channel port. If the function detects an error, it
returns -1.
Description
The xPCGetEcho function returns the display mode of the target
computer using communication channel port. Messages include the
status of downloading the target application, changes to parameters,
and changes to scope signals.
See Also
API function xPCSetEcho
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-57
xPCGetExecTime
Purpose
Return target application execution time
Prototype
double xPCGetExecTime(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetExecTime function returns the current execution time for a
target application. If the function detects an error, it returns -1.
Description
The xPCGetExecTime function returns the current execution time for
the running target application. If the target application is stopped, the
value is the last running time when the target application was stopped.
If the target application is running, the value is the current running
time.
See Also
API functions xPCSetStopTime, xPCGetStopTime
xpctarget.xpc Class property ExecTime
7-58
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetLastError
Purpose
Return constant of last error
Prototype
int xPCGetLastError(void);
Return
The xPCGetLastError function returns the error constant for the last
reported error. If the function did not detect an error, it returns 0.
Description
The xPCGetLastError function returns the constant of the last reported
error by another API function. This value is reset every time you
call a new function. Therefore, you should check this constant value
immediately after a call to an API function. For a list of error constants
and messages, see “C API Error Messages”.
See Also
API functions xPCErrorMsg, xPCSetLastError
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-59
xPCGetLoadTimeOut
Purpose
Return timeout value for communication between host computer and
target computer
Prototype
int xPCGetLoadTimeOut(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetLoadTimeOut function returns the number of seconds
allowed for the communication between the host computer and target
application. If the function detects an error, it returns -1.
Description
The xPCGetLoadTimeOut function returns the number of seconds
allowed for the communication between the host computer and the
target application. When an xPC Target API function initiates
communication between the host computer and target computer,
it waits for a certain amount of time before checking to see if the
communication is complete. In the case where communication with the
target computer is not complete, the function returns a timeout error.
For example, when you load a new target application onto the target
computer, the function xPCLoadApp waits for a certain amount of time
before checking to see if the initialization of the target application is
complete. In the case where initialization of the target application is
not complete, the function xPCLoadApp returns a timeout error. By
default, xPCLoadApp checks for the readiness of the target computer
for up to 5 seconds. However, for larger models or models requiring
longer initialization (for example, those with thermocouple boards), the
default might not be long enough and a spurious timeout is generated.
Other functions that communicate with the target computer will wait
for timeOut seconds before declaring a timeout event. The function
xPCSetLoadTimeOut sets the timeout to a different number.
Use the xPCGetLoadTimeOut function if you suspect that the current
number of seconds (the timeout value) is too short. Then use the
xPCSetLoadTimeOut function to set the timeout to a higher number.
7-60
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetLoadTimeOut
See Also
API functions xPCLoadApp, xPCSetLoadTimeOut
xPCUnloadApp
“Increase the Time for Downloads”
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-61
xPCGetLogMode
Purpose
Return logging mode and increment value for target application
Prototype
lgmode xPCGetLogMode(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetLogMode function returns the logging mode in the lgmode
structure. If the logging mode is 1 (LGMOD_VALUE), this function also
returns an increment value in the lgmode structure. If an error occurs,
this function returns -1.
Description
The xPCGetLogMode function gets the logging mode and increment
value for the current target application. The increment (difference
in amplitude) value is measured between logged data points. A data
point is logged only when an output signal or a state changes by the
increment value.
See Also
API function xPCSetLogMode
API structure lgmode
7-62
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetNumOutputs
Purpose
Return number of outputs
Prototype
int xPCGetNumOutputs(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetNumOutputs function returns the number of outputs in the
current target application. If the function detects an error, it returns -1.
Description
The xPCGetNumOutputs function returns the number of outputs in the
target application. The number of outputs equals the sum of the input
signal widths of the output blocks at the root level of the Simulink
model.
See Also
API functions xPCGetOutputLog, xPCGetNumStates, xPCGetStateLog
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-63
xPCGetNumParams
Purpose
Return number of tunable parameters
Prototype
int xPCGetNumParams(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetNumParams function returns the number of tunable
parameters in the target application. If the function detects an error, it
returns -1.
Description
The xPCGetNumParams function returns the number of tunable
parameters in the target application. Use this function to see how many
parameters you can get or modify.
See Also
API functions xPCGetParamIdx, xPCSetParam, xPCGetParam,
xPCGetParamName, xPCGetParamDims
xpctarget.xpc Class property NumParameters
7-64
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetNumScopes
Purpose
Return number of scopes added to target application
Prototype
int
Arguments
xPCGetNumScopes(int port);
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetNumScopes function returns the number of scopes that have
been added to the target application. If the function detects an error, it
returns -1.
Description
The xPCGetNumScopes function returns the number of scopes that have
been added to the target application.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-65
xPCGetNumScSignals
Purpose
Returns number of signals added to specific scope
Prototype
int xPCGetNumScSignals(int port, int scopeId);
Arguments
7-66
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scopeId
Enter the ID number of the scope for which you want to
get the number of added signals.
Return
The xPCGetNumScSignals function returns the number of signals that
have been added to the scope, scopeID. If the function detects an error,
it returns -1.
Description
The xPCGetNumScSignals function returns the number of signals that
have been added to the scope, scopeID.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetNumSignals
Purpose
Return number of signals
Prototype
int xPCGetNumSignals(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetNumSignals function returns the number of signals in the
target application. If the function detects an error, it returns -1.
Description
The xPCGetNumSignals function returns the total number of signals in
the target application that can be monitored from the host. Use this
function to see how many signals you can monitor.
See Also
API functions xPCGetSignalIdx, xPCGetSignal, xPCGetSignals,
xPCGetSignalName, xPCGetSignalWidth
xpctarget.xpc Class property NumSignals
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-67
xPCGetNumStates
Purpose
Return number of states
Prototype
int xPCGetNumStates(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetNumStates function returns the number of states in the
target application. If the function detects an error, it returns -1.
Description
The xPCGetNumStates function returns the number of states in the
target application.
See Also
API functions xPCGetStateLog, xPCGetNumOutputs, xPCGetOutputLog
xpctarget.xpc Class property StateLog
7-68
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetOutputLog
Purpose
Copy output log data to array
Prototype
void xPCGetOutputLog(int port, int first_sample,
int num_samples,
int decimation, int output_id, double *output_data);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
first_sample
Enter the index of the first sample to copy.
num_samples
Enter the number of samples to copy from the output
log.
decimation
Select whether to copy every sample value or every
Nth value.
output_id
Enter an output identification number.
output_data
The log is stored in output_data, whose allocation
is the responsibility of the caller.
The xPCGetOutputLog function gets the output log and copies that
log to an array. You get the data for each output signal in turn by
specifying output_id. Output IDs range from 0 to (N-1), where N is the
return value of xPCGetNumOutputs. Entering 1 for decimation copies
all values. Entering N copies every Nth value.
For first_sample, the sample indices range from 0 to (N-1), where N is
the return value of xPCNumLogSamples. Get the maximum number of
samples by calling the function xPCNumLogSamples.
Note that the target application must be stopped before you get the
number.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-69
xPCGetOutputLog
See Also
API functions xPCNumLogWraps, xPCNumLogSamples, xPCMaxLogSamples,
xPCGetNumOutputs, xPCGetStateLog, xPCGetTETLog, xPCGetTimeLog
Target object method xpctarget.xpc.getlog
xpctarget.xpc Class property OutputLog
7-70
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetParam
Purpose
Get parameter value and copy it to array
Prototype
void xPCGetParam(int port, int paramIndex,
double *paramValue);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
paramIndex
Enter the index for a parameter.
paramValue
The function returns a parameter value as an array
of doubles.
The xPCGetParam function returns the parameter as an array in
paramValue. paramValue must be large enough to hold the parameter.
You can query the size by calling the function xPCGetParamDims. Get
the parameter index by calling the function xPCGetParamIdx. The
parameter matrix is returned as a vector, with the conversion being
done in column-major format. It is also returned as a double, regardless
of the data type of the actual parameter.
For paramIndex, values range from 0 to (N-1), where N is the return
value of xPCGetNumParams.
See Also
API functions xPCSetParam, xPCGetParamDims, xPCGetParamIdx,
xPCGetNumParams
xpctarget.xpc.getparamid
xpctarget.xpc Class properties ShowParameters, Parameters
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-71
xPCGetParamDims
Purpose
Get row and column dimensions of parameter
Prototype
void xPCGetParamDims(int port, int paramIndex,
int *dimension);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
paramIndex
Parameter index.
dimension
Dimensions (row, column) of a parameter.
The xPCGetParamDims function gets the dimensions (row, column) of
a parameter with paramIndex and stores them in dimension, which
must have at least two elements.
For paramIndex, values range from 0 to (N-1), where N is the return
value of xPCGetNumParams.
See Also
API functions xPCGetParamIdx, xPCGetParamName, xPCSetParam,
xPCGetParam, xPCGetNumParams
xpctarget.xpc.getparamid
xpctarget.xpc Class property ShowParameters, Parameters
7-72
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetParamIdx
Purpose
Return parameter index
Prototype
int xPCGetParamIdx(int port, const char *blockName,
const char *paramName);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
blockName
Enter the full block path generated by Simulink
Coder.
paramName
Enter the parameter name for a parameter associated
with the block.
Return
The xPCGetParamIdx function returns the parameter index for the
parameter name. If the function detects an error, it returns -1.
Description
The xPCGetParamIdx function returns the parameter index for the
parameter name (paramName) associated with a Simulink block
(blockName). Both blockName and paramName must be identical to those
generated at target application building time. The block names should
be referenced from the file model_namept.m in the generated code,
where model_name is the name of the model. Note that a block can have
one or more parameters.
See Also
API functions xPCGetParamDims, xPCGetParamName, xPCGetParam
xpctarget.xpc.getparamid
xpctarget.xpc Class properties ShowParameters, Parameters
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-73
xPCGetParamName
Purpose
Get name of parameter
Prototype
void xPCGetParamName(int port, int paramIdx,
char *blockName, char
*paramName);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
paramIdx
Enter a parameter index.
blockName
String with the full block path generated by
Simulink Coder.
paramName
Name of a parameter for a specific block.
Description
The xPCGetParamName function gets the parameter name and block
name for a parameter with the index paramIdx. The block path
and name are returned and stored in blockName, and the parameter
name is returned and stored in paramName. You must allocate enough
space for both blockName and paramName. If the paramIdx is invalid,
xPCGetLastError returns nonzero, and the strings are unchanged. Get
the parameter index from the function xPCGetParamIdx.
See Also
API functions xPCGetParam, xPCGetParamDims, xPCGetParamIdx
xpctarget.xpc Class properties ShowParameters, Parameters
7-74
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetSampleTime
Purpose
Return target application sample time
Prototype
double xPCGetSampleTime(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetSampleTime function returns the sample time, in seconds, of
the target application. If the function detects an error, it returns -1.
Description
The xPCGetSampleTime function returns the sample time, in seconds,
of the target application. You can get the error by using the function
xPCGetLastError.
See Also
API function xPCSetSampleTime
xpctarget.xpc Class property SampleTime
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-75
xPCGetScope
Purpose
Get and copy scope data to structure
Prototype
scopedata xPCGetScope(int port, int scNum);
Arguments
Return
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
The xPCGetScope function returns a structure of type scopedata.
Note The xPCGetScope function will be removed in a future release.
Use the xPCScGetScopePropertyName functions to access property
values instead. For example, to get the number of samples being
acquired in one data acquisition cycle, use xPCScGetNumSamples.
The xPCGetScope function gets properties of a scope with scNum and
copies the properties into a structure with type scopedata. You can
use this function in conjunction with xPCSetScope to change several
properties of a scope at one time. See scopedata for a list of properties.
Use the xPCGetScope function to get the scope number.
See Also
API functions xPCSetScope, scopedata
Target object method xpctarget.xpc.getscope
7-76
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetScopeList
Purpose
Get and copy list of scope numbers
Prototype
void xPCGetScopeList(int port, int *data);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
data
List of scope numbers in an integer array (allocated by
the caller) as a list of unsorted integers.
The xPCGetScopeList function gets the list of scopes currently defined.
data must be large enough to hold the list of scopes. You can query the
size by calling the function xPCGetNumScopes.
Note Use the xPCGetScopeList function instead of the xPCGetScopes
function. The xPCGetScopes will be obsoleted in a future release.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-77
xPCGetScopes
Purpose
Get and copy list of scope numbers
Prototype
void xPCGetScopes(int port, int *data);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
data
List of scope numbers in an integer array (allocated by
the caller) as a list of unsorted integers and terminated
by -1.
The xPCGetScopes function gets the list of scopes currently defined.
You can use the constant MAX_SCOPES (defined in xpcapiconst.h) as
the size of data. This is currently set to 30 scopes.
Note This function will be obsoleted in a future release. Use the
xPCGetScopeList function instead.
See Also
API functions xPCSetScope, xPCGetScope, xPCScGetSignals
xpctarget.xpc Class property Scopes
7-78
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetSessionTime
Purpose
Return length of time xPC Target kernel has been running
Prototype
double xPCGetSessionTime(int port);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
Return
The xPCGetSessionTime function returns the amount of time in seconds
that the xPC Target kernel has been running on the target computer.
If the function detects an error, it returns -1.
Description
The xPCGetSessionTime function returns, as a double, the amount of
time in seconds that the xPC Target kernel has been running. This
value is also the time that has elapsed since you last booted the target
computer.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-79
xPCGetSignal
Purpose
Return value of signal
Prototype
double xPCGetSignal(int port, int sigNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
sigNum
Enter a signal number.
Return
The xPCGetSignal function returns the current value of signal sigNum.
If the function detects an error, it returns -1.
Description
The xPCGetSignal function returns the current value of a signal.
For vector signals, use xPCGetSignals rather than call this function
multiple times. Use the xPCGetSignalIdx function to get the signal
number.
See Also
API function xPCGetSignals
xpctarget.xpc Class properties ShowSignals, Signals
7-80
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetSignalIdx
Purpose
Return index for signal
Prototype
int xPCGetSignalIdx(int port, const char *sigName);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
sigName
Enter a signal name.
Return
The xPCGetSignalIdx function returns the index for the signal with
name sigName. If the function detects an error, it returns -1.
Description
The xPCGetSignalIdx function returns the index of a signal. The name
must be identical to the name generated when the application was
built. You should reference the name from the file model_namebio.m in
the generated code, where model_name is the name of the model. The
creator of the application should already know the signal name.
See Also
API functions xPCGetSignalName, xPCGetSignalWidth, xPCGetSignal,
xPCGetSignals
Target object method xpctarget.xpc.getsignalid
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-81
xPCGetSigIdxfromLabel
Purpose
Return array of signal indices
Prototype
int xPCGetSigIdxfromLabel(int port, const char
*sigLabel, int *sigIds);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
sigLabel
String with the name of a signal label.
sigIds
Return array of signal indices.
Return
If xPCGetSigIdxfromLabel finds a signal, it fills an array sigIds with
signal indices and returns 0. If it finds no signal, it returns -1.
Description
The xPCGetSigIdxfromLabel function returns in sigIds the array
of signal indices for signal sigName. This function assumes that you
have labeled the signal for which you request the indices (see the
Signal name parameter of the “Signal Properties Controls”). Note
that the xPC Target software refers to Simulink signal names as signal
labels. The creator of the application should already know the signal
name/label. Signal labels must be unique.
sigIds must be large enough to contain the array of indices. You can
use the xPCGetSigLabelWidth function to get the required amount of
memory to be allocated by the sigIds array.
See Also
7-82
API functions xPCGetSignalLabel, xPCGetSigLabelWidth
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetSignalLabel
Purpose
Copy label of signal to character array
Prototype
char * xPCGetSignalLabel(int port, int sigIdx,
char *sigLabel);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
sigIdx
Enter signal index.
sigLabel
Return signal label associated with signal index, sigIdx.
Return
The xPCGetSignalLabel function returns the label of the signal.
Description
The xPCGetSignalLabel function copies and returns the signal label,
including the block path, of a signal with sigIdx. The result is stored
in sigLabel. If sigIdx is invalid, xPCGetLastError returns a nonzero
value, and sigLabel is unchanged. The function returns sigLabel,
which makes it convenient to use in a printf or similar statement.
This function assumes that you already know the signal index. Signal
labels must be unique.
This function assumes that you have labeled the signal for which you
request the index (see the Signal name parameter of the “Signal
Properties Controls”). Note that the xPC Target software refers to
Simulink signal names as signal labels. The creator of the application
should already know the signal name/label.
See Also
API functions xPCGetSigIdxfromLabel, xPCGetSigLabelWidth
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-83
xPCGetSigLabelWidth
Purpose
Return number of elements in signal
Prototype
int xPCGetSigLabelWidth(int port, const char *sigName);
Arguments
7-84
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
sigName
String with the name of a signal.
Return
The xPCGetSigLabelWidth function returns the number of elements
that the signal sigName contains. If the function detects an error, it
returns -1.
Description
The xPCGetSigLabelWidth function returns the number of elements
that the signal sigName contains. This function assumes that you
have labeled the signal for which you request the elements (see the
Signal name parameter of the “Signal Properties Controls”). Note
that the xPC Target software refers to Simulink signal names as signal
labels. The creator of the application should already know the signal
name/label. Signal labels must be unique.
See Also
API functions xPCGetSigIdxfromLabel, xPCGetSignalLabel
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetSignalName
Purpose
Copy name of signal to character array
Prototype
char *xPCGetSignalName(int port, int sigIdx,
char *sigName);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
sigIdx
Enter a signal index.
sigName
String with the name of a signal.
Return
The xPCGetSignalName function returns the name of the signal.
Description
The xPCGetSignalName function copies and returns the signal name,
including the block path, of a signal with sigIdx. The result is stored
in sigName. If sigIdx is invalid, xPCGetLastError returns a nonzero
value, and sigName is unchanged. The function returns sigName, which
makes it convenient to use in a printf or similar statement. This
function assumes that you already know the signal index.
See Also
API functions xPCGetSignalIdx, xPCGetSignalWidth, xPCGetSignal,
xPCGetSignals
xpctarget.xpc Class properties ShowSignals, Signals
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-85
xPCGetSignals
Purpose
Return vector of signal values
Prototype
int xPCGetSignals(int port, int numSignals,
const int *signals,
double *values);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
numSignals
Enter the number of signals to be acquired (that is, the
number of values in signals).
signals
Enter the list of signal numbers to be acquired.
values
Returned values are stored in the double array values.
Return
The xPCGetSignals function returns 0 if it completes execution without
detecting an error. If the function detects an error, it returns -1.
Description
The xPCGetSignals function is the vector version of the function
xPCGetSignal. This function returns the values of a vector of signals
(up to 1000) as fast as it can acquire them. The signal values may not
be at the same time step (for that, define a scope of type SCTYPE_HOST
and use xPCScGetData). xPCGetSignal does the same thing for a single
signal, and could be used multiple times to achieve the same result.
However, the xPCGetSignals function is faster, and the signal values
are more likely to be spaced closely together. The signals are converted
to doubles regardless of the actual data type of the signal.
For signals, the list you provide should be stored in an integer array.
Get the signal numbers with the function xPCGetSignalIdx.
7-86
See Also
API function xPCGetSignal, xPCGetSignalIdx
Example
To reference signal vector data rather than scalar values, pass a vector
of indices for the signal data. For example:
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetSignals
/**********************************************************/
/* Assume a signal of width 10, with the blockpath
* mySubsys/mySignal and the signal index s1.
*/
int i;
int sigId[10];
double sigVal[10]; /* Signal values are stored here */
/* Get the ID of the first signal */
sigId[0] = xPCGetSignalIdx(port, "mySubsys/mySignal/s1");
if (sigId[0] == -1) {
/* Handle error */
}
for (i = 1; i < 10; i++) {
sigId[i] = sigId[0] + i;
}
xPCGetSignals(port, 10, sigId, sigVal);
/* If no error, sigVal should have the signal values */
/***********************************************************/
To repeatedly get the signals, repeat the call to xPCGetSignals. If you
do not change sigID, you only need to call xPCGetSignalIdx once.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-87
xPCGetSignalWidth
Purpose
Return width of signal
Prototype
int xPCGetSignalWidth(int port, int sigIdx);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
sigIdx
Enter the index of a signal.
Return
The xPCGetSignalWidth function returns the signal width for a signal
with sigIdx. If the function detects an error, it returns -1.
Description
The xPCGetSignalWidth function returns the number of signals for a
specified signal index. Although signals are manipulated as scalars, the
width of the signal might be useful to reassemble the components into a
vector again. A signal’s width is the number of signals in the vector.
See Also
API functions xPCGetSignalIdx, xPCGetSignalName, xPCGetSignal,
xPCGetSignals
7-88
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetStateLog
Purpose
Copy state log values to array
Prototype
void xPCGetStateLog(int port, int first_sample,
int num_samples,
int decimation, int state_id, double *state_data);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
first_sample
Enter the index of the first sample to copy.
num_samples
Enter the number of samples to copy from the output
log.
decimation
Select whether to copy all the sample values or every
Nth value.
state_id
Enter a state identification number.
state_data
The log is stored in state_data, whose allocation is
the responsibility of the caller.
The xPCGetStateLog function gets the state log. It then copies the
log into state_data. You get the data for each state signal in turn by
specifying the state_id. State IDs range from 1 to (N-1), where N is the
return value of xPCGetNumStates. Entering 1 for decimation copies
all values. Entering N copies every Nth value. For first_sample, the
sample indices range from 0 to (N-1), where N is the return value of
xPCNumLogSamples. Use the xPCNumLogSamples function to get the
maximum number of samples.
Note that the target application must be stopped before you get the
number.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-89
xPCGetStateLog
See Also
API functions xPCNumLogWraps, xPCNumLogSamples, xPCMaxLogSamples,
xPCGetNumStates, xPCGetOutputLog, xPCGetTETLog, xPCGetTimeLog
xpctarget.xpc.getlog
xpctarget.xpc Class property StateLog
7-90
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetStopTime
Purpose
Return stop time
Prototype
double xPCGetStopTime(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCGetStopTime function returns the stop time as a double, in
seconds, of the target application. If the function detects an error, it
returns -10.0. If the stop time is infinity (run forever), this function
returns -1.0.
Description
The xPCGetStopTime function returns the stop time, in seconds, of the
target application. This is the amount of time the target application
runs before stopping. If the function detects an error, it returns -10.0.
You will then need to use the function xPCGetLastError to find the
error number.
See Also
API function xPCSetStopTime
xpctarget.xpc Class property StopTime
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-91
xPCGetTargetVersion
Purpose
Get xPC Target kernel version
Prototype
void xPCGetTargetVersion(int port, char *ver);
Arguments
7-92
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
ver
The version is stored in ver.
Description
The xPCGetTargetVersion function gets a string with the version
number of the xPC Target kernel on the target computer. It then copies
that version number into ver.
See Also
xPCGetAPIVersion
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCGetTETLog
Purpose
Copy TET log to array
Prototype
void xPCGetTETLog(int port, int first_sample,
int num_samples, int decimation,
double *TET_data);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
first_sample
Enter the index of the first sample to copy.
num_samples
Enter the number of samples to copy from the TET
log.
decimation
Select whether to copy all the sample values or
every Nth value.
TET_data
The log is stored in TET_data, whose allocation is
the responsibility of the caller.
The xPCGetTETLog function gets the task execution time (TET) log. It
then copies the log into TET_data. Entering 1 for decimation copies
all values. Entering N copies every Nth value. For first_sample, the
sample indices range from 0 to (N-1), where N is the return value of
xPCNumLogSamples. Use the xPCNumLogSamples function to get the
maximum number of samples.
Note that the target application must be stopped before you get the
number.
See Also
API functions xPCNumLogWraps, xPCNumLogSamples, xPCMaxLogSamples,
xPCGetNumOutputs, xPCGetStateLog, xPCGetTimeLog
xpctarget.xpc.getlog
xpctarget.xpc Class property TETLog
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-93
xPCGetTimeLog
Purpose
Copy time log to array
Prototype
void xPCGetTimeLog(int port, int first_sample,
int num_samples,
int decimation, double *time_data);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
first_sample
Enter the index of the first sample to copy.
num_samples
Enter the number of samples to copy from the
time log.
decimation
Select whether to copy all the sample values or
every Nth value.
time_data
The log is stored in time_data, whose allocation
is the responsibility of the caller.
The xPCGetTimeLog function gets the time log and copies the log into
time_data. This is especially relevant in the case of value-equidistant
logging, where the logged values might not be uniformly spaced in
time. Entering 1 for decimation copies all values. Entering N copies
every Nth value. For first_sample, the sample indices range from 0
to (N-1), where N is the return value of xPCNumLogSamples. Use the
xPCNumLogSamples function to get the number of samples.
Note that the target application must be stopped before you get the
number.
See Also
API functions xPCNumLogWraps, xPCNumLogSamples, xPCMaxLogSamples,
xPCGetStateLog, xPCGetTETLog, xPCSetLogMode, xPCGetLogMode
xpctarget.xpc.getlog
xpctarget.xpc Class property TimeLog
7-94
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCInitAPI
Purpose
Initialize xPC Target DLL
Prototype
int xPCInitAPI(void);
Return
The xPCInitAPI function returns 0 if it completes execution without
detecting an error. If the function detects an error, it returns -1.
Description
The xPCInitAPI function initializes the xPC Target dynamic link
library. You must execute this function once at the beginning of the
application to load the xPC Target API DLL. This function is defined in
the file xpcinitfree.c. Link this file with your application.
See Also
API functions xPCFreeAPI, xPCNumLogWraps, xPCNumLogSamples,
xPCMaxLogSamples, xPCGetStateLog, xPCGetTETLog, xPCSetLogMode,
xPCGetLogMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-95
xPCIsAppRunning
Purpose
Return target application running status
Prototype
int xPCIsAppRunning(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
If the target application is stopped, the xPCIsAppRunning function
returns 0. If the target application is running, this function returns 1.
If the function detects an error, it returns -1.
Description
The xPCIsAppRunning function returns 1 or 0 depending on whether
the target application is stopped or running. If the function detects
is an error, use the function xPCGetLastError to check for the error
string constant.
See Also
API function xPCIsOverloaded
xpctarget.xpc Class property Status
7-96
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCIsOverloaded
Purpose
Return target computer overload status
Prototype
int xPCIsOverloaded(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
If the target application has overloaded the CPU, the xPCIsOverloaded
function returns 1. If it has not overloaded the CPU, the function
returns 0. If this function detects error, it returns -1.
Description
The xPCIsOverloaded function checks if the target application has
overloaded the target computer and returns 1 if it has and 0 if it has
not. If the target application is not running, the function returns 0.
See Also
API function xPCIsAppRunning
xpctarget.xpc Class property CPUoverload
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-97
xPCIsScFinished
Purpose
Return data acquisition status for scope
Prototype
int xPCIsScFinished(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
If a scope finishes a data acquisition cycle, the xPCIsScFinished
function returns 1. If the scope is in the process of acquiring data, this
function returns 0. If the function detects an error, it returns -1.
Description
The xPCIsScFinished function returns a Boolean value depending on
whether scope scNum is finished (state of SCST_FINISHED) or not. You
can also call this function for target scopes; however, because target
scopes restart immediately, it is almost impossible to find these scopes
in the finished state. Use the xPCGetScope function to get the scope
number.
See Also
API function xPCScGetState
Scope object property Status
7-98
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCLoadApp
Purpose
Load target application onto target computer
Prototype
void xPCLoadApp(int port, const char *pathstr,
const char *filename);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
pathstr
Enter the full path to the target application file,
excluding the file name. For example, in C, use a
string like "C:\\work".
filename
Enter the name of a compiled target application
(*.dlm) without the file extension. For example, in C
use a string like "xpcosc".
The xPCLoadApp function loads the compiled target application to the
target computer. pathstr must not contain the trailing backslash.
pathstr can be set to NULL or to the string 'nopath' if the application
is in the current folder. The variable filename must not contain the
target application extension.
Before returning, xPCLoadApp waits for a certain amount of time before
checking whether the model initialization is complete. In the case
where the model initialization is incomplete, xPCLoadApp returns a
timeout error to indicate a connection problem (for example, ETCPREAD).
By default, xPCLoadApp checks for target readiness five times, with
each attempt taking approximately 1 second (less if the target is ready).
However, for larger models or models requiring longer initialization (for
example, those with thermocouple boards), the default might not be
long enough and a spurious timeout can be generated. The functions
xPCGetLoadTimeOut and xPCSetLoadTimeOut control the number of
attempts made.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-99
xPCLoadApp
See Also
API functions xPCStartApp, xPCStopApp, xPCUnloadApp,
xPCSetLoadTimeOut, xPCGetLoadTimeOut
Target object method xpctarget.xpc.load
7-100
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCLoadParamSet
Purpose
Restore parameter values
Prototype
void xPCLoadParamSet(int port, const char *filename);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
filename
Enter the name of the file that contains the saved
parameters.
Description
The xPCLoadParamSet function restores the target application
parameter values saved in the file filename. This file must be located
on a local drive of the target computer. The parameter file must have
been saved from a previous call to xPCSaveParamSet.
See Also
API function xPCSaveParamSet
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-101
xPCMaxLogSamples
Purpose
Return maximum number of samples that can be in log buffer
Prototype
int xPCMaxLogSamples(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCMaxLogSamples function returns the total number of samples.
If the function detects an error, it returns -1.
Description
The xPCMaxLogSamples function returns the total number of samples
that can be returned in the logging buffers.
See Also
API functions xPCNumLogSamples, xPCNumLogWraps, xPCGetStateLog,
xPCGetOutputLog, xPCGetTETLog, xPCGetTimeLog
xpctarget.xpc Class property MaxLogSamples
7-102
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCMaximumTET
Purpose
Copy maximum task execution time to array
Prototype
void xPCMaximumTET(int port, double *data);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
data
Array of at least two doubles.
Description
The xPCMaximumTET function gets the maximum task execution time
(TET) that was achieved during the previous target application run.
This function also returns the time at which the maximum TET was
achieved. The xPCMaximumTET function then copies these values into the
data array. The maximum TET value is copied into the first element,
and the time at which it was achieved is copied into the second element.
See Also
API functions xPCMinimumTET, xPCAverageTET
xpctarget.xpc Class property MaxTET
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-103
xPCMinimumTET
Purpose
Copy minimum task execution time to array
Prototype
void xPCMinimumTET(int port, double *data);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
data
Array of at least two doubles.
Description
The xPCMinimumTET function gets the minimum task execution time
(TET) that was achieved during the previous target application run.
This function also returns the time at which the minimum TET was
achieved. The xPCMinimumTET function then copies these values into the
data array. The minimum TET value is copied into the first element,
and the time at which it was achieved is copied into the second element.
See Also
API functions xPCMaximumTET, xPCAverageTET
xpctarget.xpc Class property MinTET
7-104
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCNumLogSamples
Purpose
Return number of samples in log buffer
Prototype
int xPCNumLogSamples(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCNumLogSamples function returns the number of samples in the
log buffer. If the function detects an error, it returns -1.
Description
The xPCNumLogSamples function returns the number of samples in
the log buffer. In contrast to xPCMaxLogSamples, which returns the
maximum number of samples that can be logged (because of buffer
size constraints), xPCNumLogSamples returns the number of samples
actually logged.
Note that the target application must be stopped before you get the
number.
See Also
API functions xPCGetStateLog, xPCGetOutputLog, xPCGetTETLog,
xPCGetTimeLog, xPCMaxLogSamples
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-105
xPCNumLogWraps
Purpose
Return number of times log buffer wraps
Prototype
int xPCNumLogWraps(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCNumLogWraps function returns the number of times the log
buffer wraps. If the function detects an error, it returns -1.
Description
The xPCNumLogWraps function returns the number of times the log
buffer wraps.
See Also
API functions xPCNumLogSamples, xPCMaxLogSamples, xPCGetStateLog,
xPCGetOutputLog, xPCGetTETLog, xPCGetTimeLog
xpctarget.xpc Class property NumLogWraps
7-106
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCOpenConnection
Purpose
Open connection to target computer
Prototype
void xPCOpenConnection(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Description
The xPCOpenConnection function opens a connection to the target
computer whose data is indexed by port. Before calling this function,
set up the target information by calling xPCRegisterTarget. A call to
either xPCOpenSerialPort or xPCOpenTcpIpPort can also set up the
target information. If the port is already open, calling this function
has no effect.
See Also
API functions xPCOpenTcpIpPort, xPCClosePort, xPCReOpenPort,
xPCTargetPing, xPCCloseConnection, xPCRegisterTarget
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-107
xPCOpenSerialPort
Purpose
Open RS-232 connection to xPC Target system
Prototype
int xPCOpenSerialPort(int comPort, int baudRate);
Arguments
comPort
Index of the COM port to be used (0 is COM1, 1 is
COM2, and so forth).
baudRate
baudRate must be one of the following values: 1200,
2400, 4800, 9600, 19200, 38400, 57600, or 115200.
Return
The xPCOpenSerialPort function returns the port value for the
connection. If the function detects an error, it returns -1.
Description
The xPCOpenSerialPort function initiates an RS-232 connection to
an xPC Target system. It returns the port value for the connection.
Be sure to pass this value to all the xPC Target API functions that
require a port value.
If you enter a value of 0 for baudRate, this function sets the baud rate to
the default value (115200).
Note RS-232 Host-Target communication mode will be removed in a
future release. Use TCP/IP instead.
See Also
7-108
API functions xPCOpenTcpIpPort, xPCClosePort, xPCReOpenPort,
xPCTargetPing, xPCOpenConnection, xPCCloseConnection,
xPCRegisterTarget, xPCDeRegisterTarget
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCOpenTcpIpPort
Purpose
Open TCP/IP connection to xPC Target system
Prototype
int xPCOpenTcpIpPort(const char *ipAddress, const char
*ipPort);
Arguments
ipAddress
Enter the IP address of the target as a dotted decimal
string. For example, "192.168.0.10".
ipPort
Enter the associated IP port as a string. For example,
"22222".
Return
The xPCOpenTcpIpPort function returns a nonnegative integer that you
can then use as the port value for an xPC Target API function that
requires it. If this operation fails, this function returns -1.
Description
The xPCOpenTcpIpPort function opens a connection to the TCP/IP
location specified by the IP address. It returns a nonnegative integer if
it succeeds. Use this integer as the ipPort variable in the xPC Target
API functions that require a port value. The global error number is also
set, which you can get using xPCGetLastError.
See Also
API functions xPCOpenSerialPort, xPCClosePort, xPCReOpenPort,
xPCTargetPing
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-109
xPCReboot
Purpose
Reboot target computer
Prototype
void xPCReboot(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Description
The xPCReboot function reboots the target computer. This function
returns nothing. This function does not close the connection to the
target computer. You should either explicitly close the port or call
xPCReOpenPort once the target computer has rebooted.
See Also
API function xPCReOpenPort
Target object method xpctarget.xpc.reboot
7-110
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCReOpenPort
Purpose
Reopen communication channel
Prototype
int xPCReOpenPort(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCReOpenPort function returns 0 if it reopens a connection without
detecting an error. If the function detects an error, it returns -1.
Description
The xPCReOpenPort function reopens the communications channel
pointed to by port. The difference between this function and
xPCOpenSerialPort or xPCOpenTcpIpPort is that xPCReOpenPort uses
the already existing settings, while the other functions need to set up
the port.
See Also
API functions xPCOpenTcpIpPort, xPCClosePort
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-111
xPCRegisterTarget
Purpose
Register target with xPC Target API library
Prototype
int xPCRegisterTarget(int commType, const char *ipAddress,
const char *ipPort, int comPort, int baudRate);
Arguments
commType
Specify the communication type (TCP/IP or RS-232)
between the host and the target.
Note RS-232 Host-Target communication mode will be
removed in a future release. Use TCP/IP instead.
ipAddress Enter the IP address of the target as a dotted decimal
string. For example, "192.168.0.10".
ipPort
Enter the associated IP port as a string. For example,
"22222".
comPort
comPort and baudRate are as in xPCOpenSerialPort.
baudRate
The baudRate must be one of the following values: 1200,
2400, 4800, 9600, 19200, 38400, 57600, or 115200.
Return
The xPCRegisterTarget function returns the port number. If the
function detects an error, it returns -1.
Description
The xPCRegisterTarget function works similarly to
xPCOpenSerialPort and xPCOpenTcpIpPort, except that it does not
try to open a connection to the target computer. In other words,
xPCOpenSerialPort or xPCOpenTcpIpPort is equivalent to calling
xPCRegisterTarget with the required parameters, followed by a call to
xPCOpenConnection.
Use the constants COMMTYP_TCPIP and COMMTYP_RS232 for commType.
If commType is set to COMMTYP_RS232, the function ignores ipAddress
7-112
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCRegisterTarget
and ipPort. Analogously, the function ignores comPort and baudRate if
commType is set to COMMTYP_TCPIP.
If you enter a value of 0 for baudRate, this function sets the baud rate to
the default value (115200).
See Also
API functions xPCDeRegisterTarget, xPCOpenTcpIpPort,
xPCOpenSerialPort, xPCClosePort, xPCReOpenPort,
xPCOpenConnection, xPCCloseConnection, xPCTargetPing
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-113
xPCRemScope
Purpose
Remove scope
Prototype
void xPCRemScope(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Description
The xPCRemScope function removes the scope with number scNum.
Attempting to remove a nonexistent scope causes an error. For a list
of existing scopes, see xPCGetScopes. Use the xPCGetScope function
to get the scope number.
See Also
API functions xPCAddScope, xPCScRemSignal, xPCGetScopes
Target object method xpctarget.xpc.remscope
7-114
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSaveParamSet
Purpose
Save parameter values of target application
Prototype
void xPCSaveParamSet(int port, const char *filename);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
filename
Enter the name of the file to contain the saved parameters.
The xPCSaveParamSet function saves the target application parameter
values in the file filename. This function saves the file on a local drive
of the current target computer. You can later reload these parameters
with the xPCLoadParamSet function.
You might want to save target application parameter values if you
change these parameter values while the application is running in
real time. Saving these values enable you to easily recreate target
application parameter values from a number of application runs.
See Also
API function xPCLoadParamSet
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-115
xPCScAddSignal
Purpose
Add signal to scope
Prototype
void xPCScAddSignal(int port, int scNum, int sigNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
sigNum
Enter a signal number.
Description
The xPCScAddSignal function adds the signal with number sigNum to
the scope scNum. The signal should not already exist in the scope. You
can use xPCScGetSignals to get a list of the signals already present.
Use the function xPCGetScope to get the scope number. Use the
xPCGetSignalIdx function to get the signal number.
See Also
API functions xPCScRemSignal, xPCAddScope, xPCRemScope,
xPCGetScopes
Scope object method xpctarget.xpcsc.addsignal
7-116
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetAutoRestart
Purpose
Scope autorestart status
Prototype
long xPCScGetAutoRestart(int port, int scNum)
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetAutoRestart function returns the autorestart flag value
of scope scNum. If the function detects an error, it returns -1.
Description
The xPCScGetAutoRestart function gets the autorestart flag value for
scope scNum. Autorestart flag can be disabled (0) or enabled (1).
See Also
API functions xPCScSetAutoRestart
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-117
xPCScGetData
Purpose
Copy scope data to array
Prototype
void xPCScGetData(int port, int scNum, int
signal_id, int start,
int numsamples, int decimation, double *data);
Arguments
Description
7-118
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
signal_id
Enter a signal number. Enter -1 to get time
stamped data.
start
Enter the first sample from which data retrieval is
to start
numsamples
Enter the number of samples retrieved with a
decimation of decimation, starting from the start
value.
decimation
Enter a value such that every decimation sample
is retrieved in a scope window.
data
The data is available in the array data, starting
from sample start.
The xPCScGetData function gets the data used in a scope. Use this
function for scopes of type SCTYPE_HOST. The scope must be either
in state "Finished" or in state "Interrupted" for the data to be
retrievable. (Use the xPCScGetState function to check the state of the
scope.) The data must be retrieved one signal at a time. The calling
function must allocate the space ahead of time to store the scope data.
data must be an array of doubles, regardless of the data type of the
signal to be retrieved. Use the function xPCScGetSignals to get the list
of signals in the scope for signal_id. Use the function xPCGetScope to
get the scope number for scNum.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetData
To get time stamped data, specify -1 for signal_id. From the output,
you can then get the number of nonzero elements.
See Also
API functions xPCGetScope, xPCScGetState, xPCScGetSignals
xpctarget.xpcschost Class property Data
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-119
xPCScGetDecimation
Purpose
Return decimation of scope
Prototype
int xPCScGetDecimation(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetDecimation function returns the decimation of scope
scNum. If the function detects an error, it returns -1.
Description
The xPCScGetDecimation function gets the decimation of scope scNum.
The decimation is a number, N, meaning every Nth sample is acquired in
a scope window. Use the xPCGetScope function to get the scope number.
See Also
API function xPCScSetDecimation
xpctarget.xpcsc Class property Decimation
7-120
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetNumPrePostSamples
Purpose
Get number of pre- or post-triggering samples before triggering scope
Prototype
int xPCScGetNumPrePostSamples(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetNumPrePostSamples function returns the number of
samples for pre- or posttriggering for scope scNum. If an error occurs,
this function returns the minimum integer value (-2147483647-1).
Description
The xPCScGetNumPrePostSamples function gets the number of samples
for pre- or posttriggering for scope scNum. A negative number implies
pretriggering, whereas a positive number implies posttriggering
samples. Use the xPCGetScope function to get the scope number.
See Also
API function xPCScSetNumPrePostSamples
xpctarget.xpcsc Class property NumPrePostSamples
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-121
xPCScGetNumSamples
Purpose
Get number of samples in one data acquisition cycle
Prototype
int xPCScGetNumSamples(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetNumSamples function returns the number of samples in
the scope scNum. If the function detects an error, it returns -1.
Description
The xPCScGetNumSamples function gets the number of samples in one
data acquisition cycle for scope scNum. Use the xPCGetScope function
to get the scope number.
See Also
API function xPCScSetNumSamples
xpctarget.xpcsc Class property NumSamples
7-122
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetNumSignals
Purpose
Get number of signals in scope
Prototype
int xPCScGetNumSignals(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetNumSignals function returns the number of signals in the
scope scNum. If the function detects an error, it returns -1.
Description
The xPCScGetNumSignals function gets the number of signals in the
scope scNum. Use the xPCGetScope function to get the scope number.
See Also
API function xPCGetScope
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-123
xPCScGetSignalList
Purpose
Copy list of signals to array
Prototype
void xPCScGetSignalList(int port, int scNum, int *data)
Arguments
Description
port
Value returned by either the function xPCOpenSerialPort
or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
data
Integer array allocated by the caller as a list containing
the signal identifiers.
The xPCScGetSignals function gets the list of signals defined for scope
scNum. The array data must be large enough to hold the list of signals.
To query the size, use the xPCScGetNumSignals function. Use the
xPCGetScope function to get the scope number.
Note Use the xPCScGetSignalList function instead of the
xPCScGetSignals function. The xPCScGetSignals will be obsoleted
in a future release.
7-124
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetSignals
Purpose
Copy list of signals to array
Prototype
void xPCScGetSignals(int port, int scNum, int *data);
Arguments
Description
port
Value returned by either the function xPCOpenSerialPort
or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
data
Integer array allocated by the caller as a list containing
the signal identifiers, terminated by -1.
The xPCScGetSignals function gets the list of signals defined for
scope scNum. You can use the constant MAX_SIGNALS, defined in
xpcapiconst.h, as the size of data. Use the xPCGetScope function
to get the scope number.
Note This function will be obsoleted in a future release. Use the
xPCScGetSignalList function instead.
See Also
API functions xPCScGetData, xPCGetScopes
Scope object property Signals
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-125
xPCScGetStartTime
Purpose
Get start time for last data acquisition cycle
Prototype
double xPCScGetStartTime(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetStartTime function returns the start time for the last
data acquisition cycle of a scope. If the function detects an error, it
returns -1.
Description
The xPCScGetStartTime function gets the time at which the last data
acquisition cycle for scope scNum started. This is only valid for scopes
of type SCTYPE_HOST. Use the xPCGetScope function to get the scope
number.
See Also
API functions xPCScGetNumSamples, xPCScGetDecimation
7-126
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetState
Purpose
Get state of scope
Prototype
int xPCScGetState(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetState function returns the state of scope scNum. If the
function detects an error, it returns -1.
Description
The xPCScGetState function gets the state of scope scNum, or -1 upon
error. Use the xPCGetScope function to get the scope number.
Constants to find the scope state, defined in xpcapiconst.h, have the
following meanings:
Constant
Value
Description
SCST_WAITTOSTART
0
Scope is ready and waiting to start.
SCST_PREACQUIRING
5
Scope acquires a predefined number
of samples before triggering.
SCST_WAITFORTRIG
1
After a scope is finished with the
preacquiring state, it waits for
a trigger. If the scope does not
preacquire data, it enters the wait
for trigger state.
SCST_ACQUIRING
2
Scope is acquiring data. The scope
enters this state when it leaves the
wait for trigger state.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-127
xPCScGetState
See Also
Constant
Value
Description
SCST_FINISHED
3
Scope is finished acquiring data
when it has attained the predefined
limit.
SCST_INTERRUPTED
4
The user has stopped (interrupted)
the scope.
API functions xPCScStart, xPCScStop
Scope object property Status
7-128
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetTriggerLevel
Purpose
Get trigger level for scope
Prototype
double xPCScGetTriggerLevel(int port, int scNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetTriggerLevel function returns the scope trigger level.
If the function detects an error, it returns -1.
Description
The xPCScGetTriggerLevel function gets the trigger level for scope
scNum. Use the xPCGetScope function to get the scope number.
See Also
API functions xPCScSetTriggerLevel, xPCScSetTriggerSlope,
xPCScGetTriggerSlope, xPCScSetTriggerSignal,
xPCScGetTriggerSignal, xPCScSetTriggerScope,
xPCScGetTriggerScope, xPCScSetTriggerMode, xPCScGetTriggerMode
xpctarget.xpcsc Class property TriggerLevel
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-129
xPCScGetTriggerMode
Purpose
Get trigger mode for scope
Prototype
int xPCScGetTriggerMode(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetTriggerMode function returns the scope trigger mode. If
the function detects an error, it returns -1.
Description
The xPCScGetTriggerMode function gets the trigger mode for scope
scNum. Use the xPCGetScope function to get the scope number. Use
the constants defined in xpcapiconst.h to interpret the trigger mode.
These constants include the following:
7-130
Constant
Value
Description
TRIGMD_FREERUN
0
There is no trigger mode. The
scope triggers when it is ready
to trigger, regardless of the
circumstances.
TRIGMD_SOFTWARE
1
Only user intervention can
trigger the scope. No other
triggering is possible.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetTriggerMode
See Also
Constant
Value
Description
TRIGMD_SIGNAL
2
The scope is triggered only
after a signal has crossed a
value.
TRIGMD_SCOPE
3
The scope is triggered by
another scope at the trigger
point of the triggering scope,
modified by the value of
triggerscopesample (see
scopedata).
API functions xPCScSetTriggerLevel, xPCScGetTriggerLevel,
xPCScSetTriggerSlope, xPCScGetTriggerSlope,
xPCScSetTriggerSignal, xPCScGetTriggerSignal,
xPCScSetTriggerScope, xPCScGetTriggerScope,
xPCScSetTriggerMode
trigger
xpctarget.xpcsc Class property TriggerMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-131
xPCScGetTriggerScope
Purpose
Get trigger scope
Prototype
int xPCScGetTriggerScope(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetTriggerScope function returns a trigger scope. If the
function detects an error, it returns -1.
Description
The xPCScGetTriggerScope function gets the trigger scope for scope
scNum. Use the xPCGetScope function to get the scope number.
See Also
API functions xPCScSetTriggerLevel, xPCScGetTriggerLevel,
xPCScSetTriggerSlope, xPCScGetTriggerSlope,
xPCScSetTriggerSignal, xPCScGetTriggerSignal,
xPCScSetTriggerMode, xPCScGetTriggerMode
xpctarget.xpcsc Class property TriggerScope
7-132
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetTriggerScopeSample
Purpose
Get sample number for triggering scope
Prototype
int xPCScGetTriggerScopeSample(int port, int scNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetTriggerScopeSample function returns a nonnegative
integer for a real sample, and -1 for the special case where triggering
is at the end of the data acquisition cycle for a triggering scope. If the
function detects an error, it returns INT_MIN (-2147483647-1).
Description
The xPCScGetTriggerScopeSample function gets the number of
samples a triggering scope (scNum) acquires before starting data
acquisition on a second scope. This value is a nonnegative integer for a
real sample, and -1 for the special case where triggering is at the end of
the data acquisition cycle for a triggering scope. Use the xPCGetScope
function to get the scope number for the trigger scope.
See Also
API functions xPCScSetTriggerLevel, xPCScGetTriggerLevel,
xPCScSetTriggerSlope, xPCScGetTriggerSlope,
xPCScSetTriggerSignal, xPCScGetTriggerSignal,
xPCScSetTriggerScope, xPCScGetTriggerScope,
xPCScSetTriggerMode, xPCScGetTriggerMode,
xPCScSetTriggerScopeSample
xpctarget.xpcsc Class property TriggerSample
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-133
xPCScGetTriggerSignal
Purpose
Get trigger signal for scope
Prototype
int xPCScGetTriggerSignal(int port, int scNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetTriggerSignal function returns the scope trigger signal.
If the function detects an error, it returns -1.
Description
The xPCScGetTriggerSignal function gets the trigger signal for scope
scNum. Use the xPCGetScope function to get the scope number for the
trigger scope.
See Also
API functions xPCScSetTriggerLevel, xPCScGetTriggerLevel,
xPCScSetTriggerSlope, xPCScGetTriggerSlope,
xPCScSetTriggerSignal, xPCScSetTriggerScope,
xPCScGetTriggerScope, xPCScSetTriggerMode, xPCScGetTriggerMode
trigger
xpctarget.xpcsc Class property TriggerSignal
7-134
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetTriggerSlope
Purpose
Get trigger slope for scope
Prototype
int xPCScGetTriggerSlope(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetTriggerSlope function returns the scope trigger slope.
If the function detects an error, it returns -1.
Description
The xPCScGetTriggerSlope function gets the trigger slope of scope
scNum. Use the xPCGetScope function to get the scope number for the
trigger scope. Use the constants defined in xpcapiconst.h to interpret
the trigger slope. These constants have the following meanings:
Constant
Value
Description
TRIGSLOPE_EITHER
0
The trigger slope can be either
rising or falling.
TRIGSLOPE_RISING
1
The trigger slope must be
rising when the signal crosses
the trigger value.
TRIGSLOPE_FALLING
2
The trigger slope must be
falling when the signal crosses
the trigger value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-135
xPCScGetTriggerSlope
See Also
API functions xPCScSetTriggerLevel, xPCScGetTriggerLevel,
xPCScSetTriggerSlope, xPCScSetTriggerSignal,
xPCScGetTriggerSignal, xPCScSetTriggerScope,
xPCScGetTriggerScope, xPCScSetTriggerMode, xPCScGetTriggerMode
xpctarget.xpcsc.trigger
xpctarget.xpcsc Class properties TriggerMode, TriggerSlope
7-136
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScGetType
Purpose
Get type of scope
Prototype
int xPCScGetType(int port, int scNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
The xPCScGetType function returns the scope type. If the function
detects an error, it returns -1.
Description
The xPCScGetType function gets the type (SCTYPE_HOST for host,
SCTYPE_TARGET for target, or SCTYPE_FILE for file) of scope scNum. Use
the constants defined in xpcapiconst.h to interpret the return value.
A scope of type SCTYPE_HOST is displayed on the host computer while
a scope of type SCTYPE_TARGET is displayed on the target computer
screen. A scope of type SCTYPE_FILE is stored on a storage medium. Use
the xPCGetScope function to get the scope number.
See Also
API functions xPCAddScope, xPCRemScope
xpctarget.xpcsc Class property Type
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-137
xPCScRemSignal
Purpose
Remove signal from scope
Prototype
void xPCScRemSignal(int port, int scNum, int sigNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
sigNum
Enter a signal number.
Description
The xPCScRemSignal function removes a signal from the scope with
number scNum. The scope must already exist, and signal number sigNum
must exist in the scope. Use xPCGetScopes to determine the existing
scopes, and use xPCScGetSignals to determine the existing signals
for a scope. Use this function only when the scope is stopped. Use
xPCScGetState to check the state of the scope. Use the xPCGetScope
function to get the scope number.
See Also
API functions xPCScAddSignal, xPCAddScope, xPCRemScope,
xPCGetScopes, xPCScGetSignals, xPCScGetState
Scope object method remsignal
7-138
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScSetAutoRestart
Purpose
Scope autorestart status
Prototype
void xPCScSetAutoRestart(int port, int scNum,
int autorestart)
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
autorestart
Enter value to enable (1) or disable (0) scope
autorestart.
Description
The xPCScSetAutoRestart function sets the autorestart flag for scope
scNum to 0 or 1. 0 disables the flag, 1 enables it. Use this function only
when the scope is stopped.
See Also
API functions xPCScGetAutoRestart
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-139
xPCScSetDecimation
Purpose
Set decimation of scope
Prototype
void xPCScSetDecimation(int port, int scNum,
int decimation);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
decimation
Enter an integer for the decimation.
Description
The xPCScSetDecimation function sets the decimation of scope scNum.
The decimation is a number, N, meaning every Nth sample is acquired in
a scope window. Use this function only when the scope is stopped. Use
xPCScGetState to check the state of the scope. Use the xPCGetScope
function to get the scope number.
See Also
API functions xPCScGetDecimation, xPCScGetState
xpctarget.xpcsc Class property Decimation
7-140
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScSetNumPrePostSamples
Purpose
Set number of pre- or posttriggering samples before triggering scope
Prototype
void xPCScSetNumPrePostSamples(int port, int
scNum, int prepost);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
prepost
A negative number means pretriggering, while
a positive number means posttriggering. This
function can only be used when the scope is stopped.
Description
The xPCScSetNumPrePostSamples function sets the number of samples
for pre- or posttriggering for scope scNum to prepost. Use this function
only when the scope is stopped. Use xPCScGetState to check the state
of the scope. Use the xPCGetScope function to get the scope number.
See Also
API functions xPCScGetNumPrePostSamples, xPCScGetState
xpctarget.xpcsc Class property NumPrePostSamples
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-141
xPCScSetNumSamples
Purpose
Set number of samples in one data acquisition cycle
Prototype
void xPCScSetNumSamples(int port, int scNum, int samples);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
samples
Enter the number of samples you want to acquire in
one cycle.
Description
The xPCScSetNumSamples function sets the number of samples for
scope scNum to samples. Use this function only when the scope is
stopped. Use xPCScGetState to check the state of the scope. Use the
xPCGetScope function to get the scope number.
See Also
API functions xPCScGetNumSamples, xPCScGetState
xpctarget.xpcsc Class property NumSamples
7-142
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScSetTriggerLevel
Purpose
Set trigger level for scope
Prototype
void xPCScSetTriggerLevel(int port, int scNum,
double level);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
level
Value for a signal to trigger data acquisition with a
scope.
Description
The xPCScSetTriggerLevel function sets the trigger level to level for
scope scNum. Use this function only when the scope is stopped. Use
xPCScGetState to check the state of the scope. Use the xPCGetScope
function to get the scope number for the trigger scope.
See Also
API functions xPCScGetTriggerLevel, xPCScSetTriggerSlope,
xPCScGetTriggerSlope, xPCScSetTriggerSignal,
xPCScGetTriggerSignal, xPCScSetTriggerScope,
xPCScGetTriggerScope, xPCScSetTriggerMode,
xPCScGetTriggerMode, xPCScGetState
xpctarget.xpcsc Class property TriggerLevel
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-143
xPCScSetTriggerMode
Purpose
Set trigger mode of scope
Prototype
void xPCScSetTriggerMode(int port, int scNum, int mode);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
mode
Trigger mode for a scope.
The xPCScSetTriggerMode function sets the trigger mode of scope
scNum to mode. Use this function only when the scope is stopped. Use
xPCScGetState to check the state of the scope. Use the xPCGetScopes
function to get a list of scopes.
Use the constants defined in xpcapiconst.h to interpret the trigger
mode:
7-144
Constant
Value
Description
TRIGMD_FREERUN
0
There is no trigger mode. The scope
triggers when it is ready to trigger,
regardless of the circumstances. This is
the default.
TRIGMD_SOFTWARE 1
Only user intervention can trigger the
scope. No other triggering is possible.
TRIGMD_SIGNAL
2
The scope is triggered only after a signal
has crossed a value.
TRIGMD_SCOPE
3
The scope is triggered by another
scope at the trigger point of the
triggering scope, modified by the value of
triggerscopesample (see scopedata).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScSetTriggerMode
See Also
API functions xPCGetScopes, xPCScSetTriggerLevel,
xPCScGetTriggerLevel, xPCScSetTriggerSlope,
xPCScGetTriggerSlope, xPCScSetTriggerSignal,
xPCScGetTriggerSignal, xPCScSetTriggerScope,
xPCScGetTriggerScope, xPCScGetTriggerMode, xPCScGetState
trigger
xpctarget.xpcsc Class property TriggerMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-145
xPCScSetTriggerScope
Purpose
Select scope to trigger another scope
Prototype
void xPCScSetTriggerScope(int port, int scNum,
int trigScope);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
trigScope
Enter the scope number of the scope used for a trigger.
The xPCScSetTriggerScope function sets the trigger scope of scope
scNum to trigScope. This function can only be used when the scope is
stopped. Use xPCScGetState to check the state of the scope. Use the
xPCGetScopes function to get a list of scopes.
The scope type can be SCTYPE_HOST, SCTYPE_TARGET, or SCTYPE_FILE.
See Also
API functions xPCGetScopes, xPCScSetTriggerLevel,
xPCScGetTriggerLevel, xPCScSetTriggerSlope,
xPCScGetTriggerSlope, xPCScSetTriggerSignal,
xPCScGetTriggerSignal, xPCScGetTriggerScope,
xPCScSetTriggerMode, xPCScGetTriggerMode, xPCScGetState
xpctarget.xpcsc Class property TriggerScope
7-146
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScSetTriggerScopeSample
Purpose
Set sample number for triggering scope
Prototype
void xPCScSetTriggerScopeSample(int port, int scNum, int
trigScSamp);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
trigScSampEnter a nonnegative integer for the number of samples
acquired by the triggering scope before starting data
acquisition on a second scope.
Description
The xPCScSetTriggerScopeSample function sets the number of samples
(trigScSamp) a triggering scope acquires before it triggers a second
scope (scNum). Use the xPCGetScopes function to get a list of scopes.
For meaningful results, set trigScSamp between -1 and (nSamp-1).
nSamp is the number of samples in one data acquisition cycle for the
triggering scope. If you specify too large a value, the scope is never
triggered.
If you want to trigger a second scope at the end of a data acquisition
cycle for the triggering scope, enter a value of -1 for trigScSamp.
See Also
API functions xPCGetScopes, xPCScSetTriggerLevel,
xPCScGetTriggerLevel, xPCScSetTriggerSlope,
xPCScGetTriggerSlope, xPCScSetTriggerSignal,
xPCScGetTriggerSignal, xPCScSetTriggerScope,
xPCScGetTriggerScope, xPCScSetTriggerMode,
xPCScGetTriggerMode, xPCScGetTriggerScopeSample
xpctarget.xpcsc Class properties TriggerMode, TriggerSample
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-147
xPCScSetTriggerSignal
Purpose
Select signal to trigger scope
Prototype
void xPCScSetTriggerSignal(int port, int
scNum, int trigSig);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
trigSig
Enter a signal number.
Description
The xPCScSetTriggerSignal function sets the trigger signal of scope
scNum to trigSig. The trigger signal trigSig must be one of the
signals in the scope. Use this function only when the scope is stopped.
You can use xPCScGetSignals to get the list of signals in the scope. Use
xPCScGetState to check the state of the scope. Use the xPCGetScopes
function to get a list of scopes.
See Also
API functions xPCGetScopes, xPCScGetState, xPCScSetTriggerLevel,
xPCScGetTriggerLevel, xPCScSetTriggerSlope,
xPCScGetTriggerSlope, xPCScGetTriggerSignal,
xPCScSetTriggerScope, xPCScGetTriggerScope,
xPCScSetTriggerMode, xPCScGetTriggerMode
xpctarget.xpcsc Class property TriggerSignal
7-148
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScSetTriggerSlope
Purpose
Set slope of signal that triggers scope
Prototype
void xPCScSetTriggerSlope(int port, int scNum,
int trigSlope);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
trigSlope
Enter the slope mode for the signal that triggers the
scope.
The xPCScSetTriggerSlope function sets the trigger slope of scope
scNum to trigSlope. Use this function only when the scope is
stopped. Use xPCScGetState to check the state of the scope. Use the
xPCGetScopes function to get a list of scopes.
Use the constants defined in xpcapiconst.h to set the trigger slope:
Constant
Value
Description
TRIGSLOPE_EITHER
0
The trigger slope can be either
rising or falling.
TRIGSLOPE_RISING
1
The trigger signal value must be
rising when it crosses the trigger
value.
TRIGSLOPE_FALLING
2
The trigger signal value must be
falling when it crosses the trigger
value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-149
xPCScSetTriggerSlope
See Also
API functions xPCGetScopes, xPCScSetTriggerLevel,
xPCScGetTriggerLevel, xPCScGetTriggerSlope,
xPCScSetTriggerSignal, xPCScGetTriggerSignal,
xPCScSetTriggerScope, xPCScGetTriggerScope,
xPCScSetTriggerMode, xPCScGetTriggerMode, xPCScGetState
xpctarget.xpcsc Class property TriggerSlope
7-150
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScSoftwareTrigger
Purpose
Set software trigger of scope
Prototype
void xPCScSoftwareTrigger(int port, int scNum);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
The xPCScSoftwareTrigger function triggers scope scNum. The
scope must be in the state Waiting for trigger for this function to
succeed. Use xPCScGetState to check the state of the scope. Use the
xPCGetScopes function to get a list of scopes.
Regardless of the trigger mode setting, you can use
xPCScSoftwareTrigger to force a trigger. In trigger mode
Software, this function is the only way to trigger the scope.
See Also
API functions xPCGetScopes, xPCScGetState, xPCIsScFinished
trigger
xpctarget.xpcsc Class property TriggerMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-151
xPCScStart
Purpose
Start data acquisition for scope
Prototype
void xPCScStart(int port, int scNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Description
The xPCScStart function starts or restarts the data acquisition of scope
scNum. If the scope does not have to preacquire samples, it enters the
Waiting for Trigger state. The scope must be in state Waiting to
Start, Finished, or Interrupted for this function to succeed. Call
xPCScGetState to check the state of the scope or, for host scopes that
are already started, call xPCIsScFinished. Use the xPCGetScopes
function to get a list of scopes.
See Also
API functions xPCGetScopes, xPCScGetState, xPCScStop,
xPCIsScFinished
Scope object method start (scope object)
7-152
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScStop
Purpose
Stop data acquisition for scope
Prototype
void xPCScStop(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Description
The xPCScStop function stops the scope scNum. This sets the scope to
the "Interrupted" state. The scope must be running for this function
to succeed. Use xPCScGetState to determine the state of the scope. Use
the xPCGetScopes function to get a list of scopes.
See Also
API functions xPCGetScopes, xPCScStart, xPCScGetState
Scope object method stop (scope object)
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-153
xPCSetEcho
Purpose
Turn message display on or off
Prototype
void xPCSetEcho(int port, int mode);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
mode
Valid values are
0
Turns the display off
1
Turns the display on
Description
On the target computer screen, the xPCSetEcho function sets the
message display on the target computer on or off. You can change the
mode only when the target application is stopped. When you turn the
message display off, the message screen no longer updates. Existing
messages remain on the screen as they were.
See Also
API function xPCGetEcho
7-154
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSetLastError
Purpose
Set last error to specific string constant
Prototype
void xPCSetLastError(int error);
Arguments
error
Specify the string constant for the error.
Description
The xPCSetLastError function sets the global error constant returned
by xPCGetLastError to error. This is useful only to set the string
constant to ENOERR, indicating no error was found.
See Also
API functions xPCGetLastError, xPCErrorMsg
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-155
xPCSetLoadTimeOut
Purpose
Change initialization timeout value between host computer and target
computer
Prototype
void xPCSetLoadTimeOut(int port, int timeOut);
Arguments
Description
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
timeOut
Enter the new communication timeout value.
The xPCSetLoadTimeOut function changes the timeout value for
communication between the host computer and target computer.
The timeOut value is the time an xPC Target API function waits for
the communication between the host computer and target computer
to complete before returning. It enables you to set the number of
communication attempts to be made before signaling a timeout.
For example, the function xPCLoadApp waits to check whether the
model initialization for a new application is complete before returning.
When a new target application is loaded onto the target computer,
the function xPCLoadApp waits for a certain time to check whether
the model initialization is complete before returning. If the model
initialization is incomplete within the allotted time, xPCLoadApp returns
a timeout error.
By default, xPCLoadApp checks for target readiness for up to 5 seconds.
However, for larger models or models requiring longer initialization (for
example, models with thermocouple boards), the default might not be
long enough and a spurious timeout can be generated. Other functions
that communicate with the target computer will wait for timeOut
seconds before declaring a timeout event.
See Also
7-156
API functions xPCGetLoadTimeOut, xPCLoadApp, xPCUnloadApp
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSetLogMode
Purpose
Set logging mode and increment value of scope
Prototype
void xPCSetLogMode(int port, lgmode logging_data);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
logging_data
Logging mode and increment value.
Description
The xPCSetLogMode function sets the logging mode and increment to the
values set in logging_data. See the structure lgmode for more details.
See Also
API function xPCGetLogMode
API structure lgmode
xpctarget.xpc Class property LogMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-157
xPCSetParam
Purpose
Change value of parameter
Prototype
void xPCSetParam(int port, int paramIdx, const
double *paramValue);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
paramIdx
Parameter index.
paramValue
Vector of doubles, assumed to be the size required
by the parameter type
Description
The xPCSetParam function sets the parameter paramIdx to the
value in paramValue. For matrices, paramValue should be a vector
representation of the matrix in column-major format. Although
paramValue is a vector of doubles, the function converts the values to
the expected data types (using truncation) before setting them.
See Also
API functions xPCGetParamDims, xPCGetParamIdx, xPCGetParam
7-158
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSetSampleTime
Purpose
Change target application sample time
Prototype
void xPCSetSampleTime(int port, double ts);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
ts
Sample time for the target application.
Description
The xPCSetSampleTime function sets the sample time, in seconds, of the
target application to ts. Use this function only when the application
is stopped.
See Also
API function xPCGetSampleTime
xpctarget.xpc Class property SampleTime
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-159
xPCSetScope
Purpose
Set properties of scope
Prototype
void xPCSetScope(int port, scopedata state);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
state
Enter a structure of type scopedata.
Note The xPCSetScope function will be removed in a future release.
Use the xPCScSetScopePropertyName functions to access property
values instead. For example, to set the number of samples to acquire in
one data acquisition cycle, use xPCScSetNumSamples.
The xPCSetScope function sets the properties of a scope using a state
structure of type scopedata. Set the properties you want to set for the
scope. You can set several properties at the same time. For convenience,
call the function xPCGetScope first to populate the structure with
the current values. You can then change the desired values. Use
this function only when the scope is stopped. Use xPCScGetState to
determine the state of the scope.
See Also
API functions xPCGetScope, xPCScGetState, scopedata
Scope object method set (scope object)
7-160
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCSetStopTime
Purpose
Change target application stop time
Prototype
void xPCSetStopTime(int port, double tfinal);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
tfinal
Enter the stop time, in seconds.
Description
The xPCSetStopTime function sets the stop time of the target
application to the value in tfinal. The target application will run for
this number of seconds before stopping. Set tfinal to -1.0 to set the
stop time to infinity.
See Also
API function xPCGetStopTime
xpctarget.xpc Class property StopTime
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-161
xPCStartApp
Purpose
Start target application
Prototype
void xPCStartApp(int port);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
Description
The xPCStartApp function starts the target application loaded on the
target machine.
See Also
API function xPCStopApp
Target object method start (target application object)
7-162
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCStopApp
Purpose
Stop target application
Prototype
void xPCStopApp(int port);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
Description
The xPCStopApp function stops the target application loaded on the
target computer. The target application remains loaded and the
parameter changes you made remain intact. If you want to stop and
unload an application, use xPCUnloadApp.
See Also
API functions xPCStartApp, xPCUnloadApp
Target object method stop (target application object)
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-163
xPCTargetPing
Purpose
Ping target computer
Prototype
int xPCTargetPing(int port);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
Return
The xPCTargetPing function does not return an error status. This
function returns 1 if the target responds. If the target computer does
not respond, the function returns 0.
Description
The xPCTargetPing function pings the target computer and returns 1
or 0 depending on whether the target responds or not. This function
returns an error string constant only when there is an error in the input
parameter (for example, the port number is invalid or port is not open).
Other errors, such as the inability to connect to the target, are ignored.
If you are using TCP/IP, note that xPCTargetPing will cause the
target computer to close the TCP/IP connection. You can use
xPCOpenConnection to reconnect. You can also use this xPCTargetPing
feature to close the target computer connection in the event of an
aborted TCP/IP connection (for example, if your host side program
crashes).
See Also
7-164
API functions xPCOpenConnection, xPCOpenSerialPort,
xPCOpenTcpIpPort, xPCClosePort
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTgScGetGrid
Purpose
Get status of grid line for particular scope
Prototype
int xPCTgScGetGrid(int port, int scNum);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Return
Returns the status of the grid for a scope of type SCTYPE_TARGET. If the
function detects an error, it returns -1.
Description
The xPCTgScGetGrid function gets the state of the grid lines for scope
scNum (which must be of type SCTYPE_TARGET). A return value of 1
implies grid on, while 0 implies grid off. Note that when the scope mode
is set to SCMODE_NUMERICAL, the grid is not drawn even when the grid
mode is set to 1.
Tip
• Use xPCTgScSetMode and xPCTgScGetMode to set and retrieve the
scope mode.
• Use xPCGetScopes to get a list of scopes.
See Also
API functions xPCGetScopes, xPCTgScSetGrid, xPCTgScSetViewMode,
xPCTgScGetViewMode, xPCTgScSetMode, xPCTgScGetMode,
xPCTgScSetYLimits, xPCTgScGetYLimits
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-165
xPCTgScGetMode
Purpose
Get scope mode for displaying signals
Prototype
int xPCTgScGetMode(int port, int scNum);
Arguments
Return
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
The xPCTgScGetMode function returns the value corresponding to the
scope mode. The possible values are
• SCMODE_NUMERICAL = 0
• SCMODE_REDRAW = 1
• SCMODE_SLIDING = 2
• SCMODE_ROLLING = 3
If this function detects an error, it returns -1.
Description
The xPCTgScGetMode function gets the mode (SCMODE_NUMERICAL,
SCMODE_REDRAW, SCMODE_SLIDING, SCMODE_ROLLING) of the scope scNum,
which must be of type SCTYPE_TARGET. Use the xPCGetScopes function
to get a list of scopes.
See Also
API functions xPCGetScopes, xPCTgScSetGrid, xPCTgScGetGrid,
xPCTgScSetViewMode, xPCTgScGetViewMode, xPCTgScSetMode,
xPCTgScSetYLimits, xPCTgScGetYLimits
xpctarget.xpcsctg Class property DisplayMode
7-166
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTgScGetViewMode
Purpose
Get view mode for target computer display
Prototype
int xPCTgScGetViewMode(int port);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
Return
The xPCTgScGetViewMode function returns the view mode for the target
computer screen. If the function detects an error, it returns -1.
Description
The xPCTgScGetViewMode function gets the view (zoom) mode for the
target computer display. If the returned value is not zero, the number
is that of the scope currently displayed on the screen. If the value is 0,
then all defined scopes are displayed on the target computer screen, but
no scopes are in focus (all scopes are unzoomed).
See Also
API functions xPCGetScopes, xPCTgScSetGrid, xPCTgScGetGrid,
xPCTgScSetViewMode, xPCTgScSetMode, xPCTgScGetMode,
xPCTgScSetYLimits, xPCTgScGetYLimits
xpctarget.xpc Class property ViewMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-167
xPCTgScGetYLimits
Purpose
Copy y-axis limits for scope to array
Prototype
void xPCTgScGetYLimits(int port, int scNum,
double *limits);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
limits
The first element of the array is the lower limit while the
second element is the upper limit.
Description
The xPCTgScGetYLimits function gets and copies the upper and lower
limits for a scope of type SCTYPE_TARGET and with scope number scNum.
The limits are stored in the array limits. If both elements are zero,
the limits are autoscaled. Use the xPCGetScopes function to get a list of
scopes.
See Also
API functions xPCGetScopes, xPCTgScSetGrid, xPCTgScGetGrid,
xPCTgScSetViewMode, xPCTgScGetViewMode, xPCTgScSetMode,
xPCTgScGetMode, xPCTgScSetYLimits
xpctarget.xpcsctg Class property Ylimit
7-168
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTgScSetGrid
Purpose
Set grid mode for scope
Prototype
void xPCTgScSetGrid(int port, int scNum, int grid);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
grid
Enter a grid value.
Description
The xPCTgScSetGrid function sets the grid of a scope of type
SCTYPE_TARGET and scope number scNum to grid. If grid is 0, the
grid is off. If grid is 1, the grid is on and grid lines are drawn on
the scope window. When the drawing mode of scope scNum is set to
SCMODE_NUMERICAL, the grid is not drawn even when the grid mode is
set to 1. Use the xPCGetScopes function to get a list of scopes.
See Also
API functions xPCGetScopes, xPCTgScGetGrid, xPCTgScSetViewMode,
xPCTgScGetViewMode, xPCTgScSetMode, xPCTgScGetMode,
xPCTgScSetYLimits, xPCTgScGetYLimits
Scope object property Grid
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-169
xPCTgScSetMode
Purpose
Set display mode for scope
Prototype
void xPCTgScSetMode(int port, int scNum, int mode);
Arguments
Description
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
mode
Enter the value for the mode.
The xPCTgScSetMode function sets the mode of a scope of type
SCTYPE_TARGET and scope number scNum to mode. You can use one of
the following constants for mode:
• SCMODE_NUMERICAL = 0
• SCMODE_REDRAW = 1
• SCMODE_SLIDING = 2
• SCMODE_ROLLING = 3
Use the xPCGetScopes function to get a list of scopes.
See Also
API functions xPCGetScopes, xPCTgScSetGrid, xPCTgScGetGrid,
xPCTgScSetViewMode, xPCTgScGetViewMode, xPCTgScGetMode,
xPCTgScSetYLimits, xPCTgScGetYLimits
xpctarget.xpcsctg Class property DisplayMode
7-170
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTgScSetViewMode
Purpose
Set view mode for scope
Prototype
void xPCTgScSetViewMode(int port, int scNum);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
scNum
Enter the scope number.
Description
The xPCTgScSetViewMode function sets the target computer screen
to display one scope with scope number scNum. If you set scNum to 0,
the target computer screen displays all the defined scopes. Use the
xPCGetScopes function to get a list of scopes.
See Also
API functions xPCGetScopes, xPCTgScSetGrid, xPCTgScGetGrid,
xPCTgScGetViewMode, xPCTgScSetMode, xPCTgScGetMode,
xPCTgScSetYLimits, xPCTgScGetYLimits
xpctarget.xpc Class property ViewMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-171
xPCTgScSetYLimits
Purpose
Set y-axis limits for scope
Prototype
void xPCTgScSetYLimits(int port, int scNum, const
double *Ylimits);
Arguments
port
Enter the value returned by either the function
xPCOpenSerialPort or the function xPCOpenTcpIpPort.
scNum
Enter the scope number.
Ylimits Enter a two-element array.
Description
The xPCTgScSetYLimits function sets the y-axis limits for a scope
with scope number scNum and type SCTYPE_TARGET to the values in
the double array Ylimits. The first element is the lower limit, and
the second element is the upper limit. Set both limits to 0.0 to specify
autoscaling. Use the xPCGetScopes function to get a list of scopes.
See Also
API functions xPCGetScopes, xPCTgScSetGrid, xPCTgScGetGrid,
xPCTgScSetViewMode, xPCTgScGetViewMode, xPCTgScSetMode,
xPCTgScGetMode, xPCTgScGetYLimits
xpctarget.xpcsctg Class property Ylimit
7-172
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCUnloadApp
Purpose
Unload target application
Prototype
void xPCUnloadApp(int port);
Arguments
port
Enter the value returned by either the
function xPCOpenSerialPort or the function
xPCOpenTcpIpPort.
Description
The xPCUnloadApp function stops the current target application,
removes it from the target computer memory, and resets the target
computer in preparation for receiving a new target application. The
function xPCLoadApp calls this function before loading a new target
application.
See Also
API function xPCLoadApp
Target object methods xpctarget.xpc.load, xpctarget.xpc.unload
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
7-173
‫‪xPCUnloadApp‬‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫‪7-174‬‬
8
xPC Target API Reference
for COM
• “COM API Methods” on page 8-2
• “COM API Methods — Alphabetical List” on page 8-9
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8
xPC Target™ API Reference for COM
COM API Methods
In this section...
“Target Computers” on page 8-2
“Target Applications” on page 8-3
“Scopes” on page 8-4
“Parameters” on page 8-6
“Signals” on page 8-6
“Data Logs” on page 8-7
“File Systems” on page 8-7
“Errors” on page 8-8
Note The xPC Target COM API is no longer being enhanced. You should use
the xPC Target API for Microsoft .NET Framework instead. See “xPC Target
API for Microsoft .NET Framework” on page 1-3
Target Computers
8-2
xPCProtocol.Close
Close RS-232 or TCP/IP
communication connection
xPCProtocol.GetLoadTimeOut
Return current timeout value for
target application initialization
xPCProtocol.Init
Initialize xPC Target API DLL
xPCProtocol.Port
Contain communication channel
index
xPCProtocol.Reboot
Reboot target computer
xPCProtocol.RS232Connect
Open RS-232 connection to target
computer
xPCProtocol.SetLoadTimeOut
Change initialization timeout value
xPCProtocol.TargetPing
Ping target computer
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
COM API Methods
xPCProtocol.TcpIpConnect
Open TCP/IP connection to target
computer
xPCProtocol.Term
Unload xPC Target API DLL from
memory
xPCTarget.UnLoadApp
Unload target application
Target Applications
xPCTarget.AverageTET
Get average task execution time
xPCTarget.GetAppName
Get target application name
xPCTarget.GetExecTime
Get execution time for target
application
xPCTarget.GetNumOutputs
Get number of outputs
xPCTarget.GetSampleTime
Get sample time
xPCTarget.GetStopTime
Get stop time
xPCTarget.Init
Initialize target object to
communicate with target computer
xPCTarget.IsAppRunning
Return running status for target
application
xPCTarget.IsOverloaded
Return overload status for target
computer
xPCTarget.MaximumTET
Copy maximum task execution time
to array
xPCTarget.MaxLogSamples
Return maximum number of samples
that can be in log buffer
xPCTarget.MinimumTET
Copy minimum task execution time
to array
xPCTarget.NumLogSamples
Return number of samples in log
buffer
xPCTarget.NumLogWraps
Return number of times log buffer
wraps
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-3
8
xPC Target™ API Reference for COM
xPCTarget.SetSampleTime
Change sample time for target
application
xPCTarget.SetStopTime
Change stop time of target
application
xPCTarget.StartApp
Start target application
xPCTarget.StopApp
Stop target application
Scopes
xPCScopes.AddFileScope
Create new file scope
xPCScopes.AddHostScope
Create new host scope
xPCScopes.AddTargetScope
Create new target scope
xPCScopes.GetScopes
Get and copy list of scope numbers
xPCScopes.Init
Initialize scope object to
communicate with target computer
xPCScopes.IsScopeFinished
Get data acquisition status for scope
xPCScopes.RemScope
Remove scope
xPCScopes.ScopeAddSignal
Add signal to scope
xPCScopes.ScopeGetAutoRestart
Scope autorestart value
xPCScopes.ScopeGetData
Copy scope data to array
xPCScopes.ScopeGetDecimation
Get decimation of scope
xPCScopes.ScopeGetNumPrePostSamples
Get number of pre- or posttriggering
samples before triggering scope
8-4
xPCScopes.ScopeGetNumSamples
Get number of samples in one data
acquisition cycle
xPCScopes.ScopeGetSignals
Get list of signals
xPCScopes.ScopeGetStartTime
Get last data acquisition cycle start
time
xPCScopes.ScopeGetState
Get state of scope
xPCScopes.ScopeGetTriggerLevel
Get trigger level for scope
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
COM API Methods
xPCScopes.ScopeGetTriggerMode
Get trigger mode for scope
xPCScopes.ScopeGetTriggerModeStr Get trigger mode as string
xPCScopes.ScopeGetTriggerSample
Get sample number for triggering
scope
xPCScopes.ScopeGetTriggerSignal
Get trigger signal for scope
xPCScopes.ScopeGetTriggerSlope
Get trigger slope for scope
xPCScopes.ScopeGetTriggerSlopeStr Get trigger slope as string
xPCScopes.ScopeGetType
Get type of scope
xPCScopes.ScopeRemSignal
Remove signal from scope
xPCScopes.ScopeSetAutoRestart
Scope autorestart value
xPCScopes.ScopeSetDecimation
Set decimation of scope
xPCScopes.ScopeSetNumPrePostSamples
Set number of pre- or posttriggering
samples before triggering scope
xPCScopes.ScopeSetNumSamples
Set number of samples in one data
acquisition cycle
xPCScopes.ScopeSetTriggerLevel
Set trigger level for scope
xPCScopes.ScopeSetTriggerMode
Set trigger mode of scope
xPCScopes.ScopeSetTriggerSample
Set sample number for triggering
scope
xPCScopes.ScopeSetTriggerSignal
Select signal to trigger scope
xPCScopes.ScopeSetTriggerSlope
Set slope of signal that triggers scope
xPCScopes.ScopeSoftwareTrigger
Set software trigger of scope
xPCScopes.ScopeStart
Start data acquisition for scope
xPCScopes.ScopeStop
Stop data acquisition for scope
xPCScopes.TargetScopeGetGrid
Get status of grid line for particular
scope
xPCScopes.TargetScopeGetMode
Get scope mode for displaying
signals
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-5
8
xPC Target™ API Reference for COM
xPCScopes.TargetScopeGetModeStr
Get scope mode string for displaying
signals
xPCScopes.TargetScopeGetViewMode Get view mode for target computer
display
xPCScopes.TargetScopeGetYLimits
Get y-axis limits for scope
xPCScopes.TargetScopeSetGrid
Set grid mode for scope
xPCScopes.TargetScopeSetMode
Set display mode for scope
xPCScopes.TargetScopeSetViewMode Set view mode for scope
xPCScopes.TargetScopeSetYLimits
Set y-axis limits for scope
Parameters
xPCTarget.GetNumParams
Get number of tunable parameters
xPCTarget.GetParam
Get parameter values
xPCTarget.GetParamDims
Get row and column dimensions of
parameter
xPCTarget.GetParamIdx
Get parameter index
xPCTarget.GetParamName
Get parameter name
xPCTarget.SetParam
Change parameter value
Signals
8-6
xPCTarget.GetNumSignals
Get number of signals
xPCTarget.GetSignal
Get signal value
xPCTarget.GetSignalidsfromLabel
Get signal IDs from signal label
xPCTarget.GetSignalIdx
Get signal index
xPCTarget.GetSignalLabel
Get signal label
xPCTarget.GetSignalName
Copy signal name to character array
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
COM API Methods
xPCTarget.GetSignals
Get vector of signal values
xPCTarget.GetSignalWidth
Get width of signal
Data Logs
xPCTarget.GetNumStates
Get number of states
xPCTarget.GetOutputLog
Copy output log data to array
xPCTarget.GetStateLog
Get state log
xPCTarget.GetTETLog
Get TET log
xPCTarget.GetTimeLog
Get time log
File Systems
FSDir
Type definition for file system folder
information structure
FSDiskInfo
Type definition for file system disk
information structure
xPCFileSystem.CD
Change current folder on target
computer to specified path
xPCFileSystem.CloseFile
Close file on target computer
xPCFileSystem.DirList
Return contents of target computer
folder
xPCFileSystem.GetDiskInfo
Return disk information
xPCFileSystem.GetFileSize
Return size of file on target computer
xPCFileSystem.Init
Initialize file system object to
communicate with target computer
xPCFileSystem.MKDIR
Create folder on target computer
xPCFileSystem.OpenFile
Open file on target computer
xPCFileSystem.PWD
Get current folder of target computer
xPCFileSystem.ReadFile
Read open file on target computer
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-7
8
xPC Target™ API Reference for COM
xPCFileSystem.RemoveFile
Remove file from target computer
xPCFileSystem.RMDIR
Remove folder from target computer
xPCFileSystem.ScGetFileName
Get name of file for scope
xPCFileSystem.ScGetWriteMode
Get write mode of file for scope
xPCFileSystem.ScGetWriteSize
Get block write size of data chunks
xPCFileSystem.ScSetFileName
Specify file name to contain signal
data
xPCFileSystem.ScSetWriteMode
Specify when file allocation table
entry is updated
xPCFileSystem.ScSetWriteSize
Specify that memory buffer collect
data in multiples of write size
xPCFileSystem.WriteFile
Write to file on target computer
Errors
8-8
xPCProtocol.GetxPCErrorMsg
Return error string
xPCProtocol.isxPCError
Return error status
xPCScopes.GetxPCError
Get error string
xPCScopes.isxPCError
Get error status
xPCTarget.GetxPCError
Get error string
xPCTarget.isxPCError
Return error status
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
COM API Methods — Alphabetical List
COM API Methods — Alphabetical List
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-9
FSDir
Purpose
Type definition for file system folder information structure
Syntax
typedef struct {
BSTR Name;
BSTR Date;
BSTR Time;
long Bytes;
long isdir;
} FSDir;
Fields
8-10
Name
This value contains the name of the file or
folder.
Date
This value contains the date the file or folder
was last modified.
Time
This value contains the time the file or folder
was last modified.
Bytes
This value contains the size of the file in
bytes. If the element is a folder, this value
is 0.
isdir
This value indicates if the element is a file
(0) or folder (1). If it is a folder, Bytes has a
value of 0.
Description
The FSDir structure contains information for a folder in the file system.
See Also
API methodxPCFileSystem.DirList
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
FSDiskInfo
Purpose
Type definition for file system disk information structure
Syntax
typedef struct {
BSTR Label;
BSTR DriveLetter;
BSTR Reserved;
long SerialNumber;
long FirstPhysicalSector;
long FATType;
long FATCount;
long MaxDirEntries;
long BytesPerSector;
long SectorsPerCluster;
long TotalClusters;
long BadClusters;
long FreeClusters;
long Files;
long FileChains;
long FreeChains;
long LargestFreeChain;
} FSDiskInfo;
Fields
Label
This value contains the zero-terminated
string that contains the volume label. The
string is empty if the volume has no label.
DriveLetter
This value contains the drive letter, in
uppercase.
Reserved
Reserved.
SerialNumber
This value contains the volume serial
number.
FirstPhysicalSector This value contains the logical block address
(LBA) of the logical drive boot record. For
3.5-inch disks, this value is 0.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-11
FSDiskInfo
8-12
FATType
This value contains the type of file system
found. It can contain 12 , 16 , or 32 for
FAT-12, FAT-16, or FAT-32 volumes,
respectively.
FATCount
This value contains the number of FAT
partitions on the volume.
MaxDirEntries
This value contains the size of the root folder.
For FAT-32 systems, this value is 0.
BytesPerSector
This value contains the sector size. This
value is most likely to be 512.
SectorsPerCluster
This value contains, in sectors, the size of the
smallest unit of storage that can be allocated
to a file.
TotalClusters
This value contains the number of file storage
clusters on the volume.
BadClusters
This value contains the number of clusters
that have been marked as bad. These clusters
are unavailable for file storage.
FreeClusters
This value contains the number of clusters
that are currently available for storage.
Files
This value contains the number of files,
including folders, on the volume. This
number excludes the root folder and files that
have an allocated file size of 0.
FileChains
This value contains the number of contiguous
cluster chains. On a completely unfragmented
volume, this value is identical to the value
of Files.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
FSDiskInfo
FreeChains
This value contains the number of contiguous
cluster chains of free clusters. On a
completely unfragmented volume, this value
is 1.
LargestFreeChain
This value contains the maximum allocated
file size, in number of clusters, for a newly
allocated contiguous file. On a completely
unfragmented volume, this value is identical
to FreeClusters.
Description
The FSDiskInfo structure contains information for file system disks.
See Also
API method xPCFileSystem.GetDiskInfo
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-13
xPCFileSystem.CD
Purpose
Change current folder on target computer to specified path
Prototype
long CD(BSTR dir);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
8-14
[in] dir
Enter the path on the target computer to change to.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.CD method changes the current folder on the target
computer to the path specified in dir. Use the xPCFileSystem.PWD
method to show the current folder of the target computer.
See Also
API method xPCFileSystem.PWD
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.CloseFile
Purpose
Close file on target computer
Prototype
CloseFile(long filehandle);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] filehandle
Enter the file handle of an open file on the
target computer.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.CloseFile method closes the file associated with
fileHandle on the target computer. fileHandle is the handle of a file
previously opened by the xPCFileSystem.OpenFile method.
See Also
API methods xPCFileSystem.OpenFile, xPCFileSystem.ReadFile,
xPCFileSystem.WriteFile
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-15
xPCFileSystem.DirList
Purpose
Return contents of target computer folder
Prototype
DirList(BSTR path);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] path
Enter the path of the folder.
Description
The xPCFileSystem.DirList method returns the contents of the target
computer folder specified by path as an array of the FSDir structure.
See Also
API structure FSDir
API method xPCFileSystem.GetDiskInfo
8-16
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.GetDiskInfo
Purpose
Return disk information
Prototype
GetDiskInfo(BSTR driveLetter);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] driveLetter
Enter the driver letter that contains the file
system.
Description
The xPCFileSystem.GetDiskInfo method accepts as input the drive
specified by driveLetter and fills in the fields of the FSDiskInfo
structure.
See Also
API structure FSDiskInfo
API method xPCFileSystem.DirList
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-17
xPCFileSystem.GetFileSize
Purpose
Return size of file on target computer
Prototype
long GetFileSize(long filehandle);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
8-18
[in] filehandle
Enter the file handle of an open file on the
target computer.
Return
This method returns the size of the specified file in bytes.
Description
The xPCFileSystem.GetFileSize method returns the size, in bytes,
of the file associated with filehandle on the target computer.
filehandle is the handle of a file previously opened by the
xPCFileSystem.OpenFile method.
See Also
API methods xPCFileSystem.OpenFile, xPCFileSystem.ReadFile
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.Init
Purpose
Initialize file system object to communicate with target computer
Prototype
long Init(IxPCProtocol* xPCProtocol);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] xPCProtocol
Specify the communication port of the target
computer object for which the file system is
to be initialized.
Return
If the method detects an error, it returns -1. Otherwise, the
xPCFileSystem.Init method returns 0.
Description
The xPCFileSystem.Init method initializes the file system object to
communicate with the target computer referenced by the xPCProtocol
object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-19
xPCFileSystem.MKDIR
Purpose
Create folder on target computer
Prototype
long MKDIR(BSTR dirname);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
8-20
[in] dirname
Enter the name of the folder to create on the
target computer.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.MKDIR method creates the folder dirname in the
current folder of the target computer.
See Also
API method xPCFileSystem.PWD
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.OpenFile
Purpose
Open file on target computer
Prototype
long OpenFile(BSTR filename, BSTR permission);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] filename
Enter the name of the file to open on the
target computer.
[in] permission
Enter the read/write permission with which
to open the file. Values are r (read) or w
(read/write).
Return
The xPCFileSystem.OpenFile method returns the file handle for the
opened file.
Description
The xPCFileSystem.OpenFile method opens the specified file,
filename, on the target computer. If the file does not exist, the
xPCFileSystem.OpenFile method creates filename, then opens it. You
can open a file for read or read/write access.
Note Opening the file for write access overwrites the existing contents
of the file. It does not append the new data.
See Also
API methods xPCFileSystem.CloseFile,
xPCFileSystem.GetFileSize, xPCFileSystem.ReadFile,
xPCFileSystem.WriteFile
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-21
xPCFileSystem.PWD
8-22
Purpose
Get current folder of target computer
Prototype
BSTR PWD();
Member
Of
XPCAPICOMLib.xPCFileSystem
Return
This method returns the path of the current folder on the target
computer.
Description
The xPCFileSystem.PWD method places the path of the current folder
on the target computer.
See Also
API method xPCFileSystem.CD
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.ReadFile
Purpose
Read open file on target computer
Prototype
VARIANT ReadFile(int fileHandle, int start, int numbytes);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] fileHandle
Enter the file handle of an open file on the
target computer.
[in] start
Enter an offset from the beginning of the file
from which this method can start to read.
[in] numbytes
Enter the number of bytes this method is to
read from the file.
Return
This method returns the results of the read operation as a VARIANT of
type Byte. If the method detects an error, it returns VT_ERROR, whose
value is 10, instead.
Description
The xPCFileSystem.ReadFile method reads an open file on the target
computer and returns the results of the read operation as a VARIANT
of type Byte. fileHandle is the file handle of a file previously opened
by xPCFileSystem.OpenFile. You can specify that the read operation
begin at the beginning of the file (default) or at a certain offset into the
file (start). The numbytes parameter specifies how many bytes the
xPCFileSystem.ReadFile method is to read from the file.
See Also
API methods xPCFileSystem.CloseFile,
xPCFileSystem.GetFileSize, xPCFileSystem.OpenFile,
xPCFileSystem.WriteFile
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-23
xPCFileSystem.RemoveFile
Purpose
Remove file from target computer
Prototype
long RemoveFile(BSTR filename);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
8-24
[in] filename
Enter the name of a file on the target
computer.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.RemoveFile method removes the file named
filename from the target computer file system. filename can be a
relative or absolute path name on the target computer.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.RMDIR
Purpose
Remove folder from target computer
Prototype
long RMDIR(BSTR dirname);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] dirname
Enter the name of a folder on the target
computer.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.RMDIR method removes a folder named dirname
from the target computer file system. dirname can be a relative or
absolute path name on the target computer.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-25
xPCFileSystem.ScGetFileName
Purpose
Get name of file for scope
Prototype
BSTR ScGetFileName(long scNum);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
8-26
[in] scNum
Enter the scope number.
Return
Returns the name of the file for the scope.
Description
The xPCFileSystem.ScGetFileName method returns the name of the
file to which scope scNum will save signal data.
See Also
API method xPCFileSystem.ScSetFileName
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.ScGetWriteMode
Purpose
Get write mode of file for scope
Prototype
long ScGetWriteMode(long scNum);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
Return
[in] scNum
Enter the scope number.
This method returns the number indicating the write mode. Values are
0
Lazy mode. The FAT entry is updated only when the file is
closed and not during each file write operation. This mode
is faster, but if the system crashes before the file is closed,
the file system might not have the actual file size (the file
contents, however, will be intact).
1
Commit mode. Each file write operation simultaneously
updates the FAT entry for the file. This mode is slower, but
the file system maintains the actual file size.
Description
The xPCFileSystem.ScGetWriteMode method returns the write mode
of the file for the scope.
See Also
API method xPCFileSystem.ScSetWriteMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-27
xPCFileSystem.ScGetWriteSize
Purpose
Get block write size of data chunks
Prototype
long ScGetWriteSize(long scNum);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
8-28
[in] scNum
Enter the scope number.
Return
This method returns the block size, in bytes, of the data chunks.
Description
The xPCFileSystem.ScGetWriteSize method gets the block size, in
bytes, of the data chunks.
See Also
API method xPCFileSystem.ScSetWriteSize
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.ScSetFileName
Purpose
Specify file name to contain signal data
Prototype
long ScSetFileName(long scNum, BSTR filename);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] scNum
Enter the scope number.
[in] filename
Enter the name of a file to contain the signal
data.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.ScSetFileName method sets the name of the file
to which the scope will save the signal data. The xPC Target software
creates this file in the target computer file system. Note that you can
only call this method when the scope is stopped.
See Also
API method xPCFileSystem.ScGetFileName
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-29
xPCFileSystem.ScSetWriteMode
Purpose
Specify when file allocation table entry is updated
Prototype
long ScSetWriteMode(long scNum, long writeMode);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] scNum
Enter the scope number.
[in] writeMode
Enter an integer for the write mode:
0
Enables lazy write mode
1
Enables commit write mode
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.ScSetWriteMode method specifies when a file
allocation table (FAT) entry is updated. Both modes write the signal
data to the file, as follows:
See Also
0
Lazy mode. The FAT entry is updated only when the file is
closed and not during each file write operation. This mode
is faster, but if the system crashes before the file is closed,
the file system might not have the actual file size (the file
contents, however, will be intact).
1
Commit mode. Each file write operation simultaneously
updates the FAT entry for the file. This mode is slower,
but the file system maintains the actual file size.
API method xPCFileSystem.ScSetWriteMode
Scope object property Mode
8-30
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCFileSystem.ScSetWriteSize
Purpose
Specify that memory buffer collect data in multiples of write size
Prototype
long ScSetWriteSize(long scNum, long writeSize);
Member
Of
XPCAPICOMLib.xPCFileSystem
Arguments
[in] scNum
Enter the scope number.
[in] writeSize
Enter the block size, in bytes, of the data
chunks.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.ScSetWriteSize method specifies that a memory
buffer collect data in multiples of writeSize. By default, this parameter
is 512 bytes, which is the typical disk sector size. Using a block size
that is the same as the disk sector size provides better performance.
writeSize must be a multiple of 512.
See Also
API method xPCFileSystem.ScGetWriteSize
Scope object property WriteSize
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-31
xPCFileSystem.WriteFile
Purpose
Write to file on target computer
Prototype
long WriteFile(long fileHandle, long numbytes,
VARIANT buffer);
Member
Of
Arguments
XPCAPICOMLib.xPCFileSystem
[in] fileHandle
Enter the file handle of an open file on the
target computer.
[in] numbytes
Enter the number of bytes this method is
to write into the file.
[in] buffer
The contents to write to fileHandle are
stored in buffer.
Return
If the method detects an error, it returns -1. Otherwise, the method
returns 0.
Description
The xPCFileSystem.WriteFile method writes the contents of the
VARIANT buffer, of type Byte, to the file specified by fileHandle on
the target computer. The fileHandle parameter is the handle of a
file previously opened by xPCFSOpenFile. numbytes is the number of
bytes to write to the file.
See Also
API methods xPCFileSystem.CloseFile,
xPCFileSystem.GetFileSize, xPCFileSystem.OpenFile,
xPCFileSystem.ReadFile
8-32
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCProtocol.Close
Purpose
Close RS-232 or TCP/IP communication connection
Prototype
long Close();
Member
Of
XPCAPICOMLib.xPCProtocol
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCProtocol.Close method closes the communication channel
opened by xPCProtocol.RS232Connect or xPCProtocol.TcpIpConnect.
Note RS-232 Host-Target communication mode will be removed in a
future release. Use TCP/IP instead.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-33
xPCProtocol.GetLoadTimeOut
Purpose
Return current timeout value for target application initialization
Prototype
long GetLoadTimeOut();
Member
Of
XPCAPICOMLib.xPCProtocol
Return
If the method detects an error, it returns -1. Otherwise, it returns the
number of seconds allowed for the initialization of the target application.
Description
The xPCProtocol.GetLoadTimeOut method returns the number of
seconds allowed for the initialization of the target application.
When you load a new target application onto the target computer, the
method xPCTarget.LoadApp waits for a certain amount of time before
checking to see whether the initialization of the target application is
complete. In the case where initialization of the target application is
not complete, the method xPCTarget.LoadApp returns a timeout error.
By default, xPCTarget.LoadApp checks five times to see whether the
target application is ready, with each attempt taking about 1 second.
However, for larger models or models requiring longer initialization
(for example, those with thermocouple boards), the default might not
be long enough and a spurious timeout is generated. The method
xPCProtocol.SetLoadTimeOutxPCProtocol.SetLoadTimeOut sets the
timeout to a different number.
Use the xPCProtocol.GetLoadTimeOut method if you suspect that the
current number of seconds (the timeout value) is too short. Then use
the xxPCProtocol.SetLoadTimeOut method to set the timeout to a
higher number.
8-34
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCProtocol.GetxPCErrorMsg
Purpose
Return error string
Prototype
BSTR GetxPCErrorMsg();
Member
Of
XPCAPICOMLib.xPCProtocol
Return
If the xPCProtocol.GetxPCErrorMsg method completes without
detecting an error, it returns the string for the last reported error.
Description
The xPCProtocol.GetxPCErrorMsg method returns the string of the
last error reported by another COM API method. This value is reset
every time you call a new method. Therefore, you should check this
constant value immediately after a call to an API COM method. You
can use this method in conjunction with the xPCProtocol.isxPCError
method, which detects that an error has occurred.
See Also
API function xPCProtocol.isxPCError
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-35
xPCProtocol.Init
Purpose
Initialize xPC Target API DLL
Prototype
long Init();
Member
Of
XPCAPICOMLib.xPCProtocol
Return
If the xPC Target DLL, xpcapi.dll loads without causing
xPCProtocol.Init to detect an error, the method returns 0. If
xpcapi.dll fails to load, this method returns -1.
Description
The xPCProtocol.Init method initializes the xPC Target API by
loading the xPC Target DLL, xpcapi.dll, into memory. To load
xpcapi.dll into memory, the method requires that the xpcapi.dll file
be in one of the following folders:
• The folder in which the application is loaded
• The current folder
• The Windows system folder
8-36
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCProtocol.isxPCError
Purpose
Return error status
Prototype
long isxPCError();
Member
Of
XPCAPICOMLIB.xPCProtocol
Return
If an error occurred, the method returns 1. Otherwise, it returns 0.
Description
Use the xPCProtocol.isxPCError method to check for errors that
might occur after a call to the xPCProtocol class methods. If the method
detects that an error occurred, call the xPCProtocol.GetxPCErrorMsg
to get the string for the error.
See Also
API function xPCProtocol.GetxPCErrorMsg
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-37
xPCProtocol.Port
8-38
Purpose
Contain communication channel index
Prototype
long Port();
Member
Of
XPCAPICOMLIB.xPCProtocol
Return
If the method detects an error, it returns a nonpositive number.
Otherwise, it returns a positive number (the communication channel
index).
Description
The xPCProtocol.Port property contains the communication channel
index if connection with the target computer succeeds. Note that you
only need to use this property when working with a model-specific COM
library that you generate from a Simulink model. See “Model-Specific
COM Interface Library (model_nameCOMiface.dll)” on page 4-16.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCProtocol.Reboot
Purpose
Reboot target computer
Prototype
long Reboot();
Member
Of
XPCAPICOMLib.xPCProtocol
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCProtocol.Reboot method reboots the target computer.
This function does not close the connection to the target computer.
You should explicitly close the connection, then reestablish the
connection once the target computer has rebooted. Use the methods
xPCProtocol.RS232Connect or xPCProtocol.TcpIpConnect to
reestablish the connection.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-39
xPCProtocol.RS232Connect
Purpose
Open RS-232 connection to target computer
Prototype
long RS232Connect(long comport, long baudrate);
Member
Of
XPCAPICOMLib.xPCProtocol
Arguments
[in] comport
Index of the COM port to be used (0 is COM1, 1 is
COM2, and so forth).
[in] baudrate
baudrate must be one of the following values: 1200,
2400, 4800, 9600, 19200, 38400, 57600, or 115200.
Return
The xPCProtocol.RS232Connect method returns the port value for the
connection. If the method detects an error, it returns 0. Otherwise, it
returns -1.
Description
The xPCProtocol.RS232Connect method initiates an RS-232
connection to an xPC Target system. It returns the port value for the
connection. Be sure to pass this value to every xPC Target API function
that requires a port value.
If you enter a value of 0 for baudrate, this function sets the baud rate to
the default value (115200).
Note RS-232 Host-Target communication mode will be removed in a
future release. Use TCP/IP instead.
8-40
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCProtocol.SetLoadTimeOut
Purpose
Change initialization timeout value
Prototype
long SetLoadTimeOut(long timeOut);
Member
Of
XPCAPICOMLib.xPCProtocol
Arguments
[in] timeOut
Enter the new initialization timeout value.
Return
If the method detects an error, it returns 0. Otherwise, it
returns -1. To get the string description for the error, use
xPCProtocol.GetxPCErrorMsg.
Description
The xPCProtocol.SetLoadTimeOut method changes the timeout
value for initialization. The timeOut value is the time the method
xPCTarget.LoadApp waits to check whether the model initialization
for a new application is complete before returning. It enables you to
set the number of initialization attempts to be made before signaling
a timeout. When a new target application is loaded onto the target
computer, the method xPCTarget.LoadApp waits for a certain time to
check whether the model initialization is complete before returning.
If the model initialization is incomplete within the allotted time,
xPCTarget.LoadApp returns a timeout error.
By default, xPCTarget.LoadApp checks for target readiness five times,
with each attempt taking approximately 1 second (less if the target
is ready). However, for larger models or models requiring longer
initialization (for example, those with thermocouple boards), the default
might not be long enough and a spurious timeout can be generated.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-41
xPCProtocol.TargetPing
Purpose
Ping target computer
Prototype
long TargetPing;
Member
Of
XPCAPICOMLIB.xPCProtocol
Return
The xPCProtocol.TargetPing method does not return an error
status. This method returns 1 if it reaches the target computer and
the computer responds. If the target computer does not respond, the
method returns 0.
Description
The xPCProtocol.TargetPing method pings the target computer and
returns 1 or 0 depending on whether the target responds or not. Errors
such as the inability to connect to the target are ignored.
If you are using TCP/IP, note that xPCProtocol.TargetPing will
cause the target computer to close the TCP/IP connection. You can
use xPCProtocol.TcpIpConnect to reconnect. You can also use
this xPCProtocol.TargetPing feature to close the target computer
connection in the event of an aborted TCP/IP connection (for example, if
your host side program crashes).
8-42
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCProtocol.TcpIpConnect
Purpose
Open TCP/IP connection to target computer
Prototype
long TcpIpConnect(BSTR TargetIpAddress, BSTR TargetPort);
Member
Of
XPCAPICOMLIB.xPCProtocol
Arguments
[in] TargetIpAddress
Enter the IP address of the target
as a dotted decimal string. For
example, "192.168.0.10".
[in] TargetPort
Enter the associated IP port as a
string. For example, "22222".
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCProtocol.TcpIpConnect method opens a connection to the
TCP/IP location specified by the IP address. Use this integer as the
TargetPort variable in the xPC Target COM API functions that require
a port value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-43
xPCProtocol.Term
8-44
Purpose
Unload xPC Target API DLL from memory
Prototype
long Term();
Member
Of
XPCAPICOMLib.xPCProtocol
Return
The xPCProtocol.Term method always returns -1.
Description
The xPCProtocol.Term method unloads the xPC Target API DLL
(xpcapi.dll) from memory. You must call this method when you want
to terminate your COM API application.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.AddFileScope
Purpose
Create new file scope
Prototype
long AddFileScope(long scNum);
Member
Of
XPCAPICOMLib.xPCScopes
Arguments
[in] scNum
Enter a number for a new scope. Values are 1, 2,
3. . .
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.AddFileScope method creates a new file scope on the
target computer.
Calling the xPCScopes.AddFileScope method with scNum
having the number of an existing scope produces an error. Use
xPCScopes.GetScopes to find the numbers of existing scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-45
xPCScopes.AddHostScope
Purpose
Create new host scope
Prototype
long AddHostScope(long scNum);
Member
Of
XPCAPICOMLib.xPCScopes
Arguments
[in] scNum
Enter a number for a new scope. Values are 1, 2,
3. . .
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.AddHostScope method creates a new host scope on
the target computer.
Calling the xPCScopes.AddHostScope method with scNum
having the number of an existing scope produces an error. Use
xPCScopes.GetScopes to find the numbers of existing scopes.
8-46
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.AddTargetScope
Purpose
Create new target scope
Prototype
long AddTargetScope(long scNum);
Member
Of
XPCAPICOMLib.xPCScopes
Arguments
[in] scNum
Enter a number for a new scope. Values are 1,
2 , 3. . .
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
If the method detects an error, it returns 0. The
xPCScopes.AddTargetScope method creates a new scope on
the target computer.
Calling the xPCScopes.AddTargetScope method with scNum
having the number of an existing scope produces an error. Use
xPCScopes.GetScopes to find the numbers of existing scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-47
xPCScopes.GetScopes
Purpose
Get and copy list of scope numbers
Prototype
VARIANT GetScopes(long size);
Member
Of
XPCAPICOMLib.xPCScopes
Arguments
8-48
[in] size
Specify the size of the VARIANT array returned. This
argument must be greater than MAX_SCOPES-1. The
elements in the array consist of a list of unsorted
integers, terminated by -1.
Return
The xPCScopes.GetScopes method returns a VARIANT array with
elements containing a list of scope numbers from the target application.
Description
The xPCScopes.GetScopes method gets a VARIANT array with elements
containing a list of scope numbers currently defined for the target
application. Specify the size of the VARIANT array returned. This size
must be greater than the maximum number of scopes -1, up to a
maximum of 30 scopes. The elements in the array consist of a list of
unsorted integers, terminated by -1.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.GetxPCError
Purpose
Get error string
Prototype
BSTR GetxPCError();
Member
Of
XPCAPICOMLib.xPCScopes
Return
The xPCScopes.GetxPCError method returns the string for the last
reported error. If the software has not reported an error, this method
returns 0.
Description
The xPCScopes.GetxPCError method gets the string of the last
reported error by another COM API method. This value is reset every
time you call a new method. Therefore, you should check this constant
value immediately after a call to an API COM method. You can use this
method in conjunction with the xPCScopes.isxPCError method, which
detects that an error has occurred.
See Also
API function xPCScopes.isxPCError
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-49
xPCScopes.Init
Purpose
Initialize scope object to communicate with target computer
Prototype
long Init(IxPCProtocol* xPCProtocol);
Member
Of
XPCAPICOMLib.xPCScopes
Arguments
8-50
[in] xPCProtocol
Specify the communication port of the target
computer object for which the scope is to be
initialized.
Return
If the xPCScopes.Init method initializes the scope object without
detecting an error, it returns 0. If the scope object fails to initialize, the
method returns -1.
Description
The xPCScopes.Init method initializes the scope object to communicate
with the target computer referenced by the xPCProtocol object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.IsScopeFinished
Purpose
Get data acquisition status for scope
Prototype
long IsScopeFinished(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
If the method detects an error, it returns -1. If a scope finishes a data
acquisition cycle, this method returns 1. If the scope is in the process of
acquiring data, this method returns 0.
Description
The xPCScopeos.IsScopeFinished method gets a 1 or 0 depending on
whether scope scNum is finished (state of SCST_FINISHED) or not. You
can also call this function for target scopes; however, because target
scopes restart immediately, it is almost impossible to find these scopes
in the finished state.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-51
xPCScopes.isxPCError
8-52
Purpose
Get error status
Prototype
long isxPCError();
Member
Of
XPCAPICOMLIB.xPCScopes
Return
If an error occurred, the method returns 1. Otherwise, it returns 0.
Description
Use the xPCScopes.isxPCError method to check for errors that might
occur after a call to the xPCScopes class methods. If the software
detects that an error occurred, call the xPCScopes.GetxPCError method
to get the string for the error.
See Also
API function xPCScopes.GetxPCError
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.RemScope
Purpose
Remove scope
Prototype
long RemScope(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.RemScope method removes the scope with number
scNum. Attempting to remove a nonexistent scope causes an error. For a
list of existing scopes, use xPCScopes.GetScopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-53
xPCScopes.ScopeAddSignal
Purpose
Add signal to scope
Prototype
long ScopeAddSignal(long scNum, long sigNum);
Member
Of
XPCAPICOMLib.xPCScopes
Arguments
8-54
[in] scNum
Enter the scope number.
[in] sigNum
Enter a signal number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeAddSignal method adds the signal with number
sigNum to the scope scNum. The signal should not already exist in the
scope. You can use xPCScopes.ScopeGetSignals to get a list of the
signals already present. Use the xPCTarget.GetSignalIdx method
to get the signal number.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetAutoRestart
Purpose
Scope autorestart value
Prototype
long ScopeGetAutoRestart(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetAutoRestart method returns the scope
autorestart flag value (1 if enabled, 0 if disabled). If the method detects
an error, it returns -1.
Description
The xPCScopes.ScopeGetAutoRestart method gets the autorestart flag
value for scope scNum. Autorestart flag can be disabled (0) or enabled (1).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-55
xPCScopes.ScopeGetData
Purpose
Copy scope data to array
Prototype
VARIANT ScopeGetData(long scNum, long signal_id,
long start,
long numsamples, long decimation);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-56
[in] scNum
Enter the scope number.
[in] signal_id
Enter a signal number. Enter -1 to get
time stamped data.
[in] start
Enter the first sample from which data
retrieval is to start.
[in] numsamples
Enter the number of samples retrieved
with a decimation of decimation, starting
from the start value.
[in] decimation
Enter a value such that every decimation
sample is retrieved in a scope window.
Return
The xPCScopes.ScopeGetData method returns a VARIANT array with
elements containing the data used in a scope.
Description
The xPCScopes.ScopeGetData method gets the data used in a scope.
Use this function for scopes of type SCTYPE_HOST. The scope must be
either in state Finished or in state Interrupted for the data to be
retrievable. (Use the xPCScopes.ScopeGetState method to check the
state of the scope.) The data must be retrieved one signal at a time. The
calling function determines and allocates the space ahead of time to
store the scope data. Use the method xPCScopes.ScopeGetSignals to
get the list of signals in the scope for signal_id.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetData
To get time stamped data, specify -1 for signal_id. From the output,
you can then get the number of nonzero elements.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-57
xPCScopes.ScopeGetDecimation
Purpose
Get decimation of scope
Prototype
long ScopeGetDecimation(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-58
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetDecimation method returns the decimation
of scope scNum. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetDecimation method gets the decimation of
scope scNum. The decimation is a number, N, meaning every Nth sample
is acquired in a scope window.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetNumPrePostSamples
Purpose
Get number of pre- or posttriggering samples before triggering scope
Prototype
long ScopeGetNumPrePostSamples(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetNumPrePostSamples method returns the
number of samples for pre- or posttriggering for scope scNum. If an
error occurs, this method returns -1.
Description
The xPCScopes.ScopeGetNumPrePostSamples method gets the number
of samples for pre- or posttriggering for scope scNum. A negative number
implies pretriggering, whereas a positive number implies posttriggering
samples.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-59
xPCScopes.ScopeGetNumSamples
Purpose
Get number of samples in one data acquisition cycle
Prototype
long ScopeGetNumSamples(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-60
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetNumSamples method returns the number of
samples in the scope scNum. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetNumSamples method gets the number of
samples in one data acquisition cycle for scope scNum.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetSignals
Purpose
Get list of signals
Prototype
VARIANT ScopeGetSignals(long scNum, long size);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] size
Enter an integer to allocate the number of elements
to be returned in the VARIANT array. This size is
required for the method to copy the list of signals
into the VARIANT array. The maximum number of
signals is 10.
Return
The xPCScopes.ScopeGetSignals method returns a VARIANT array
with elements consisting of the list of signals defined for a scope.
Description
The xPCScopes.ScopeGetSignals method gets the list of signals
defined for scope scNum. You can use the constant MAX_SIGNALS.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-61
xPCScopes.ScopeGetStartTime
Purpose
Get last data acquisition cycle start time
Prototype
double ScopeGetStartTime(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-62
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetStartTime method returns the start time
for the last data acquisition cycle of a scope. If the method detects an
error, it returns -1.
Description
The xPCScopes.ScopeGetStartTime method gets the time at which the
last data acquisition cycle for scope scNum started. This is only valid
for scopes of type SCTYPE_HOST.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetState
Purpose
Get state of scope
Prototype
BSTR ScopeGetState(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetState method returns the state of scope
scNum. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetState method gets the state of scope scNum,
or -1 upon error.
Constants to find the scope state have the following meanings:
Constant
Value
Description
SCST_WAITTOSTART
0
Scope is ready and waiting to
start.
SCST_PREACQUIRING
5
Scope acquires a predefined
number of samples before
triggering.
SCST_WAITFORTRIG
1
After a scope is finished with
the preacquiring state, it waits
for a trigger. If the scope does
not preacquire data, it enters
the wait for trigger state.
SCST_ACQUIRING
2
Scope is acquiring data. The
scope enters this state when
it leaves the wait for trigger
state.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-63
xPCScopes.ScopeGetState
8-64
Constant
Value
Description
SCST_FINISHED
3
Scope is finished acquiring
data when it has attained the
predefined limit.
SCST_INTERRUPTED
4
The user has stopped
(interrupted) the scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetTriggerLevel
Purpose
Get trigger level for scope
Prototype
double ScopeGetTriggerLevel(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetTriggerLevel method returns the scope
trigger level. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetTriggerLevel method gets the trigger level
for scope scNum.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-65
xPCScopes.ScopeGetTriggerMode
Purpose
Get trigger mode for scope
Prototype
long ScopeGetTriggerMode(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-66
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetTriggerMode method returns the scope
trigger mode. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetTriggerMode method gets the trigger mode
for scope scNum. Use the constants here to interpret the trigger mode:
Constant
Value
Description
TRIGMD_FREERUN
0
There is no trigger mode. The
scope triggers when it is ready
to trigger, regardless of the
circumstances.
TRIGMD_SOFTWARE
1
Only user intervention can
trigger the scope. No other
triggering is possible.
TRIGMD_SIGNAL
2
The scope is triggered only
after a signal has crossed a
value.
TRIGMD_SCOPE
3
The scope is triggered by
another scope at the trigger
point of the triggering scope,
modified by the value of
triggerscopesample (see
scopedata).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetTriggerMode
See Also
API function xPCScopes.ScopeGetTriggerModeStr
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-67
xPCScopes.ScopeGetTriggerModeStr
Purpose
Get trigger mode as string
Prototype
BSTR ScopeGetTriggerModeStr(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
Enter the scope number.
Return
The xPCScopes.ScopeGetTriggerModeStr method returns a string
containing the trigger mode string.
Description
The xPCScopes.ScopeGetTriggerModeStr method gets the trigger
mode string for scope scNum. This method returns one of the following
strings.
See Also
8-68
[in] scNum
Constant
Description
FreeRun
There is no trigger mode. The scope triggers
when it is ready to trigger, regardless of the
circumstances.
Software
Only user intervention can trigger the scope. No
other triggering is possible.
Signal
The scope is triggered only after a signal has
crossed a value.
Scope
The scope is triggered by another scope at the
trigger point of the triggering scope, modified by
the value of triggerscopesample (see scopedata).
API function xPCScopes.ScopeGetTriggerMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetTriggerSample
Purpose
Get sample number for triggering scope
Prototype
long ScopeGetTriggerSample(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetTriggerSample method returns a nonnegative
integer for a real sample, and -1 for the special case where triggering
is at the end of the data acquisition cycle for a triggering scope. If the
method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetTriggerSample method gets the number
of samples a triggering scope (scNum) acquires before starting data
acquisition on a second scope. This value is a nonnegative integer for a
real sample, and -1 for the special case where triggering is at the end of
the data acquisition cycle for a triggering scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-69
xPCScopes.ScopeGetTriggerSignal
Purpose
Get trigger signal for scope
Prototype
long ScopeGetTriggerSignal(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-70
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetTriggerSignal method returns the scope
trigger signal. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetTriggerSignal method gets the trigger
signal for scope scNum.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetTriggerSlope
Purpose
Get trigger slope for scope
Prototype
long ScopeGetTriggerSlope(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetTriggerSlope method returns the scope
trigger slope. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetTriggerSlope method gets the trigger slope
of scope scNum. Use the constants here to interpret the trigger slope:
See Also
String
Value
Description
TRIGSLOPE_EITHER
0
The trigger slope can be either
rising or falling.
TRIGSLOPE_RISING
1
The trigger slope must be
rising when the signal crosses
the trigger value.
TRIGSLOPE_FALLING
2
The trigger slope must be
falling when the signal
crosses the trigger value.
API function xPCScopes.ScopeGetTriggerSlopeStr
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-71
xPCScopes.ScopeGetTriggerSlopeStr
Purpose
Get trigger slope as string
Prototype
BSTR ScopeGetTriggerSlopeStr(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
Enter the scope number.
Return
The xPCScopes.ScopeGetTriggerSlopeStr method returns a string
containing the trigger slope string.
Description
The xPCScopes.ScopeGetTriggerSlopeStr method gets the trigger
slope string for scope scNum. This method returns one of the following
strings:
See Also
8-72
[in] scNum
String
Description
Either
The trigger slope can be either rising or falling.
Rising
The trigger slope must be rising when the signal
crosses the trigger value.
Falling
The trigger slope must be falling when the signal
crosses the trigger value.
API function xPCScopes.ScopeGetTriggerSlope
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeGetType
Purpose
Get type of scope
Prototype
BSTR ScopeGetType(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.ScopeGetType method returns the scope type as a
string. If the method detects an error, it returns -1.
Description
The xPCScopes.ScopeGetType method gets the type of scope scNum.
This method returns one of the following strings:
String
Description
HOST
Host scope
Target
Target scope
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-73
xPCScopes.ScopeRemSignal
Purpose
Remove signal from scope
Prototype
long ScopeRemSignal(long scNum, long sigNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-74
[in] scNum
Enter the scope number.
[in] sigNum
Enter a signal number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeRemSignal method removes a signal from the
scope with number scNum. The scope must already exist, and signal
number sigNum must exist in the scope. Use xPCScopes.GetScopes to
determine the existing scopes, and use xPCScopes.ScopeGetSignals
to determine the existing signals for a scope. Use this function only
when the scope is stopped. Use xPCScopes.ScopeGetState to check
the state of the scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeSetAutoRestart
Purpose
Scope autorestart value
Prototype
long ScopeSetAutoRestart(long scNum, long onoff);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] onoff
Enter value to enable (1) or disable (0)
scope autorestart.
Return
The xPCScopes.ScopeSetAutoRestart method returns the scope
autorestart flag value (1 if enabled, 0 if disabled). If the method detects
an error, it returns -1.
Description
The xPCScopes.ScopeSetAutoRestart method sets the autorestart flag
value for scope scNum. Autorestart flag can be disabled (0) or enabled (1).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-75
xPCScopes.ScopeSetDecimation
Purpose
Set decimation of scope
Prototype
long ScopeSetDecimation(long scNum, long decimation);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-76
[in] scNum
Enter the scope number.
[in] decimation
Enter an integer for the decimation.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetDecimation method sets the decimation of
scope scNum. The decimation is a number, N, meaning every Nth sample
is acquired in a scope window. Use this function only when the scope is
stopped. Use xPCScopes.ScopeGetState to check the state of the scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeSetNumPrePostSamples
Purpose
Set number of pre- or posttriggering samples before triggering scope
Prototype
long ScopeSetNumPrePostSamples(long scNum, long prepost);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] prepost
A negative number means pretriggering, while
a positive number means posttriggering. This
function can only be used when the scope is
stopped.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetNumPrePostSamples method sets the number
of samples for pre- or posttriggering for scope scNum to prepost. Use this
method only when the scope is stopped. Use xPCScopes.ScopeGetState
to check the state of the scope. Use the xPCScopes.GetScopes method
to get a list of scope numbers.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-77
xPCScopes.ScopeSetNumSamples
Purpose
Set number of samples in one data acquisition cycle
Prototype
long ScopeSetNumSamples(long scNum, long samples);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-78
[in] scNum
Enter the scope number.
[in] samples
Enter the number of samples you want to acquire
in one cycle.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetNumSamples method sets the number of
samples for scope scNum to samples. Use this function only when the
scope is stopped. Use xPCScopes.ScopeGetState to check the state
of the scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeSetTriggerLevel
Purpose
Set trigger level for scope
Prototype
long ScopeSetTriggerLevel(long scNum, double level);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] level
Value for a signal to trigger data acquisition with
a scope.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetTriggerLevel method sets the trigger level to
level for scope scNum. Use this function only when the scope is stopped.
Use xPCScopes.ScopeGetStateto check the state of the scope.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-79
xPCScopes.ScopeSetTriggerMode
Purpose
Set trigger mode of scope
Prototype
long ScopeSetTriggerMode(long scNum, long triggermode);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] triggermode
Trigger mode for a scope.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetTriggerMode method sets the trigger mode of
scope scNum to triggermode. Use this method only when the scope is
stopped. Use xPCScopes.ScopeGetStateto check the state of the scope.
Use the xPCScopes.GetScopes method to get a list of scopes.
Use the constants defined here to interpret the trigger mode:
8-80
Constant
Value
Description
TRIGMD_FREERUN
0
There is no trigger mode.
The scope triggers when it is
ready to trigger, regardless
of the circumstances. This is
the default.
TRIGMD_SOFTWARE
1
Only user intervention can
trigger the scope. No other
triggering is possible.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeSetTriggerMode
Constant
Value
Description
TRIGMD_SIGNAL
2
The scope is triggered only
after a signal has crossed a
value.
TRIGMD_SCOPE
3
The scope is triggered by
another scope at the trigger
point of the triggering scope,
modified by the value of
triggerscopesample (see
scopedata).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-81
xPCScopes.ScopeSetTriggerSample
Purpose
Set sample number for triggering scope
Prototype
long ScopeSetTriggerSample(long scNum, long trigScSample);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] trigScSample
Enter a nonnegative integer for the
number of samples acquired by the
triggering scope before starting data
acquisition on a second scope.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetTriggerSample method sets the number of
samples (trigScSample) a triggering scope acquires before it triggers
a second scope (scNum). Use the xPCScopes.GetScopes method to get
a list of scopes.
For meaningful results, set trigScSample between -1 and (nSamp-1).
nSamp is the number of samples in one data acquisition cycle for the
triggering scope. If you specify too large a value, the scope is never
triggered.
If you want to trigger a second scope at the end of a data acquisition
cycle for the triggering scope, use a value of -1 for trigScSamp.
8-82
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeSetTriggerSignal
Purpose
Select signal to trigger scope
Prototype
long ScopeSetTriggerSignal(long scNum, long triggerSignal);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] trigSignal
Enter a signal number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetTriggerSignal method sets the trigger signal
of scope scNum to trigSig. The trigger signal trigSig must be one of
the signals in the scope. Use this method only when the scope is stopped.
You can use xPCScopes.ScopeGetSignals to get the list of signals in
the scope. UsexPCScopes.ScopeGetState to check the state of the
scope. Use the xPCScopes.GetScopes method to get a list of scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-83
xPCScopes.ScopeSetTriggerSlope
Purpose
Set slope of signal that triggers scope
Prototype
long ScopeSetTriggerSlope(long scNum, long triggerslope);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] triggerSlope
Enter the slope mode for the signal that triggers
the scope.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSetTriggerSlope method sets the trigger slope
of scope scNum to trigSlope. Use this method only when the scope is
stopped. Use xPCScopes.ScopeGetState to check the state of the scope.
Use the xPCScopes.GetScopes method to get a list of scopes.
Use the constants defined here to set the trigger slope:
8-84
Constant
Value
Description
TRIGSLOPE_EITHER
0
The trigger slope can be either
rising or falling.
TRIGSLOPE_RISING
1
The trigger signal value must
be rising when it crosses the
trigger value.
TRIGSLOPE_FALLING
2
The trigger signal value must
be falling when it crosses the
trigger value.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeSoftwareTrigger
Purpose
Set software trigger of scope
Prototype
long ScopeSoftwareTrigger(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeSoftwareTrigger method triggers scope scNum.
The scope must be in the state Waiting for trigger for this method to
succeed. Use xPCScopes.ScopeGetState to check the state of the scope.
Use the xPCScopes.GetScopes method to get a list of scopes.
You can use the xPCScopes.ScopeSoftwareTrigger method to trigger
the scope, regardless of the trigger mode.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-85
xPCScopes.ScopeStart
Purpose
Start data acquisition for scope
Prototype
long ScopeStart(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-86
[in] scNum
Enter the scope number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeStart method starts or restarts the data
acquisition of scope scNum. If the scope does not have to preacquire
samples, it enters the Waiting for Trigger state. The scope must
be in state Waiting to Start, Finished, or Interrupted for this
function to succeed. Call xPCScopes.ScopeGetState to check the
state of the scope or, for host scopes that are already started, call
xPCScopes.IsScopeFinished. Use the xPCScopes.GetScopes method
to get a list of scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.ScopeStop
Purpose
Stop data acquisition for scope
Prototype
long ScopeStop(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.ScopeStop method stops the scope scNum. This sets
the scope to the Interrupted state. The scope must be running for
this function to succeed. Use xPCScopes.ScopeGetState to determine
the state of the scope. Use the xPCScopes.GetScopes method to get
a list of scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-87
xPCScopes.TargetScopeGetGrid
Purpose
Get status of grid line for particular scope
Prototype
long TargetScopeGetGrid(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
The xPCScopes.TargetScopeGetGrid method returns the state of the
grid lines for scope scNum. If the method detects an error, it returns -1.
Description
The xPCScopes.TargetScopeGetGrid method gets the state of the grid
lines for scope scNum (which must be of type SCTYPE_TARGET). A return
value of 1 implies grid on, while 0 implies grid off. Note that when the
scope mode is set to SCMODE_NUMERICAL, the grid is not drawn even
when the grid mode is set to 1.
Tip
• Use the xPCScopes.GetScopes method to get a list of scopes.
• Use xPCScopes.TargetScopeGetMode and
xPCScopes.TargetScopeSetMode to retrieve and set the scope mode.
8-88
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.TargetScopeGetMode
Purpose
Get scope mode for displaying signals
Prototype
long TargetScopeGetMode(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
Return
[in] scNum
Enter the scope number.
The xPCScopes.TargetScopeGetMode method returns the value
corresponding to the scope mode. The possible values are
• SCMODE_NUMERICAL = 0
• SCMODE_REDRAW = 1
• SCMODE_SLIDING = 2
• SCMODE_ROLLING = 3
If the method detects an error, it returns -1.
Description
The xPCScopes.TargetScopeGetMode method gets the mode of
the scope scNum, which must be of type SCTYPE_TARGET. Use the
xPCScopes.GetScopes method to get a list of scopes.
See Also
API function xPCScopes.TargetScopeGetModeStr
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-89
xPCScopes.TargetScopeGetModeStr
Purpose
Get scope mode string for displaying signals
Prototype
BSTR TargetScopeGetModeStr(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
Return
[in] scNum
Enter the scope number.
The xPCScopes.TargetScopeGetModeStr method returns the string
corresponding to the scope mode. The possible strings are
• Numerical
• Redraw
• Sliding
• Rolling
8-90
Description
The xPCScopes.TargetScopeGetModeStr method gets the mode string
of the scope scNum, which must be of type SCTYPE_TARGET. Use the
xPCScopes.GetScopes method to get a list of scopes.
See Also
API function xPCScopes.TargetScopeGetMode
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.TargetScopeGetViewMode
Purpose
Get view mode for target computer display
Prototype
long TargetScopeGetViewMode();
Member
Of
XPCAPICOMLIB.xPCScopes
Return
The xPCScopes.TargetScopeGetViewMode method returns the view
mode for the target computer screen. If the method detects an error, it
returns -1.
Description
The xPCScopes.TargetScopeGetViewMode method gets the view (zoom)
mode for the target computer display. If the returned value is not zero,
the number is of the scope currently displayed on the screen. If the
value is 0, then all defined scopes are displayed on the target computer
screen, but no scopes are in focus (all scopes are unzoomed).
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-91
xPCScopes.TargetScopeGetYLimits
Purpose
Get y-axis limits for scope
Prototype
VARIANT TargetScopeGetYLimits(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-92
[in] scNum
Enter the scope number.
Return
The xPCScopes.TargetScopeGetYLimits method returns the upper
and lower limits for target scopes.
Description
The xPCScopes.TargetScopeGetYLimits method gets and copies the
upper and lower limits for a scope of type SCTYPE_TARGET and with scope
number scNum. If both elements are zero, the limits are autoscaled. Use
the xPCScopes.GetScopes method to get a list of scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.TargetScopeSetGrid
Purpose
Set grid mode for scope
Prototype
long TargetScopeSetGrid(long scNum, long gridonoff);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
[in] gridonoff
Enter a grid value (0 or 1).
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.TargetScopeSetGrid method sets the grid of a scope
of type SCTYPE_TARGET and scope number scNum to gridonoff. If
gridonoff is 0, the grid is off. If gridonoff is 1, the grid is on and grid
lines are drawn on the scope window. When the drawing mode of scope
scNum is set to SCMODE_NUMERICAL, the grid is not drawn even when
the grid mode is set to 1. Use the xPCScopes.GetScopes method to
get a list of scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-93
xPCScopes.TargetScopeSetMode
Purpose
Set display mode for scope
Prototype
long TargetScopeSetMode(long scNum, long mode);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
in] mode
Enter the value for the mode.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.TargetScopeSetMode method sets the mode of a scope
of type SCTYPE_TARGET and scope number scNum to mode. You can use
one of the following constants for mode:
• SCMODE_NUMERICAL = 0
• SCMODE_REDRAW = 1
• SCMODE_SLIDING = 2
• SCMODE_ROLLING = 3
Use the xPCScopes.GetScopes method to get a list of scopes.
8-94
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCScopes.TargetScopeSetViewMode
Purpose
Set view mode for scope
Prototype
long TargetScopeSetViewMode(long scNum);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
[in] scNum
Enter the scope number.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.TargetScopeSetViewMode method sets the target
computer screen to display one scope with scope number scNum. If you
set scNum to 0, the target computer screen displays all the defined
scopes. Use the xPCScopes.GetScopes method to get a list of scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-95
xPCScopes.TargetScopeSetYLimits
Purpose
Set y-axis limits for scope
Prototype
long TargetScopeSetYLimits(long scNum, SAFEARRAY(double)*
Ylimitarray);
Member
Of
XPCAPICOMLIB.xPCScopes
Arguments
8-96
[in] scNum
Enter the scope number.
[in, out] Ylimitarray
Enter a two-element array.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCScopes.TargetScopeSetYLimits method sets the y-axis limits
for a scope with scope number scNum and type SCTYPE_TARGET to the
values in the double array YlimitArray. The first element is the lower
limit, and the second element is the upper limit. Set both limits to
0.0 to specify autoscaling. Use the xPCScopes.GetScopes method to
get a list of scopes.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.AverageTET
Purpose
Get average task execution time
Prototype
double AverageTET();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.AverageTET method returns the average task execution
time (TET) for the target application. If the method detects an error, it
returns -1.
Description
The xPCTarget.AverageTET method gets the TET for the target
application. You can use this function when the target application is
running or when it is stopped.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-97
xPCTarget.GetAppName
8-98
Purpose
Get target application name
Prototype
BSTR GetAppName();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetAppName method returns a string with the name
of the target application.
Description
The xPCTarget.GetAppName method gets the name of the target
application. You can use the return value, model_name, in a printf or
similar statement. In case of error, the string is unchanged. Be sure
to allocate enough space to accommodate the longest target name you
have.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetExecTime
Purpose
Get execution time for target application
Prototype
double GetExecTime();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetExecTime method returns the current execution
time for a target application. If the method detects an error, it returns
-1.
Description
The xPCTarget.GetExecTime method gets the current execution time
for the running target application. If the target application is stopped,
the value is the last running time when the target application was
stopped. If the target application is running, the value is the current
running time.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-99
xPCTarget.GetNumOutputs
Purpose
Get number of outputs
Prototype
long GetNumOutputs();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetNumOutputs method returns the number of outputs
in the current target application. If the method detects an error, it
returns -1.
Description
The xPCTarget.GetNumOutputs method gets the number of outputs in
the target application. The number of outputs equals the sum of the
input signal widths of the output blocks at the root level of the Simulink
model.
8-100
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetNumParams
Purpose
Get number of tunable parameters
Prototype
long GetNumParams();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetNumParams method returns the number of tunable
parameters in the target application. If the method detects an error, it
returns -1.
Description
The xPCTarget.GetNumParams method gets the number of tunable
parameters in the target application. Use this method to see how many
parameters you can get or modify.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-101
xPCTarget.GetNumSignals
Purpose
Get number of signals
Prototype
long GetNumSignals();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetNumSignals method returns the number of signals
in the target application. If the method detects an error, it returns -1.
Description
The xPCTarget.GetNumSignals method gets the total number of signals
in the target application that can be monitored from the host. Use this
method to see how many signals you can monitor.
8-102
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetNumStates
Purpose
Get number of states
Prototype
long GetNumStates();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetNumStates method returns the number of states in
the target application. If the method detects an error, it returns -1.
Description
The xPCTarget.GetNumStates method gets the number of states in the
target application.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-103
xPCTarget.GetOutputLog
Purpose
Copy output log data to array
Prototype
VARIANT GetOutputLog(long start, long numsamples,
long decimation,
long output_id);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] start
Enter the index of the first sample to copy.
[in] numsamples
Enter the number of samples to copy from
the output log.
[in] decimation
Select whether to copy all the sample values
or every Nth value.
[in] output_id
Enter an output identification number.
Return
The xPCTarget.GetOutputLog method returns output log data. You
get the data for each output signal. If the method detects an error, it
returns VT_ERROR, a scalar.
Description
The xPCTarget.GetOutputLog method gets the output log and copies
that log to an array. Output IDs range from 0 to (N-1), where N is the
return value of xPCTarget.GetNumOutputs. Entering 1 for decimation
copies all values. Entering N copies every Nth value.
For start, the sample indices range from 0 to (N-1), where N is the
return value of xPCTarget.NumLogSamples. Get the maximum number
of samples by calling the method xPCTarget.NumLogSamples.
Note that the target application must be stopped before you get the
output log data.
8-104
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetParam
Purpose
Get parameter values
Prototype
VARIANT GetParam(long paramIdx);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] paramIdx
Enter the index for a parameter.
Return
The xPCTarget.GetParam method returns the parameter values of a
parameter.
Description
The xPCTarget.GetParam method gets the parameter values of a
parameter identified by paramIdx. This method returns an array
of type VARIANT containing the parameter values, with the
conversion of the values being done in column-major format.
Each element in the array is a double, regardless of the data
type of the actual parameter. You can query the dimensions of
the array by calling the method xPCTarget.GetParamDims.
See the Microsoft Visual Basic .NET 2003 solution located in
C:\matlabroot\toolbox\rtw\targets\xpc\api\VBNET\SigsAndParamsDemo
for an example of how to use this method.
See Also
API method xPCTarget.GetParamDims, xPCTarget.SetParam
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-105
xPCTarget.GetParamDims
Purpose
Get row and column dimensions of parameter
Prototype
VARIANT GetParamDims(long paramIdx);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] paramIdx
Parameter index.
Return
The xPCTarget.GetParamDims method returns a VARIANT array of two
elements.
Description
The xPCTarget.GetParamDims method gets a VARIANT array of two
elements. The first element contains the number of rows of the
parameter, the second element contains the number of columns for
your parameter.
8-106
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetParamIdx
Purpose
Get parameter index
Prototype
long GetParamIdx(BSTR blockName, BSTR paramName);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] blockName
Enter the full block path generated by the
Simulink Coder software.
[in] paramName
Enter the parameter name for a parameter
associated with the block.
Return
The xPCTarget.GetParamIdx method returns the parameter index for
the parameter name. If the method detects an error, it returns -1.
Description
The xPCTarget.GetParamIdx method gets the parameter index for
the parameter name (paramName) associated with a Simulink block
(blockName). Both blockName and paramName must be identical to those
generated at target application building time. The block names should
be referenced from the file model_namept.m in the generated code,
where model_name is the name of the model. Note that a block can have
one or more parameters.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-107
xPCTarget.GetParamName
Purpose
Get parameter name
Prototype
VARIANT GetParamName(long paramIdx);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] paramIdx
Enter a parameter index.
Return
The xPCTarget.GetParamName method returns a VARIANT array that
contains two elements, the block path and parameter name, as strings.
Description
The xPCTarget.GetParamName method gets the parameter name
and block name for a parameter with the index paramIdx. If
paramIdx is invalid, xPCGetLastError returns nonzero, and the
strings are unchanged. Get the parameter index with the method
xPCTarget.GetParamIdx.
8-108
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetSampleTime
Purpose
Get sample time
Prototype
double GetSampleTime();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetSampleTime method returns the sample time, in
seconds, of the target application. If the method detects an error, it
returns -1.
Description
The xPCTarget.GetSampleTime method gets the sample time, in
seconds, of the target application. You can get the error by using the
method xPCGetLastError.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-109
xPCTarget.GetSignal
Purpose
Get signal value
Prototype
double GetSignal(long sigNum);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] sigNum
Enter a signal number.
Return
The xPCTarget.GetSignal method returns the current value of signal
sigNum. If the method detects an error, it returns -1.
Description
The xPCTarget.GetSignal method gets the current value of a signal.
Use the xPCTarget.GetSignalIdx method to get the signal number.
8-110
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetSignalidsfromLabel
Purpose
Get signal IDs from signal label
Prototype
VARIANT GetSignalidsfromLabel(BSTR sigLabel);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] sigLabel
Enter a signal label.
Return
The xPCTarget.GetSignalidsfromLabel method returns a VARIANT
array of the signal elements contained in the signal sigLabel. If no
labels exist, the method returns an empty string.
Description
The xPCTarget.GetSignalidsfromLabel method returns a VARIANT
array of the signal elements contained in the signal sigLabel. Signal
labels must be unique.
This method assumes that you have labeled the signal for which you
request the indices (see the Signal name parameter of the “Signal
Properties Controls”). Note that the xPC Target software refers to
Simulink signal names as signal labels. The creator of the application
should already know the signal name/label.
See Also
API method xPCTarget.GetSignalLabel
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-111
xPCTarget.GetSignalLabel
Purpose
Get signal label
Prototype
BSTR GetSignalLabel(long sigIdx);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] sigIdx
Enter a signal index.
Return
The xPCTarget.GetSignalLabel method returns the label of the signal.
If no labels exist, the method returns an empty string.
Description
The xPCTarget.GetSignalLabel method copies and gets the signal
label of a signal with sigIdx. The method returns the signal label.
This method assumes that you already know the signal index. Signal
labels must be unique.
This method assumes that you have labeled the signal for which you
request the indices (see the Signal name parameter of the “Signal
Properties Controls”). Note that the xPC Target software refers to
Simulink signal names as signal labels. The creator of the application
should already know the signal name/label.
See Also
8-112
API method xPCTarget.GetSignalidsfromLabel
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetSignalIdx
Purpose
Get signal index
Prototype
long GetSignalIdx(BSTR sigName);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] sigName
Enter a signal name.
Return
The xPCTarget.GetSignalIdx method returns the index for the signal
with name sigName. If the method detects an error, it returns -1.
Description
The xPCTarget.GetSignalIdx method gets the index of a signal. The
name must be identical to the name generated when the application was
built. You should reference the name from the file model_namebio.m in
the generated code, where model_name is the name of the model. The
creator of the application should already know the signal name.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-113
xPCTarget.GetSignalName
Purpose
Copy signal name to character array
Prototype
BSTR GetSignalName(long sigIdx);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] sigIdx
Enter a signal index.
Return
The xPCTarget.GetSignalName method returns the name of the signal.
Description
The xPCTarget.GetSignalName method copies and gets the signal
name, including the block path, of a signal with sigIdx. The method
returns a signal name, which makes it convenient to use in a printf
or similar statement. This method assumes that you already know
the signal index.
8-114
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetSignals
Purpose
Get vector of signal values
Prototype
VARIANT GetSignals(long NumOfSignals, SAFEARRAY(int)*
SignalsIdxArray);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] NumOfSignals
Enter the number of signals to acquire (the
number of IDs in SignalsIdxArray).
[out] SignalsIdxArray
Enter the IDs of the signals to acquire.
Return
The xPCTarget.GetSignals method returns a double-valued variant
array containing the current value of a vector of signals. If the method
detects an error, it returns VT_ERROR, a scalar.
Description
This function returns the values of a vector of up to 1000 signals as fast
as it can acquire them. The values are converted to doubles regardless
of the actual data type of the signal.
Tip
• Pass an integer array of signal numbers into SignalsIdxArray. Get
the signal numbers with the function xPCTarget.GetSignalIdx.
• The signal values may not be at the same time step. To get signal
values at the same time step, define a scope of type SCTYPE_HOST and
use xPCScopes.ScopeGetData.
The function xPCTarget.GetSignal does the same thing for a single
signal, and could be used multiple times to achieve the same result.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-115
xPCTarget.GetSignals
However, xPCGetSignals is faster and the signal values are more likely
to be spaced closely together.
See Also
8-116
API functions xPCTarget.GetSignal, xPCTarget.GetSignalIdx
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetSignalWidth
Purpose
Get width of signal
Prototype
long GetSignalWidth(long sigIdx);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] sigIdx
Enter the index of a signal.
Return
The xPCTarget.GetSignalWidth method returns the signal width for a
signal with sigIdx. If the method detects an error, it returns -1.
Description
The xPCTarget.GetSignalWidth method gets the number of signals for
a specified signal index. Although signals are manipulated as scalars,
the width of the signal might be useful to reassemble the components
into a vector. A signal’s width is the number of signals in the vector.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-117
xPCTarget.GetStateLog
Purpose
Get state log
Prototype
VARIANT GetStateLog(long start, long numsamples,
long decimation,
long state_id);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] start
Enter the index of the first sample to copy.
[in] numsamples
Enter the number of samples to copy from the
output log.
[in] decimation
Select whether to copy all the sample values or
every Nth value.
[in] state_id
Enter a state identification number.
[out, retval]
Outarray
The log is stored in Outarray, whose allocation
is the responsibility of the caller.
Return
The xPCTarget.GetStateLog method returns the state log. If the
method detects an error, it returns VT_ERROR, a scalar.
Description
The xPCTarget.GetStateLog method gets the state log. You get
the data for each state signal in turn by specifying the state_id.
State IDs range from 1 to (N-1), where N is the return value of
xPCTarget.GetNumStates. Entering 1 for decimation copies
all values. Entering N copies every Nth value. For start, the
sample indices range from 0 to (N-1), where N is the return value
of xPCTarget.NumLogSamples. Use the xPCTarget.NumLogSamples
method to get the maximum number of samples.
Note that the target application must be stopped before you get the
number.
8-118
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetStopTime
Purpose
Get stop time
Prototype
double GetStopTime();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetStopTime method returns the stop time as a double,
in seconds, of the target application. If the method detects an error, it
returns -1.
Description
The xPCTarget.GetStopTime method gets the stop time, in seconds, of
the target application. This is the amount of time the target application
runs before stopping.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-119
xPCTarget.GetTETLog
Purpose
Get TET log
Prototype
VARIANT GetTETLog(long start, long numsamples,
long decimation);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] start
Enter the index of the first sample to copy.
[in] numsamples
Enter the number of samples to copy from the
TET log.
[in] decimation
Select whether to copy all the sample values or
every Nth value.
[out, retval]
Outarray
The log is stored in Outarray, whose allocation is
the responsibility of the caller.
Return
The xPCTarget.GetTETLog method returns the TET log. If the method
detects an error, it returns VT_ERROR, a scalar.
Description
The xPCTarget.GetTETLog method gets the task execution time (TET)
log. Entering 1 for decimation copies all values. Entering N copies
every Nth value. For start, the sample indices range from 0 to (N-1),
where N is the return value of xPCTarget.NumLogSamples. Use the
xPCTarget.NumLogSamples method to get the maximum number of
samples.
Note that the target application must be stopped before you get the
number.
8-120
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.GetTimeLog
Purpose
Get time log
Prototype
VARIANT GetTimeLog(long start, long numsamples,
long decimation);
Member
Of
XPCAPICOMLib.xPCTarget
Arguments
[in] start
Enter the index of the first sample to copy.
[in] numsamples
Enter the number of samples to copy from
the time log.
[in] decimation
Select whether to copy all the sample values
or every Nth value.
Return
The xPCTarget.GetTimeLog method returns the time log. If the method
detects an error, it returns VT_ERROR, a scalar.
Description
The xPCTarget.GetTimeLog method gets the time log. This is
especially relevant in the case of value-equidistant logging, where
the logged values might not be uniformly spaced in time. Entering
1 for decimation copies all values. Entering N copies every Nth
value. For start, the sample indices range from 0 to (N-1), where
N is the return value of xPCTarget.NumLogSamples. Use the
xPCTarget.NumLogSamples method to get the number of samples.
Note that the target application must be stopped before you get the
number.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-121
xPCTarget.GetxPCError
Purpose
Get error string
Prototype
BSTR GetxPCError();
Member
Of
XPCAPICOMLib.xPCTarget
Return
The xPCTarget.GetxPCError method returns the string for the last
reported error. If the software has not reported an error, this method
returns 0.
Description
The xPCTarget.GetxPCError method gets the string of the error last
reported by another COM API method. This value is reset every time
you call a new method. Therefore, you should check this constant value
immediately after a call to an API COM method. You can use this
method in conjunction with the xPCTarget.isxPCError method, which
detects that an error has occurred.
See Also
API method xPCTarget.isxPCError
8-122
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.Init
Purpose
Initialize target object to communicate with target computer
Prototype
long Init(IxPCProtocol* xPCProtocol);
Member
Of
XPCAPICOMLib.xPCTarget
Return
If the method detects an error, it returns -1. Otherwise, it returns 0.
If the xPCTarget.Init method initializes the target object without
detecting an error, it returns 0. If the target object fails to initialize,
this method returns -1.
Description
The xPCTarget.Init method initializes the target object to
communicate with the target computer referenced by the xPCProtocol
object.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-123
xPCTarget.IsAppRunning
Purpose
Return running status for target application
Prototype
long IsAppRunning();
Member
Of
XPCAPICOMLib.xPCTarget
Return
If the target application is stopped, the xPCTarget.IsAppRunning
method returns 0. If the target application is running, this method
returns 1. If the method detects an error, it returns -1.
Description
The xPCTarget.IsAppRunning method returns 1 or 0 depending on
whether the target application is stopped or running.
8-124
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.IsOverloaded
Purpose
Return overload status for target computer
Prototype
long IsOverloaded();
Member
Of
XPCAPICOMLib.xPCTarget
Return
If the target application has overloaded the CPU, the
xPCTarget.IsOverloaded method returns 1. If it has not overloaded
the CPU, the method returns 0. If the method detects an error, it
returns -1.
Description
The xPCTarget.IsOverloaded method checks if the target application
has overloaded the target computer and returns 1 if it has and 0 if it
has not. If the target application is not running, the method returns 0.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-125
xPCTarget.isxPCError
Purpose
Return error status
Prototype
long isxPCError();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
If an error occurred, the method returns 1. Otherwise, it returns 0.
Description
Use the xPCTarget.isxPCError method to check for errors that might
occur after a call to the xPCTarget class methods. If the method detects
that an error occurred, call the xPCTarget.GetxPCError method to
get the string for the error.
See Also
API method xPCTarget.GetxPCError
8-126
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.LoadApp
Purpose
Load target application onto target computer
Prototype
long LoadApp(BSTR pathstr, BSTR filename);
Member
Of
XPCAPICOMLIB.xPCTarget
Arguments
[in] pathstr
Enter the full path to the target application file,
excluding the file name. For example, in C, use a
string like "C:\\work", in Microsoft Visual Basic,
use a string like 'C:\work'.
[in] filename
Enter the name of a compiled target application
(*.dlm) without the file extension. For example,
in C use a string like "xpcosc", in Microsoft
Visual Basic, use a string like 'xpcosc'.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCTarget.LoadApp method loads the compiled target application
to the target computer. pathstr must not contain the trailing
backslash. pathstr can be set to NULL or to the string 'nopath' if the
application is in the current folder. The variable filename must not
contain the target application extension.
Before returning, xPCTarget.LoadApp waits for a certain amount of
time before checking whether the model initialization is complete. In the
case where the model initialization is incomplete, xPCTarget.LoadApp
returns a timeout error to indicate a connection problem (for example,
ETCPREAD). By default, xPCTarget.LoadApp checks for target readiness
five times, with each attempt taking approximately 1 second (less if
the target is ready). However, for larger models or models requiring
longer initialization (for example, those with thermocouple boards),
the default might not be long enough and a spurious timeout can
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-127
xPCTarget.LoadApp
be generated. The methods xPCProtocol.GetLoadTimeOut and
xPCProtocol.SetLoadTimeOut control the number of attempts made.
8-128
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.MaximumTET
Purpose
Copy maximum task execution time to array
Prototype
VARIANT MaximumTET();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
The xPCTarget.MaximumTET method returns a VARIANT object
containing the maximum task execution time (TET) and the time at
which the maximum TET was achieved. The maximum TET value is
copied into the first element, and the time at which it was achieved
is copied into the second element.
Description
The xPCTarget.MaximumTET method returns the maximum TET that
was achieved during the previous target application run.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-129
xPCTarget.MaxLogSamples
Purpose
Return maximum number of samples that can be in log buffer
Prototype
long MaxLogSamples();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
The xPCTarget.MaxLogSamples method returns the total number of
samples. If the method detects an error, it returns -1.
Description
The xPCTarget.MaxLogSamples method returns the total number of
samples that can be returned in the logging buffers.
Note that the target application must be stopped before you get the
number.
8-130
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.MinimumTET
Purpose
Copy minimum task execution time to array
Prototype
VARIANT MinimumTET();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
The xPCTarget.MinimumTET method returns a VARIANT object
containing the minimum task execution time (TET) and the time at
which the minimum TET was achieved. The minimum TET value is
copied into the first element, and the time at which it was achieved
is copied into the second element.
Description
The xPCTarget.MinimumTET method returns the minimum task
execution time (TET) that was achieved during the previous target
application run.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-131
xPCTarget.NumLogSamples
Purpose
Return number of samples in log buffer
Prototype
long NumLogSamples();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
The xPCTarget.NumLogSamples method returns the number of samples
in the log buffer. If the method detects an error, it returns -1.
Description
The xPCTarget.NumLogSamples method returns the number of samples
in the log buffer. In contrast to xPCTarget.MaxLogSamples, which
returns the maximum number of samples that can be logged (because of
buffer size constraints), xPCtarget.NumLogSamples returns the number
of samples actually logged.
Note that the target application must be stopped before you get the
number.
8-132
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.NumLogWraps
Purpose
Return number of times log buffer wraps
Prototype
long NumLogWraps();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
The xPCTarget.NumLogWraps method returns the number of times the
log buffer wraps. If the method detects an error, it returns -1.
Description
The xPCTarget.NumLogWraps method returns the number of times the
log buffer wraps.
Note that the target application must be stopped before you get the
number.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-133
xPCTarget.SetParam
Purpose
Change parameter value
Prototype
long SetParam(long paramIdx, SAFEARRAY(double)*
newparamVal);
Member
Of
XPCAPICOMLIB.xPCTarget
Arguments
[in] paramIdx
Parameter index.
[in, out] newparamVal
Vector of doubles, assumed to be the size
required by the parameter type.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCTarget.SetParam method sets the parameter paramIdx to
the value in newparamVal. For matrices, newparamVal should be a
vector representation of the matrix in column-major format. Although
newparamVal is a vector of doubles, the method converts the values to
the expected data types (using truncation) before setting them.
See Also
API methods xPCTarget.GetParam, xPCTarget.GetParamDims,
xPCTarget.GetParamIdx
8-134
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.SetSampleTime
Purpose
Change sample time for target application
Prototype
long SetSampleTime(double ts);
Member
Of
XPCAPICOMLIB.xPCTarget
Arguments
[in] ts
Sample time for the target application.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCTarget.SetSampleTime method sets the sample time, in
seconds, of the target application to ts. Use this method only when
the application is stopped.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-135
xPCTarget.SetStopTime
Purpose
Change stop time of target application
Prototype
long SetStopTime(double tfinal);
Member
Of
XPCAPICOMLIB.xPCTarget
Arguments
[in] tfinal
Enter the stop time, in seconds.
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCTarget.SetStopTime method sets the stop time of the target
application to the value in tfinal. The target application will run for
this number of seconds before stopping. Set tfinal to -1.0 to set the
stop time to infinity.
8-136
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.StartApp
Purpose
Start target application
Prototype
long StartApp()
Member
Of
XPCAPICOMLIB.xPCTarget
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCTarget.StartApp method starts the target application loaded
on the target machine.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-137
xPCTarget.StopApp
Purpose
Stop target application
Prototype
long StopApp();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCTarget.StopApp method stops the target application loaded on
the target computer. The target application remains loaded, and the
parameter changes you made remain intact. If you want to stop and
unload an application, use xPCTarget.UnLoadApp.
8-138
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
xPCTarget.UnLoadApp
Purpose
Unload target application
Prototype
long UnLoadApp();
Member
Of
XPCAPICOMLIB.xPCTarget
Return
If the method detects an error, it returns 0. Otherwise, it returns -1.
Description
The xPCTarget.UnloadApp method stops the current target application,
removes it from the target computer memory, and resets the target
computer in preparation for receiving a new target application. The
method xPCTarget.LoadApp calls this method before loading a new
target application.
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
8-139
‫‪xPCTarget.UnLoadApp‬‬
‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ | ‪www.MatlabSite.com‬‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫‪8-140‬‬
Index
A
Index
applications
deploying 4-38
xPC Target C API 3-1
xPC Target COM API 4-1
B
block parameters
tagging 4-8
block signals
tagging 4-11
C
COM API methods
communication objects 8-2
file system objects 8-7
parameter objects, 8-6
scope objects 8-4
signal objects, 8-6
target objects 8-3
xPCFileSystem 8-7
xPCProtocol 8-2
xPCScopes 8-4 8-6
xPCTarget 8-3
COM applications 4-1
before you start 4-2
examples 5-1
Microsoft Visual Basic .NET example 5-2
Microsoft Visual Basic 6.0 example 5-5
Tcl/Tk scripts 5-8
Visual Basic 4-4
xpctank 4-5
COM Test Harness 8-10 to 8-11 8-14 to 8-56 8-58
to 8-63 8-65 to 8-66 8-68 to 8-80 8-82 to 8-115
8-117 to 8-127 8-129 to 8-139
custom applications
Visual C example 3-4
xPC Target COM API 4-1
custom C applications
before you start 3-2
example 3-4
guidelines 3-2
custom GUI
COM objects 4-4
custom Visual Basic applications
before you start 4-2
building 4-38
creating 4-18
creating event procedures 4-27
creating general declarations 4-26
creating load procedure 4-26
example 4-4
graphical interface 4-22
setting properties 4-24
writing code 4-25
D
dirStruct structure 7-15
diskinfo structure 7-17
F
fileinfo structure 7-20
FSDir structure 8-10
FSDiskInfo structure 8-11
G
GUI creation 4-1
L
lgmode structure 7-21
M
model-specific COM library
classes 4-16
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Index-1
Index
creating 4-13
parameter class 4-17
referencing 4-20
signal class 4-17
Visual C example
building 3-9
C code 3-16
creating 3-6
P
X
parameters
tagging 4-8
xPC Target API for Microsoft® .NET Framework
overview 1-2
xPC Target™ API for Microsoft® .NET
Framework 2-1
xPC Target APIs
overview 1-2
xPC Target C API 3-1
application creation 3-1
example 3-4
introduction 1-5
overview 1-2
xPC Target COM API 4-1
GUI creation 4-1
introduction 1-7
overview 1-2
xPCAddScope function 7-25
xPCAverageTET function 7-26
xPCCloseConnection function 7-27
xPCClosePort function 7-28
xPCDeRegisterTarget function 7-29
xPCErrorMsg function 7-30
xPCFileSystem 8-7
xPCFileSystem.CD method 8-14
xPCFileSystem.CloseFile method 8-15
xPCFileSystem.DirList method 8-16
xPCFileSystem.GetDiskInfo method 8-17
xPCFileSystem.GetFileSize method 8-18
xPCFileSystem.Init method 8-19
xPCFileSystem.MKDIR method 8-20
xPCFileSystem.OpenFile method 8-21
xPCFileSystem.PWD method 8-22
xPCFileSystem.ReadFile method 8-23
xPCFileSystem.RemoveFile method 8-24
S
scopedata structure 7-22
signals
tagging 4-11
T
tagging block parameters 4-8
tagging block signals 4-11
target application
running API application 3-10
using 3-10
target applications
building 3-6
V
Visual Basic example 4-4
building 4-38
creating event procedures 4-27
creating general declarations 4-26
creating load procedure 4-26
creating new 4-18
graphical interface 4-22
referencing without tags 4-33
setting properties 4-24
tagging block parameters 4-8
tagging block signals 4-11
testing 4-37
writing code 4-25
Index-2
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Index
xPCFileSystem.RMDIR method 8-25
xPCFileSystem.ScGetFileName method 8-26
xPCFileSystem.ScGetWriteMode method 8-27
xPCFileSystem.ScGetWriteSize method 8-28
xPCFileSystem.ScSetFileName method 8-29
xPCFileSystem.ScSetWriteMode method 8-30
xPCFileSystem.ScSetWriteSize method 8-31
xPCFileSystem.WriteFile method 8-32
xPCFreeAPI function 7-31
xPCFSCD function 7-32
xPCFSCloseFile function 7-33
xPCFSDir function 7-34
xPCFSDirItems function 7-35
xPCFSDirSize function 7-36
xPCFSDirStructSize function 7-37
xPCFSDiskInfo function 7-38
xPCFSFileInfo function 7-39
xPCFSGetError function 7-40
xPCFSGetFileSize function 7-41
xPCFSGetPWD function 7-42
xPCFSMKDIR function 7-43
xPCFSOpenFile function 7-44
xPCFSReadFile function 7-45
xPCFSRemoveFile function 7-46
xPCFSRMDIR function 7-47
xPCFSScGetFilename function 7-48
xPCFSScGetWriteMode function 7-49
xPCFSScGetWriteSize function 7-50
xPCFSScSetFilename function 7-51
xPCFSScSetWriteMode function 7-52
xPCFSScSetWriteSize function 7-53
xPCFSWriteFile function 7-54
xPCGetAPIVersion function 7-55
xPCGetAppName function 7-56
xPCGetEcho function 7-57
xPCGetExecTime function 7-58
xPCGetLastError function 7-59
xPCGetLoadTimeOut function 7-60
xPCGetLogMode function 7-62
xPCGetNumOutputs function 7-63
xPCGetNumParams function 7-64
xPCGetNumScopes function 7-65
xPCGetNumScSignals function 7-66
xPCGetNumSignals function 7-67
xPCGetNumStates function 7-68
xPCGetOutputLog function 7-69
xPCGetParam function 7-71
xPCGetParamDims function 7-72
xPCGetParamIdx function 7-73
xPCGetParamName function 7-74
xPCGetSampleTime function 7-75
xPCGetScope function 7-76
xPCGetScopeList function 7-77
xPCGetScopes function 7-78
xPCGetSessionTime function 7-79
xPCGetSigIdxfromLabel function 7-82
xPCGetSigLabelWidth function 7-84
xPCGetSignal function 7-80
xPCGetSignalIdx function 7-81
xPCGetSignalLabel function 7-83
xPCGetSignalName function 7-85
xPCGetSignals function 7-86
xPCGetSignalWidth function 7-88
xPCGetStateLog function 7-89
xPCGetStopTime function 7-91
xPCGetTargetVersion function 7-92
xPCGetTETLog function 7-93
xPCGetTimeLog function 7-94
xPCInitAPI function 7-95
xPCIsAppRunning function 7-96
xPCIsOverloaded function 7-97
xPCIsScFinished function 7-98
xPCLoadApp function 7-99
xPCLoadParamSet function 7-101
xPCMaximumTET function 7-103
xPCMaxLogSamples function 7-102
xPCMinimumTET function 7-104
xPCNumLogSamples function 7-105
xPCNumLogWraps function 7-106
xPCOpenConnection function 7-107
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Index-3
Index
xPCOpenSerialPort function 7-108
xPCOpenTcpIpPort function 7-109
xPCParameters 8-6
xPCProtocol 8-2
xPCProtocol.Close method 8-33
xPCProtocol.GetLoadTimeOut method 8-34
xPCProtocol.GetxPCErrorMsg method 8-35
xPCProtocol.Init method 8-36
xPCProtocol.isxPCError method 8-37
xPCProtocol.Port method 8-38
xPCProtocol.RS232Connect method 8-40
xPCProtocol.SetLoadTimeOut method 8-41
xPCProtocol.TargetPing method 8-42
xPCProtocol.TcpIpConnect method 8-43
xPCProtocol.Term method 8-44
xPCProtocol.xPCReboot method 8-39
xPCReboot function 7-110
xPCRegisterTarget function 7-112
xPCRemScope function 7-114
xPCReOpenPort function 7-111
xPCSaveParamSet function 7-115
xPCScAddSignal function 7-116
xPCScGetData function 7-118
xPCScGetDecimation function 7-120
xPCScGetNumPrePostSamples function 7-121
xPCScGetNumSamples function 7-122
xPCScGetNumSignals function 7-123
xPCScGetSignalList function 7-124
xPCScGetSignals function 7-125
xPCScGetStartTime function 7-126
xPCScGetState function 7-127
xPCScGetTriggerLevel function 7-129
xPCScGetTriggerMode function 7-130
xPCScGetTriggerScope function 7-132
xPCScGetTriggerScopeSample function 7-133
xPCScGetTriggerSignal function 7-134
xPCScGetTriggerSlope function 7-135
xPCScGetType function 7-137
xPCScopes 8-4
xPCScopes.AddFileScope method 8-45
Index-4
xPCScopes.AddHostScope method 8-46
xPCScopes.AddTargetScope method 8-47
xPCScopes.GetScopes method 8-48
xPCScopes.GetxPCError method 8-49
xPCScopes.Init method 8-50
xPCScopes.IsScopeFinished method 8-51
xPCScopes.IsxPCError method 8-52
xPCScopes.RemScope method 8-53
xPCScopes.ScopeAddSignal method 8-54
xPCScopes.ScopeGetAutoRestart method 8-55
xPCScopes.ScopeGetData method 8-56
xPCScopes.ScopeGetDecimation method 8-58
xPCScopes.ScopeGetNumPrePostSamples
method 8-59
xPCScopes.ScopeGetNumSamples method 8-60
xPCScopes.ScopeGetSignals method 8-61
xPCScopes.ScopeGetStartTime method 8-62
xPCScopes.ScopeGetState method 8-63
xPCScopes.ScopeGetTriggerLevel
method 8-65
xPCScopes.ScopeGetTriggerMode method 8-66
xPCScopes.ScopeGetTriggerModeStr
method 8-68
xPCScopes.ScopeGetTriggerScopeSample
method 8-69
xPCScopes.ScopeGetTriggerSignal
method 8-70
xPCScopes.ScopeGetTriggerSlope
method 8-71
xPCScopes.ScopeGetTriggerSlopeStr
method 8-72
xPCScopes.ScopeGetType method 8-73
xPCScopes.ScopeRemSignal method 8-74
xPCScopes.ScopeSetAutoRestart method 8-75
xPCScopes.ScopeSetDecimation method 8-76
xPCScopes.ScopeSetNumPrePostSamples
method 8-77
xPCScopes.ScopeSetNumSamples method 8-78
xPCScopes.ScopeSetTriggerLevel
method 8-79
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Index
xPCScopes.ScopeSetTriggerMode method 8-80
xPCScopes.ScopeSetTriggerScopeSample
method 8-82
xPCScopes.ScopeSetTriggerSignal
method 8-83
xPCScopes.ScopeSetTriggerSlope
method 8-84
xPCSetLoadTimeOut function 7-156
xPCSetLogMode function 7-157
xPCSetParam function 7-158
xPCSetSampleTime function 7-159
xPCSetScope function 7-160
xPCSetStopTime function 7-161
xPCSignals 8-6
xPCScopes.ScopeSoftwareTrigger
method 8-85
xPCScopes.ScopeStart method 8-86
xPCScopes.ScopeStop method 8-87
xPCScopes.TargetScopeGetGrid method 8-88
xPCScopes.TargetScopeGetMode method 8-89
xPCScopes.TargetScopeGetModeStr
method 8-90
xPCScopes.TargetScopeGetViewMode
method 8-91
xPCScopes.TargetScopeGetYLimits
method 8-92
xPCScopes.TargetScopeSetGrid method 8-93
xPCScopes.TargetScopeSetMode method 8-94
xPCScopes.TargetScopeSetViewMode
method 8-95
xPCScopes.TargetScopeSetYLimits
method 8-96
xPCScRemSignal function 7-138
xPCScSetDecimation function 7-140
xPCScSetNumPrePostSamples function 7-141
xPCScSetNumSamples function 7-142
xPCScSetTriggerLevel function 7-143
xPCScSetTriggerMode function 7-144
xPCScSetTriggerScope function 7-146
xPCScSetTriggerScopeSample function 7-147
xPCScSetTriggerSignal function 7-148
xPCScSetTriggerSlope function 7-149
xPCScSoftwareTrigger function 7-151
xPCScStart function 7-152
xPCScStop function 7-153
xPCSetEcho function 7-154
xPCSetLastError function 7-155
xPCStartApp function 7-162
xPCStopApp function 7-163
xpctank model 4-5
xPCTarget 8-3
xPCTarget.AverageTET method 8-97
xPCTarget.GetAppName method 8-98
xPCTarget.GetExecTime method 8-99
xPCTarget.GetNumOutputs method 8-100
xPCTarget.GetNumParams method 8-101
xPCTarget.GetNumSignals method 8-102
xPCTarget.GetNumStates method 8-103
xPCTarget.GetOutputLog method 8-104
xPCTarget.GetParam method 8-105
xPCTarget.GetParamDims method 8-106
xPCTarget.GetParamIdx method 8-107
xPCTarget.GetParamName method 8-108
xPCTarget.GetSampleTime method 8-109
xPCTarget.GetSignal method 8-110
xPCTarget.GetSignalidsfromLabel
method 8-111
xPCTarget.GetSignalIdx method 8-113
xPCTarget.GetSignalLabel method 8-112
xPCTarget.GetSignalName method 8-114
xPCTarget.GetSignals method 8-115
xPCTarget.GetSignalWidth method 8-117
xPCTarget.GetStateLog method 8-118
xPCTarget.GetStopTime method 8-119
xPCTarget.GetTETLog method 8-120
xPCTarget.GetTimeLog method 8-121
xPCTarget.GetxPCError method 8-122
xPCTarget.Init method 8-123
xPCTarget.IsAppRunning method 8-124
xPCTarget.IsOverloaded method 8-125
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
Index-5
Index
xPCTarget.isxPCError method 8-126
xPCTarget.LoadApp method 8-127
xPCTarget.MaximumTET method 8-129
xPCTarget.MaxLogSamples method 8-130
xPCTarget.MinimumTET method 8-131
xPCTarget.NumLogSamples method 8-132
xPCTarget.NumLogWraps method 8-133
xPCTarget.SetParam method 8-134
xPCTarget.SetSampleTime method 8-135
xPCTarget.SetStopTime method 8-136
xPCTarget.StartApp method 8-137
xPCTarget.StopApp method 8-138
Index-6
xPCTarget.UnloadApp method 8-139
xPCTargetPing function 7-164
xPCTgScGetGrid function 7-165
xPCTgScGetMode function 7-166
xPCTgScGetViewMode function 7-167
xPCTgScGetYLimits function 7-168
xPCTgScSetGrid function 7-169
xPCTgScSetMode function 7-170
xPCTgScSetViewMode function 7-171
xPCTgScSetYLimits function 7-172
xPCUnloadApp function 7-173
www.MatlabSite.com | ‫ﻣﺘﻠﺐ ﺳﺎﯾﺖ‬
‫ﻣﺮﺟﻊ آﻣﻮزش ﺑﺮﻧﺎﻣﻪﻧﻮﯾﺴﯽ ﻣﺘﻠﺐ در اﯾﺮان‬
‫معرفی چند منبع در زمینه آموزش برنامه نویسی ‪ MATLAB‬یا متلب‬
‫کتاب های به زبان انگلیسی‬
‫عنوان‪Matlab, Third Edition: A Practical Introduction to :‬‬
‫‪Programming and Problem Solving‬‬
‫ترجمه عنوان‪ :‬متلب‪ :‬مقدمه ای عملی بر برنامه نويسی و حل مساله‪ ،‬چاپ سوم‬
‫مولفین‪Stormy Attaway :‬‬
‫سال چاپ‪2013 :‬‬
‫انتشارات‪Butterworth-Heinemann :‬‬
‫کتاب های به زبان فارسی‬
‫عنوان‪ :‬اصول و مبانی متلب برای علوم مهندسی‬
‫مولفین‪ :‬برايان هان‪ ،‬دانیل تی‪ ،‬والنتین‬
‫مترجمین‪ :‬رامین موالنا پور‪ ،‬سارا موالناپور‪ ،‬نینا اسدی پور‬
‫انتشارات‪ :‬سها دانش‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB For Dummies :‬‬
‫ترجمه عنوان‪ :‬تلب به زبان ساده‬
‫مولفین‪Jim Sizemore, John Paul Mueller :‬‬
‫سال چاپ‪2014 :‬‬
‫انتشارات‪For Dummies :‬‬
‫عنوان‪ :‬کاربرد ‪ MATLAB‬در علوم مهندسی‬
‫مولفین‪ :‬حیدرعلی شايانفر‪ ،‬حسین شايقی‬
‫انتشارات‪ :‬ياوريان‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Essential MATLAB for Engineers and Scientists :‬‬
‫عنوان‪ :‬برنامه نويسی ‪ MATLAB‬برای مهندسان‬
‫ترجمه عنوان‪ :‬آنچه بايد مهندسین و دانشمندان از متلب بدانند‬
‫مولفین‪ :‬محمود کشاورز مهر‪ ،‬بهزاد عبدی‬
‫مولفین‪Brian Hahn, Daniel Valentine:‬‬
‫سال چاپ‪2013 :‬‬
‫انتشارات‪Academic Press :‬‬
‫انتشارات‪ :‬نوپردازان‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB: An Introduction with Applications :‬‬
‫عنوان‪ :‬آموزش کاربردی مباحث پیشرفته با ‪MATLAB‬‬
‫ترجمه عنوان‪ :‬مقدمه ای بر متلب و کاربردهای آن‬
‫مولفین‪ :‬نیما جمشیدی‪ ،‬علی ابويی مهريزی‪ ،‬رسول مواليی‬
‫مولف‪Amos Gilat :‬‬
‫انتشارات‪ :‬عابد‬
‫سال چاپ‪2014 :‬‬
‫انتشارات‪Wiley :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB For Beginners: A Gentle Approach:‬‬
‫عنوان‪ :‬کاملترين مرجع آموزشی و کاربردی ‪MATLAB‬‬
‫ترجمه عنوان‪ :‬متلب برای افراد مبتدی با يک رويکرد تدريجی‬
‫مولفین‪ :‬علی اکبر علمداری‪ ،‬نسرين علمداری‬
‫مولف‪Peter I. Kattan:‬‬
‫انتشارات‪ :‬نگارنده دانش‬
‫سال چاپ‪2008 :‬‬
‫انتشارات‪CreateSpace Independent Publishing Platform :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪MATLAB for Engineers :‬‬
‫عنوان‪ :‬برنامه نويسی ‪ MATLAB‬برای مهندسین‬
‫ترجمه عنوان‪ :‬متلب برای مهندسین‬
‫مولف‪ :‬استفن چاپمن‬
‫مولف‪Holly Moore :‬‬
‫سال چاپ‪2011 :‬‬
‫انتشارات‪Prentice Hall :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Mastering MATLAB :‬‬
‫ترجمه عنوان‪ :‬تسلط بر متلب‬
‫مولفین‪Duane C. Hanselman, Bruce L. Littlefield :‬‬
‫سال چاپ‪2011 :‬‬
‫انتشارات‪Prentice Hall :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫مترجم‪ :‬سعدان زکائی‬
‫انتشارات‪ :‬دانشگاه صنعتی خواجه نصیرالدين طوسی‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪ :‬آموزش گام به گام محاسبات عددی با متلب‬
‫مولف‪ :‬کلیو مولر‬
‫مترجم‪ :‬رسول نصیری‬
‫انتشارات‪ :‬نشر گستر‬
‫لینک دسترسی‪ :‬لینک‬
‫منابع آموزشی آنالین‬
‫عنوان‪ :‬مجموعه فرادرسهای برنامهنويسی متلب‬
‫مدرس‪ :‬دکتر سید مصطفی کالمی هريس‬
‫مدت زمان‪ ۹ :‬ساعت و ‪ ۳‬دقیقه‬
‫زبان‪ :‬فارسی‬
‫ارائه دهنده‪ :‬فرادرس‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪ :‬مجموعه فرادرسهای متلب برای علوم و مهندسی‬
‫مدرس‪ :‬دکتر سید مصطفی کالمی هريس‬
‫مدت زمان‪ 14 :‬ساعت و ‪ 2۲‬دقیقه‬
‫زبان‪ :‬فارسی‬
‫ارائه دهنده‪ :‬فرادرس‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪ :‬مجموعه فرادرسهای برنامه نويسی متلب پیشرفته‬
‫مدرس‪ :‬دکتر سید مصطفی کالمی هريس‬
‫مدت زمان‪ ۲ :‬ساعت و ‪ 12‬دقیقه‬
‫زبان‪ :‬فارسی‬
‫ارائه دهنده‪ :‬فرادرس‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Introduction to Programming with MATLAB :‬‬
‫ترجمه عنوان‪ :‬آشنايی با برنامهنويسی متلب‬
‫مدرسین‪Akos Ledeczi, Michael Fitzpatrick, Robert Tairas :‬‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪Vanderbilt University :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Introduction to MATLAB :‬‬
‫ترجمه عنوان‪ :‬مقدمهای بر متلب‬
‫مدرس‪Danilo Šćepanović :‬‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪MIT OCW :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Up and Running with MATLAB :‬‬
‫ترجمه عنوان‪ :‬شروع سريع کار با متلب‬
‫مدرس‪Patrick Royal :‬‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪lynda.com :‬‬
‫لینک دسترسی‪ :‬لینک‬
‫عنوان‪Modelling and Simulation using MATLAB :‬‬
‫ترجمه عنوان‪ :‬مدلسازی و شبیهسازی با استفاده از متلب‬
‫مدرسین‪ Prof. Dr.-Ing. Georg Fries :‬و دیگران‬
‫زبان‪ :‬انگلیسی‬
‫ارائه دهنده‪iversity.org :‬‬
‫لینک دسترسی‪ :‬لینک‬
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement