Pi development interview

Source: Internet
Author: User
Tags tagname

Speaking of Pi-based software development, there are two main aspects,

1: Using piapi to directly operate pi. The advantage of this method is high efficiency and easy control of any operation. The disadvantage is that you need to purchase piapi. The following describes this method in detail;

2: Access PI through the OPC communication protocol agreed by the International Industrial Organization. The advantage of this method is that it is common, because as long as it is a real-time database, it will support OPC protocol, for more information about OPC, see my "[original] Learning series for the rise of China [original.

The following describes how to use piapi to perform PI operations based on pisdk:

1. First, check the PI connection:

C: int32 piut_setservernode (char piptr * servername );

C #: int piut_setservernode (string servername );

Servername [passed]: Server IP address or server name,

If the connection is successful, return 0. Note that if the firewall is developed, the connection may fail.

2. log on to pi

C: int32 piut_login (char piptr * username, char piptr * passwrd, int32 piptr * Valid );

C #: int piut_login (string username, string passwrd, ref int valid );

Username [passed]: user name, such as piadmin;

Passwrd [passed]: Login Password;

Valid [returned]: the access level returned by the server, as follows:

# Define Pino 0 (PI error );

# Define piread 1 (read-only );

# Define pireadwrite 2 (read/write );

If the logon is successful, 0 is returned;

3. Find the desired Vertex

C: int32 pipt_findpoint (char piptr * tagname, int32 piptr * PT );

C #: int pipt_findpoint (string tagname, ref int pt );

Tagname [passed]: The name of the vertex in PI;

PT [returned]: Index of the Return Point in PI;

If this point is successfully found, 0 is returned;

4. Disconnect

C: int32 piut_disconnect (void );

C #: int32 piut_disconnect (void );

0 is returned for successful disconnection;

At this point, follow the steps 1 and 2 to establish a connection with Pi, step 3 to find the desired point, step 4 to disconnect, and a basic PI operation is complete, the following describes some practical piapi functions, which are dominated by C ++. C # is similar to C.

◆ Required ID pitm_intsec (int32 piptr * TimeDate, int32 timearray [6]);

TimeDate [returned]: time used by Pi

Timearray [passed]: array of the storage time, as follows:

Timearray [0] month; // (1-12)

Timearray [1] day; // (1-31)

Timearray [2] year; // (four digit)

Timearray [3] hour; // (0-23)

Timearray [4] minute; // (0-59)

Timearray [5] Second; // (0-59)

This function converts a given time array to Pi time

◆ Required ID pitm_secint (int32 piptr * TimeDate, int32 timearray [6]);

TimeDate [passed]: time used by Pi

Timearray [returned]: array of the storage time, as follows:

This function converts a given PI time to a time array. For the format, refer to the previous one;

◆ Int32 piar_summary (int32 PT, int32 piptr * time1, int32 piptr * time2, float piptr * rval,

Float piptr * pctgood, int32 Code );

PT [passed]: vertex Index

Time1 [passed, returned]: Start Time, returns the corresponding time. If the code attribute is arcminimum, arcmaximum, arcstdev

Time2 [passed, returned]: Start Time, returns the corresponding time. If the code attribute is arcminimum, arcmaximum, arcstdev

Rval [returned]: returns the calculated value.

Pctgood [returned]: returns the quality of the computation results

Code [passed]: The calculation method is as follows:

# Define arctotal 0

# Define arcminimum 1

# Define arcmaximum 2

# Define arcstdev 3

# Define arcrange 4

# Define arcaverage 5

# Define arcmean 6

0 is returned for successful calculation,

There are two points worth noting: 1. when this function is used for calculation, the default conversion factor is 1, that is, the day. If you need your own time, convert the calculation result based on the conversion factor 1; 2. pctgood, this parameter returns the computing quality. If you need to multiply this quality during Statistical Computation, it is the real result;

◆ Int32 piar_compvalues (int32 PT, int32 piptr * count, int32 Times [], float rvals [], int32 istats [], int32 rev );

PT [passed]: vertex Index

Count [passed, returned]: specify the maximum number of returned data and the maximum number of actually returned data.

Times [passed, returned]: Specifies the query time period. Times [0] indicates the start time and returns the actual time of each data.

Rvals [returned]: returns data values.

Istats [returned]: returns the data status at each time point.

Rev [passed]: Specify the query direction. False (0) indicates the forward search based on the specified time. True indicates the Backward Search;

0 is returned if the search is successful;

It is worth noting that the last time returned by a query has not reached the specified time. At this time, the returned count is the maximum number of specified arrays, indicating that the query is not completed, you need to set the start time to the return end time and continue the query until the return value of count is smaller than the specified maximum value.

◆ Int32 pisn_getsnapshots (int32 piptr * PT, float piptr * rval, int32 piptr * ISTAT, int32 piptr * TimeDate,

Int32 piptr * error, int32 count );

PT [passed]: point to the vertex Index Array

Rval [returned]: returns the data of each point corresponding to the point index array.

ISTAT [returned]: returns the data status of each point corresponding to the point index array.

TimeDate [returned]: returns the time corresponding to each data value.

Error [returned]: an error is returned.Code

Count [passed]: Specify the array size

0 is returned for successful query,

Note that the value returned by this function is only the latest data in the snapshot.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.