/*-----------------------------------------------------------------------------
$Archive: /PI/3.2/utilities/apiutil/apisnap.c $
-------------------------------------------------------------------------------
Copyright (c) 1995-2000 OSI Software, Inc. All rights reserved.
Unpublished - rights reserved under the copyright law of the United States.
USE OF A COPYRIGHT NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
OR DISCLOSURE.
THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE SECRETS OF
OSI SOFTWARE, INC. USE, DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT
THE PRIOR EXPRESS WRITTEN PERMISSION OF OSI SOFTWARE, INC.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and
Computer Software clause at DFARS 252.227.7013
OSI Software, Inc.
777 Davis Street, Suite 250, San Leandro CA 94577
-------------------------------------------------------------------------------
Description:
apisnap.c
Example PI API program
-------------------------------------------------------------------------------
History:
$Log: /PI/3.2/utilities/apiutil/apisnap.c $
22 8/01/00 4:22p Ray
Changed retrieval of last archive value to use piar_getarcvaluex to get
a recent value, and then use its timestamps to bound the call to
piar_getarcvaluesx. This fixes a problem in UDA mapped points in which
the foreign system can't handle the wide time constraint.
21 8/01/00 1:36a Ray
Replaced C++ comment with C comment.
20 8/01/00 1:34a Ray
Restored original method of finding previous archive value (using
piar_getvaluex) inside ifdef _ARCVALUE. Technique of finding last two
years of data with value count of 2 tends to break UDA mapped points
when foreign systems cannot honor value count before time range.
19 4/26/:0 9:37a Charlie
Added unix variations of identification strings used with the 'what'
command.
18 4/06/00 7:29p Charlie
Added VSS id strings for file revision.
17 4/06/00 7:27p Charlie
Fixed printout of archive value timestamp. Made more useful routines
for printing values.
16 3/10/00 1:58p Charlie
Changed time output to check returned PI2time for bad value (-1) and
set to zero if bad. Changed format string to use int cast of fraction.
15 12/17/99 6:18p Charlie
Added PI_Type_PItimestamp and PI2.
14 11/03/99 4:25p Charlie
Use ifdef hpux_main for HP C compiler.
13 11/03/99 3:46p Charlie
Added new compiler define of _main for HPUX C/C++ _main.
12 6/18/99 10:32a Piadmin
Eliminate compiler warnings (HPUX didn't like initializing two
variables on the same line).
11 6/08/99 3:29p Charlie
Changed archive retrieval to start from the snapshot time and search
backward in time until the next archive value is found. This allows
the snapshot and last archive values to have the same timestamp. Added
multiple tagnames on the command line.
10 5/06/99 1:17p Charlie
Added newline after all output.
9 2/01/99 5:27p Charlie
Remove ANSIC compiler warning for strlen compare.
8 1/25/99 9:23a Charlie
Added option to enter point number instead of tagname. Leading
backslash is used to indicate point number.
7 9/04/98 1:12p Charlie
6 9/04/98 10:54a Charlie
Added printout of flags if set.
5 8/26/98 5:07p Charlie
Format time string subseconds and type casts in mem-functions.
3 8/26/98 3:22p Charlie
Added support for extended pointtypes and digital strings up to 80
chars. Added option to enter server and tagname arguments which will
retrieve one snapshot, then exit. Updated copyright.
2 4/25/97 8:49a Harry
Check in Jon's changes on SCCS from Feb 5
-------------------------------------------------------------------------------
24-nov-93 jhp use pitm_delay for delays
04-may-94 jhp added reconnection loop
09=may-94 jhp added version print
13-jun-96 jhp exit if cannot connect
17-jun-96 jhp tagpreferred, added piar_value
05-Feb-97 jhp better data representation on failed getsnap and arcvalue
-----------------------------------------------------------------------------*/
#ifdef WIN32
#pragma comment(exestr, "$Workfile: apisnap.c $ $Revision: 22 $")
#elif defined(aix)
#pragma comment(user, "@(#)$Workfile: apisnap.c $ $Revision: 22 $")
#elif defined(hpux)
#pragma VERSIONID "@(#)$Workfile: apisnap.c $ $Revision: 22 $"
#else/* solaris, osf1 */
#pragma ident "@(#)$Workfile: apisnap.c $ $Revision: 22 $"
#endif
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "piapix.h"
#define TAG_LEN 80
typedef struct
{
char tagname[TAG_LEN+1];
int32 point;
char descriptor[27];
char engunit[32];
char itag[33];
char pt_type;
PIvaluetype pt_typex;
float64 rval, arcrval;
int32 ival, arcival;
void *bval, *arcbval;
uint32 bsize, arcbsize;
int32 istat, arcistat;
int16 flags, arcflags;
PITIMESTAMP ts, arcts;
} TAG;
static int dosnap ( char * );
static int32 lastdayofmonth ( int32 month );
static void print_taginfo ( TAG *tag );
#define MAXTRYS 20
#ifndef TRUE
#define TRUE -1
#endif
#ifndef FALSE
#define FALSE 0
#endif
int main ( int argc, char **argv )
{
int32 result = 1;
int i, trys = 0;
int32 connection = FALSE;
char name[32], address[32];
char version[32];
char tname[TAG_LEN+1];
/* The line below for the HPUX C compiler when linking with C++. */
#ifdef hpux_main
_main();
#endif
if ( !piut_getapiversion ( version, sizeof(version) ) )
{
printf ( "\nPI-API version %s", version );
}
while ( TRUE )
{
if ( argc > 1 )
{ /* attempt connection to passed node name */
piut_setprocname ( "snap" );
printf ( "\n Attempting connection to %s", argv[1] );
while ( result && trys < MAXTRYS )
{
trys++;
result = piut_setservernode ( argv[1] );
if ( result )
{
printf ( "\n Error %d, connecting to %s", result, argv[1] );
return result;
}
else
{
connection = TRUE;
}
}
}
else /* attempt connection to default homenode */
{
printf ( "\n Attempting connection to Default homenode" );
while ( result && trys < MAXTRYS )
{
trys++;
result = piut_connect ( "snap" );
if ( result )
{
printf ( "\n Error %d, connecting to Default homenode", result );
return result;
}
else
{
if ( piut_netserverinfo ( name, 32, address,
32, &connection ) )
{
printf ( "\nConnected to DEFAULT pihome node" );
connection = TRUE;
}
else
{
printf ( "\nConnected to %s (%s)", name, address );
}
}
}
}
if ( !connection )
{
printf ( "\nError %ld connecting to PI Server node", result );
exit (1);
}
if (argc > 2)
{
/* Cycle through all tags after the host name. */
for (i=2; i<argc; i++)
{
strncpy(tname, argv[i], 80);
tname[TAG_LEN+1] = '\0';
if ( dosnap( tname ) )
{
trys = 0;
result = 1;
connection = FALSE;
printf ( "\nConnection lost attempting reconnection" );
break;
}
}
break;
} else {
tname[0] = '\0';
if ( do
PI数据库源码
4星 · 超过85%的资源 需积分: 44 133 浏览量
2012-11-07
11:48:19
上传
评论 1
收藏 1.99MB RAR 举报
aojian0501
- 粉丝: 0
- 资源: 4
最新资源
- 老飞飞搭建基础通用数据库V19数据库.rar
- jquery.js
- 机械设计多工位ACF贴胶带&预压设备sw18可编辑非常好的设计图纸100%好用.zip
- 基于Pytorch复现Point-Transformer,用于ShapeNet数据集点云分割
- 【医学影像分析】2D超声图像的分割检测(Ultrasound Nerve Segmentation - Kaggle数据集)
- 嘎嘎香的五款神仙谷歌插件
- .arch书源导入教程.mp4
- 贪心算法介绍及代码示例讲解
- CR13SP35MSI64 Crystal 水晶报表运行组件最后版本64位
- 图像分类数据集:玉米叶是否感染分类数据集(2分类,包含训练集、验证集)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈