Pointwise Plugin SDK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apiGRDPUtils.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Pointwise Plugin utility functions
4  *
5  * (C) 2021 Cadence Design Systems, Inc. All rights reserved worldwide.
6  *
7  ***************************************************************************/
8 
9 #ifndef _APIGRDPUTILS_H_
10 #define _APIGRDPUTILS_H_
11 
12 #include <stdio.h>
13 #include <time.h>
14 
15 #include "apiGRDP.h"
16 #include "apiPWP.h"
17 #include "apiPWPUtils.h"
18 #include "apiGridModel.h"
19 
20 extern "C" {
21 
22 /************************************************************************/
44 // include impl-defined instance runtime data types.
45 // Must also define the macro GRDP_RUNTIME_INSTDATADECL
46 #include "rtGrdpInstanceData.h"
47 
55 #if !defined(GRDP_RUNTIME_INSTDATADECL)
56 # define GRDP_RUNTIME_INSTDATADECL
57 #endif
58 
59 
60 /***********************************************************/
61 /***********************************************************/
73 //***************************************************************************
74 //***************************************************************************
102  /* add new group enum values before this line */
103 
106  GRDP_CLKS_SIZE,
108  GRDP_CLKS_LAST = GRDP_CLKS_SIZE-1
110  // sdkINTERNALS
111 };
112 
113 
114 /************************************************************************/
117 struct GRDP_RTITEM {
123 
127 
140  FILE * fp;
141 
152 
158 
164 
165 
173  PWP_UINT32 progTotal;
174 
180  PWP_UINT32 progComplete;
181 
187  clock_t clocks[GRDP_CLKS_SIZE];
188 
194  PWP_BOOL opAborted;
195  // sdkINTERNALS
197 
201 };
202 
203 
204 /************************************************************************/
218 extern GRDP_RTITEM grdpRtItem[];
219 
220 
221 /************************************************************************/
228  /* DOXGRP_APIGRDP_UTILS_DATA */
230 
231 
232 
233 //***************************************************************************
234 //***************************************************************************
242 /************************************************************************/
253 
254 
255 /************************************************************************/
264 GRDP_RTITEM* grdpFindFormatByName (const char name[]);
265  /* DOXGRP_APIGRDP_UTILS_SDKGRDP */
267 
268 
269 
270 //***************************************************************************
271 //***************************************************************************
283 /************************************************************************/
329 
330 
331 /************************************************************************/
345 
346 
347 /************************************************************************/
358 
359 
360 /************************************************************************/
371 
372 
373 /************************************************************************/
388  /* DOXGRP_APIGRDP_UTILS_PROGRESS */
390 
391 
392 //***************************************************************************
393 //***************************************************************************
406 //-------------------------------------------------------------------------
413 void grdpSendDebugMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
414 
415 //-------------------------------------------------------------------------
422 void grdpSendInfoMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
423 
424 //-------------------------------------------------------------------------
431 void grdpSendWarningMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
432 
433 //-------------------------------------------------------------------------
440 void grdpSendErrorMsg (GRDP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
441  /* DOXGRP_APIGRDP_UTILS_MSGS */
443 
444 
445 //***************************************************************************
446 //***************************************************************************
456 //-------------------------------------------------------------------------
483  const char value[], const char access[], const char desc[],
484  const char range[]);
485 
486 
487 //-------------------------------------------------------------------------
502 PWP_BOOL grdpAssignInfoValue(const char name[], const char value[],
503  const bool create = true);
504 
505 
506 //-------------------------------------------------------------------------
521 PWP_BOOL grdpAssignInfoValueInt(const char name[], const PWP_INT value,
522  const bool create = true);
523 
524 
525 //-------------------------------------------------------------------------
540 PWP_BOOL grdpAssignInfoValueUInt(const char name[], const PWP_UINT value,
541  const bool create = true);
542 
543 
544 //-------------------------------------------------------------------------
559 PWP_BOOL grdpAssignInfoValueReal(const char name[], const PWP_REAL value,
560  const bool create = true);
561 
562 
563 //-------------------------------------------------------------------------
578 PWP_BOOL grdpAssignInfoValueBool(const char name[], const bool value,
579  const bool create = true);
580 
581 
582 //-------------------------------------------------------------------------
597 PWP_BOOL grdpAssignInfoValueEnum(const char name[], const char value[],
598  bool create = true);
599  /* DOXGRP_APIGRDP_UTILS_VARS */
601 
602 
603 //***************************************************************************
604 //***************************************************************************
613 /************************************************************************/
616 #define GRDP_RT_IMPORT_CONDITIONS(rti) (rti)->pReadInfo->importConditions
617 
618 
619 /************************************************************************/
623 #define GRDP_RT_IS_ABORTED(rti) PWP_CAST_BOOL((rti)->opAborted)
624 
625 /************************************************************************/
628 #define GRDP_RT_ABORT(rti) ((rti)->opAborted = PWP_TRUE)
629 
630 /************************************************************************/
633 #define GRDP_IS_CLKS_ID(id) \
634  PWP_CAST_BOOL(((id) >= 0) && ((id) <= GRDP_CLKS_LAST))
635 
636 /************************************************************************/
639 #define GRDP_RT_CLKS_ID(rti, id) (GRDP_IS_CLKS_ID(id)? (rti)->clocks[id]: 0)
640 
641 /************************************************************************/
645 #define GRDP_RT_CLKS_DIFF(rti, startId, endId) \
646  ((GRDP_IS_CLKS_ID(startId) && GRDP_IS_CLKS_ID(endId)) ? \
647  ((rti)->clocks[endId] - (rti)->clocks[startId]) : 0)
648 
649 /************************************************************************/
653 #define GRDP_RT_CLKS_POLL(rti, id) \
654  GRDP_RT_CLKS_DIFF(rti, id, GRDP_CLKS_PROGINCR)
655 
656 /************************************************************************/
660 #define GRDP_RT_CLKS_POLL_STEP(rti) \
661  GRDP_RT_CLKS_POLL(rti, GRDP_CLKS_BEGSTEP)
662 
663 /************************************************************************/
667 #define GRDP_RT_CLKS_DIFF_STEP(rti) \
668  GRDP_RT_CLKS_DIFF(rti, GRDP_CLKS_BEGSTEP, GRDP_CLKS_ENDSTEP)
669 
670 /************************************************************************/
674 #define GRDP_RT_CLKS_POLL_TOTAL(rti) \
675  GRDP_RT_CLKS_POLL(rti, GRDP_CLKS_PROGINIT)
676 
677 /************************************************************************/
681 #define GRDP_RT_CLKS_DIFF_TOTAL(rti) \
682  GRDP_RT_CLKS_DIFF(rti, GRDP_CLKS_PROGINIT, GRDP_CLKS_PROGEND)
683 
684 /************************************************************************/
688 #define GRDP_CLKS_TO_MSECS(c) ((PWP_INT32)((c) * 1000) / CLOCKS_PER_SEC)
689 
690 /************************************************************************/
694 #define GRDP_CLKS_TO_SECS(c) ((PWP_INT32)(c) / CLOCKS_PER_SEC)
695 
696 /************************************************************************/
700 #define GRDP_CLKS_TO_MINS(c) (GRDP_CLKS_TO_SECS(c) / 60)
701 
702 /************************************************************************/
706 #define GRDP_CLKS_TO_HOURS(c) (GRDP_CLKS_TO_MINS(c) / 60)
707 
708 /************************************************************************/
713 #define GRDP_CLKS_TO_HMS(c, h, m, s) \
714  (s = GRDP_CLKS_TO_SECS(c)), \
715  (h = s / 3600), (s -= h * 3600), \
716  (m = s / 60), \
717  (s -= m * 60)
718 
719 /************************************************************************/
722 #define GRDP_CLKS_TO_FSECS(c) ((PWP_FLOAT)(c) / (PWP_FLOAT)CLOCKS_PER_SEC)
723 
730 } /* extern "C" */
731 
732 #endif /* _APIGRDPUTILS_H_ */
PWP_BOOL grdpPublishValueDefinition(const char name[], PWP_ENUM_VALTYPE type, const char value[], const char access[], const char desc[], const char range[])
Creates a collection of key/value pairs that represent a published grid import attribute definition...
PWP_ENUM_VALTYPE
Supported PWP-API getValue() transfer types.
Definition: apiPWP.h:696
The data representing a grid importer instance.
Definition: apiGRDPUtils.h:117
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
Pointwise Plugin API (PWP-API)
GRDP_RTITEM grdpRtItem[]
The runtime array of GRDP_RTITEM items.
Definition: apiGRDP.cxx:27
PWP_BOOL grdpAssignInfoValueReal(const char name[], const PWP_REAL value, const bool create)
Creates a key/PWP_REAL-value pair that defines a GRDP info attribute.
GRDP_RTITEM * grdpFindFormatByName(const char name[])
Find an item in grdpRtItem[] by it&#39;s name.
PWGM_HGRIDMODEL model
Runtime grid model handle to import.
Definition: apiGRDPUtils.h:157
void grdpSendDebugMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a debug text message (PWP_MSGID_DEBUG) to the framework.
PWU_RTITEM * pApiData
Pointer to the associated PWU_RTITEM structure.
Definition: apiGRDPUtils.h:126
Pointwise Grid Model API Specification (PWGM-API)
void grdpSendErrorMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an error text message (PWP_MSGID_ERROR) to the framework.
PWP_BOOL grdpAssignInfoValueInt(const char name[], const PWP_INT value, const bool create)
Creates a key/PWP_INT-value pair that defines a GRDP info attribute.
Grid import read control information.
Definition: apiGRDP.h:108
Customizes the typedef GRDP_RTITEM declaration.
PWP_BOOL grdpAssignInfoValue(const char name[], const char value[], const bool create)
Creates a key/string-value pair that defines a GRDP info attribute.
PWP_BOOL grdpProgressEnd(GRDP_RTITEM *pRti, const PWP_BOOL ok)
Ends all progress tracking.
PWP_BOOL grdpAssignInfoValueBool(const char name[], const bool value, const bool create)
Creates a key/bool-value pair that defines a GRDP info attribute.
PWP_UINT32 grdpFormatCnt
The number of entries in grdpRtItem[] array.
Definition: apiGRDP.cxx:33
Unformatted file data block.
Definition: apiPWPUtils.h:344
PWP_BOOL grdpProgressInit(GRDP_RTITEM *pRti, PWP_UINT32 cnt)
Initializes a progress tracking session.
int PWP_BOOL
logical value
Definition: apiPWP.h:303
The runtime data representing a PWP-API suported by a plugin.
Definition: apiPWPUtils.h:42
GRDP_RTITEM * grdpFindFormatById(PWP_UINT32 id)
Find an item in grdpRtItem[] by it&#39;s id.
GRDP_ENUM_CLOCKS
Supported GRDP clock id values.
Definition: apiGRDPUtils.h:95
The information returned for each supported GRDP importer.
Definition: apiGRDP.h:70
void grdpSendWarningMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a warning text message (PWP_MSGID_WARNING) to the framework.
PWP_BOOL grdpProgressEndStep(GRDP_RTITEM *pRti)
Completes a progress tracking major step.
GRDP_FORMATINFO FormatInfo
The Grid Import Plugin format data.
Definition: apiGRDPUtils.h:122
PWP_BOOL grdpProgressIncr(GRDP_RTITEM *pRti)
Completes a progress tracking sub-step.
PWP_UINT32 PWP_UINT
unsigned integer same size as void*
Definition: apiPWP.h:285
#define GRDP_RUNTIME_INSTDATADECL
Implementation defined runtime instance data macro.
PWP_BOOL grdpProgressBeginStep(GRDP_RTITEM *pRti, PWP_UINT32 total)
Begins a progress tracking step.
PWP_INT32 PWP_INT
integer same size as void*
Definition: apiPWP.h:282
FILE * fp
Runtime FILE pointer.
Definition: apiGRDPUtils.h:140
An opaque handle to a grid model.
Definition: apiGridModel.h:326
const GRDP_READINFO * pReadInfo
Runtime grid import settings.
Definition: apiGRDPUtils.h:163
PWU_UNFDATA unfData
Unformatted file I/O data.
Definition: apiGRDPUtils.h:151
PWP_BOOL grdpAssignInfoValueEnum(const char name[], const char value[], const bool create)
Creates a key/enum-value pair that defines a GRDP info attribute.
void grdpSendInfoMsg(GRDP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an info text message (PWP_MSGID_INFO) to the framework.
double PWP_REAL
64-bit real
Definition: apiPWP.h:264
PWP_BOOL grdpAssignInfoValueUInt(const char name[], const PWP_UINT value, const bool create)
Creates a key/PWP_UINT-value pair that defines a GRDP info attribute.
Data and functions useful to PWP-API compliant plugins.
Pointwise Grid Import Plugin API (GRDP-API)