With software programming, you can more flexible implementation of a variety of unconventional communications.
Since the self-written program runs at the engineering station/operator station, it takes a certain amount of CPU time and memory. Therefore, when the amount of communication data is large and the communication speed is required to be fast, there is no "exception report" mechanism for professional communication software. It is recommended not to use the method of self-developing programs.
Since self-written programs usually do not have a "data caching" mechanism, they should be used with caution when transferring very important data.
The main work of self-programming is two aspects, one is the reading, writing and processing of I/A data, and the other is the realization of communication.
Usually develop communication software by itself: serial communication (such as intelligent front-end), TCP/IP communication (such as real-time data transmission), FTP communication (such as regular transmission of report text), TCP/IP-based MODBUS protocol communication.
The above communication methods are different in the implementation of communication, but the data read and write operations in I/A's are the same. Next, the main functions and methods of software programming will be explained:
1.I/A's data reading and writing and processing
Foxboro's I/A's system provides powerful internal programming functions (C functions, FORTRAN), including:
lOMCALL function – implements read and write operations of internal data in the I/A's system.
The main functions are:
2intgetval(char*name, intobj_type, intimport, char*value, unsignedint*status, intdata_len)
This function implements a single data read operation.
2intom_getval(char*name, intobj_type, intimport, charvalue, unsignedint*status, intdata_len, PSAP_ADDR*psap_ptr)
This function implements a single data read operation, which uses a PSAP pointer.
2intsetval(char*name, intobj_type, intimport, char*value, unsigned*status, intdata_len)
This function implements a single data write operation.
2intom_setval(char*name, intobj_type, intimport, char*value, unsigned*status, intdata_len, PASP_ADDR*psap_ptr);
This function implements a single data write operation, which uses a PSAP pointer.
2intomopen(structom_header_node*om_descriptor, intopen_id)
This function implements a LIST to prepare for data read and write operations.
2intomread(intomopen_id, intsize_list, structvalue*var_list)
This function implements reading data from an open LIST.
2intomwrite(intomopen_id, intsize_list, structvalue*var_list);
This function implements writing data to an open LIST.
2intomclose(intopen_id,structom_header_node*header,structopen_var*var_list,structnet_addr*addr_tbl)
This function implements closing an LIST that is already open.
2 header files, OM structure and routines
#include
#include
#include
#include
#include
Main()
{
Structopen_varin_var_list[8];
Structheader_nodein_om_desc;
Structnet_adrin_net_adr_tbl[2];
Intin_open_id;
Intrtn;
Floatdelta_temp, delta_fc, delta_df;
Structvalue*in_data_list,*temp;
Inti;
Delta_temp=5.0;
Delta_fc=1.0;
Delta_df=0.5;
In_om_desc.task_status=OM_R_ACCESS;
In_om_desc.net_adr_tbl_ptr=in_net_adr_tbl;
In_om_desc.size_net_adr_tbl=2;
In_om_desc.open_list_ptr=in_var_list;
In_om_desc.size_open_list=8;
......
}
2 features
Using getval, setval, om_getval, om_setval functions for programming is relatively simple, but the efficiency is poor; programming with omopen, omread, omwrite, omclose requires complex declarations, programming is more complicated, but the program is universal (not supported by FOXAPI), efficiency high.
lFOXAPI function – implements I/A's system internal data read and write operations and powerful C/S structure programming.
The main functions are:
2intsbopen(int*gw_array,intnument,char*name_array,int*valtyp_array,intacctyp,float*delta_array,intclexit,intrsr,intwsr,float*wdelta_array,int*dset,int*index_array,int*error_array,int*reterr)
This function implements a read-write SET in a continuous update.
2intbread(intdset, long*value_array, int*status_array, int*reterr)
This function implements reading data from an already opened SET.
2intbwrite(intdset, long*value_array, int*error_array, int*reterr)
This function implements writing data to an already opened SET.
2intclsset(intdset, int*reterr)
This function implements closing an open SET, freeing up the memory space used by the program, and releasing control of the data in the CP.
2 head function, FOXAPI structure definition and routine
#include
#include
#include
#include
#include
#include
#include
#defineOBJNUM100
#defineSETNUM20
Typedefunion
{
Longlval;
Shortival;
Floatfval;
Charbval;
}IAXVAL;
/*PredefinedParameterofI/Avalue*/
Staticintgw[SETNUM][OBJNUM];/*GatewayArray*/
Charname[SETNUM][OBJNUM][32];/*ObjectNameArray*/
Chardesc[SETNUM][OBJNUM][15];/*ObjectdescriptionArray*/
Staticintvaltype[SETNUM][OBJNUM];/*ObjectValueTypeArray*/
Staticintacctype=1;/*Read-onlyArray*/
Staticfloatrdelta[SETNUM][OBJNUM];/*ObjectsReadDeltaArray*/
Staticfloatwdelta[SETNUM][OBJNUM];/*ObjectsWriteDeltaArray*/
Interror[SETNUM][OBJNUM];/*ObjectsErrorArray*/
Intindex[SETNUM][OBJNUM];/*ObjectsIndexesArray*/
Intstatus[SETNUM][OBJNUM];/*ObjectsStatusArray*/
IAXVALvalue[SETNUM][OBJNUM];/*ObjectsValueArray*/
Staticintrsr=4;/*ReadScanRate*/
Staticintwsr=4;/*WriteScanRate*/
Staticintclexit=1;/*IgnoredinUNIX*/
Intreterr[SETNUM];/*OpenSetreturnErrorCode*/
/*PredefineParameterofutility*/
Intset[SETNUM];/*OpenSetNumber*/
intTotal_SET;/*TotalSetNumber*/
intLast_SET_Num;/*LastSetValueNuber*/
intTotal_Num;/*TotalNumberofobjects*/
intTotal_File;/*TotaloutputfilesNumber*/
intINTERVAL;/*Communicateinterval*/
intCol_Num;/*Valuenumberperline*/
Main()
{
...scopen(gw[i],k,name[i],valtype[i],acctype,rdelta[i],clexit,rsr,\
Wsr, wdelta[i], &set[i], index[i], error[i],&reterr[i]);
Printf("ReturnErrorCode=%-d",reterr[i]);
Printf("ReturnDataSet=%-d",set[i]);
...rtn=bread(set[i],value[i],status[i],&reterr[i]);
If(reterr[i]!=0)
{
Printf("BufferedReadObjectsError%d, %d, %d", rtn,\
Reterr[i],set[i]);
}
...for(i=0;i
{
Clsset(set[i],&reterr[i]);
}
......
}
2 features
Programming with FOXAPI is relatively simple, and the program efficiency is also very high, but the execution of the program requires FOXAPI support. The compiled program can only be run on AW and AP machines equipped with FOXAPI. The PI real-time database is actually an application written using the FOXAPI function.
lHICALL function – implements human-machine interface (HUMANINTERFACE) programming with I/A's style, including display elements such as rectangle, arc, fill color; dialog box, menu structure, mouse and keyboard driver, query, file driver, etc. The entire I/A's man-machine interface is written through these functions.
lIPCALL function – implements I/A's system internal communication programming, such as: SOE software.
lICCAPI function – implements the I/A's control processor C related operations in the CP.
l Math Library – provides call functions for various classic numerical calculations.
l Physical property library – provides call functions for various physical property calculations, including calculations for water, steam, and entropy.
2intvpt(floatp,floatt,float*v)
This function calculates the volume of steam based on the pressure and temperature of the steam.
2inthpt_stm(floatp,floatt,float*h)
This function calculates the enthalpy of steam based on the pressure and temperature of the steam.
2intspt_stm(floatp,floatt,float*s)
This function calculates the entropy of the steam based on the pressure and temperature of the steam.
2inthpt_wtr(floatp,floatt,float*h)
This function calculates the enthalpy of water based on the pressure and temperature of the water.
2intspt_wtr(floatp,floatt,float*s)
This function calculates the entropy of water based on the pressure and temperature of the water.
2inthpt_air(floatp,floatt,float*h)
This function calculates the enthalpy of the air based on the pressure and temperature of the air.
2intspt_air(floatp,floatt,float*s)
This function calculates the entropy of the air based on the pressure and temperature of the air.
lINFORMIX programming.
In some cases where historical data needs to be manipulated, INFORMIX and E-SQL can be used for programming.
2. Communication realization
In the specific communication hardware used in software programming communication, RS-232 communication can be realized through the serial port, or FTP communication and TCP/IP communication can be realized through AUI network card, BNC network card and RJ-45 network card.
When other devices communicating with I/A's (such as intelligent data acquisition front-end, gps, automatic synchronization devices, etc.) can provide serial communication, and the number of communication points is small, it is not very economical to use specialized hardware to realize communication hardware. In this case, RS-232 can be used for communication.
When communicating with RS-232, the communication port should be initialized first, and then the RS-232 communication protocol (RXD, TXD, RTS, CTS, DSR, DTR, DCD signals) can be used to send commands and accept data.
The following is a routine to initialize the port:
Intinit_port(intk, int*fd, char*comport)
{
Intsavef;
If((*fd=open(comport,O_RDWR|O_NDELAY|O_NONBLOCK)))0)
Return(1);
Fflush(stdout);
Fflush(stdin);
If(savef=fcntl(*fd,F_GETFL,0)“0)
Return(2);
If(fcntl(*fd,F_SETFL,savef|O_NDELAY)"0)
Return(3);
If(ioctl(*fd,TCGETS,&termio)"0)
Return(4);
/*Settheportparameteras9600Baudrate,8databits,1siopbit,
Enablereceiver, Evenparityenable*/
Termio.c_cflag=B9600|CS8|CREAD|PARENB|CLOCAL;
Termio.c_cflag&=~CSTOPB;
Termio.c_cflag&=~PARODD;
Termio.c_iflag=INPCK;
Termio.c_iflag&=~ISTRIP;
Termio.c_lflag=0;
Termio.c_oflag=0;
Termio.c_cc[VMIN]=1;
Termio.c_cc[VTIME]=0;
If(ioctl(*fd,TCSETS,&termio)"0)
Return(5);
Sleep(1);
Return(0);
}
The following is a routine for reading and writing ports:
Intcomm(unsignedcharnum, intfd)
{
intI, rtn, tioc;
unsignedcharT[200];
Unsignedcharbuff[200];
...ioctl(fd,TIOCMGET,&tioc);
Tioc=tioc|TIOCM_RTS;
Ioctl(fd,TIOCMSET,&tioc);
...write(fd,T,200);
Rtn=ioctl(fd,TCSBRK,1);
Strcpy(buf,"",200);
Read(fd,buf,200);
}
If you are communicating with I/A's PC or other dcs, the better communication method is to use RJ-45 and other communication ports to communicate according to FTP protocol or TCP/IP protocol. Among them, the efficiency of FTP communication is low, and there is always a disk read/write operation, which has a great influence on the machine, but this method is relatively simple and easy to implement. Therefore, when communication is infrequent (recommended for more than one hour), This method can also be used. More often, it is recommended to use the TCP/IP protocol for communication.
When using TCP/IP for communication, there are two protocols to choose from: TCP and UDP. TCP (Transport Control Protocol) is connection-oriented. It provides high-reliability services, especially for transmitting a large amount of message information. UDP (UserDatagramProtocol) is unconnected. It provides efficient services and is suitable for occasions where a small amount of message information is transmitted.
The program of UDP communication is also easy to write. Just specify the client's IP address (or host name) and the port number. The following is a UDP initialization routine:
#include
#include
#include
#include
#include
#include
Intsock,length;
Structsockaddr_in,sockname;
Charbuff[1024];
intInit_Socket()
{
Char*clientName=“AW5101â€;
intportNum=10002;
Structhostent*hp, *gethostbyname();
/*Creatsocketonwhichtosend.*/
Sock=socket(AF_INET, SOCK_DGRAM, 0);
If(sock==-1)
{
Perror("opendatagramsocketerr0r");
Exit(1);
}
Hp=gethostbyname(clientName);
If(hp==(structhostent*)0)
{
Printf("unkownhost:%s",clientName);
Exit(2);
}
Memcpy((char*)&sockname.sin_addr,(char*)hp-"h_addr,hp-"h_length);
Sockname.sin_family=AF_INET;
Sockname.sin_port=htons(atoi(portNum);
Return(0);
}......
With the improvement of people's quality of life, people's lifestyles have also become varied. Different kinds of recreational products are starting to appear in people's lives, such as electronic cigarettes. The emergence of e-cigarettes represents a part of young people's thinking and means that electronic products are beginning to show a trend towards diversity.
simply replace the pods. The Pod system uses an integrated pod rather than a tank for higher nicotine strength and provides low power traction. the Pod system is rechargeable and has a longer life and higher battery capacity than disposable electronic cigarettes.
Our company Pod system has a built-in 380mAh battery and a USB charging port on the bottom. In comparison, the Pod system has a built-in battery of only 180mAh, but the Pod system charges much faster.
Our electronic cigarettes are of rechargeable construction. The first time you use the charger to charge, it is recommended to use up the remaining power before filling up, this is to ensure the performance of the battery.
Vape Pod System Oem,Vape Pod Oem,Close Pod Oem,Thc Pod Disposable
Shenzhen MASON VAP Technology Co., Ltd. , https://www.disposablevapepenfactory.com