Code: Select all
// Fonction: La fonction ouvre la vue type de l'équipement selon les paramètres lpszBlocType
#include "apdefap.h"
char *MInterface_OpenBlockPicture(char *lpszPictureName, char *lpszObjectName)
{
#define FCT_NAME "MInterface_OpenBlockPicture"
#define MAX_WINDOW_OPENED 10
long screen = 0;
char szBasePicture[256] = "";
char *psz = NULL;
long i = 0;
char szPictureWindowName[256] = "";
char *pszBlocType = NULL;
char *pszWindowTitle = NULL;
char *pszComment = NULL;
char *pszTagPrefix = NULL;
char szPicturePath[256] = "";
BOOL bWindowOK = FALSE;
char szWindowTagPrefix[256] = "";
char szTagPrfx[256] = "";
long StarterType = 0;
BOOL bHasStarterType = FALSE;
char StarterTypeObjects[21][256] = {"M_Motor", "M_Motor_State", "M_Motor_Pump", "M_PumpC", "M_PUMP1","M_PumpCNew", "M_MagnSep",
"M_Pump", "M_BlowerX3", "M_FCELL", "M_BlowerX1", "M_PUMP0", "M_Pump5",
"M_Deslimer", "M_AGITATOR", "M_FCELL","M_FEEDER_STATE1","M_SCREEN","M_Fan_State","M_ROUGHER","M_FAN"};
int k = 0;
static char szRetValue[256] = "";
char *pszObjectType = GetPropChar(lpszPictureName, lpszObjectName, "FaceplateType");
//printf("\r\n%s: Object Type = %s", FCT_NAME, pszObjectType);
//screen = MInterface_GetScreen(lpszPictureName); //Return-Type: long int
pszBlocType = GetPropChar(lpszPictureName, lpszObjectName, "BlocTypeText");
strcpy(szRetValue, "");
strncpy(szBasePicture, lpszPictureName, sizeof(szBasePicture)-1);
psz = strstr(szBasePicture, "MINT_WORK");
if (psz)
{
psz += strlen("MINT_WORK");
*(psz) = '\0';
//printf("\r\n%s:: szBasePicture = %s", FCT_NAME, szBasePicture);
for (i = 1; i<MAX_WINDOW_OPENED; i++)
{
sprintf(szPictureWindowName, "TOP_WND%d", i);
//printf("\r\n%s:: szPictureWindowName (%d)= %s", FCT_NAME, i,szPictureWindowName);
if (FALSE == GetVisible (szBasePicture, szPictureWindowName))
{
//printf("\r\n%s:: Window available = %s", FCT_NAME, szPictureWindowName);
// SetTagPrefix(szBasePicture, szPictureWindowName, "");
SetPictureName ( szBasePicture, szPictureWindowName, pszBlocType);
SetVisible (szBasePicture, szPictureWindowName, TRUE);
// Positionner les propriétés intrinsèques à la fenêtre
// Récupération du chemin complet de la vue affichée dans la fenêtre de vue
strncpy(szPicturePath, szBasePicture, sizeof(szPicturePath)-1);
strncat(szPicturePath, ".", sizeof(szPicturePath)-1);
strncat(szPicturePath, szPictureWindowName, sizeof(szPicturePath)-1);
strncat(szPicturePath, ":", sizeof(szPicturePath)-1);
strncat(szPicturePath, pszBlocType, sizeof(szPicturePath)-1);
strncpy(szRetValue, szPicturePath, sizeof(szRetValue)-1);
//printf("\r\n%s:: szPicturePath= %s", FCT_NAME, szPicturePath);
// Tag Prefix
if (1==GetPropBOOL(lpszPictureName, lpszObjectName, "FullTagPrefix"))
{
// TAG Prefix: Cas standard
pszTagPrefix = GetPropChar(lpszPictureName, lpszObjectName, "TagPrefix");
if (!StringIsNullOrEmpty(pszTagPrefix))
strncpy(szTagPrfx, pszTagPrefix , sizeof(szTagPrfx)-1);
if (0 == strncmp(szTagPrfx, "NOTP", 4))
szTagPrfx[0] = '\0';
}
else
{
// TAG Prefix: Cas ou on est dans une fenetre de vue:
STD_GetPictureTagPrefix(lpszPictureName,szWindowTagPrefix,sizeof(szWindowTagPrefix)-1); //Return-Type: BOOL
if (!StringIsNullOrEmpty(szWindowTagPrefix))
{
char *pszObjectPrfx = GetTagPrefix(lpszPictureName, lpszObjectName);
strncpy(szTagPrfx, szWindowTagPrefix, sizeof(szTagPrfx)-1);
if (!StringIsNullOrEmpty(pszObjectPrfx))
strncat(szTagPrfx, pszObjectPrfx, sizeof (szTagPrfx)-1);
}
}
// Starting Mode for Motor Objects
for (k=0;k<21;k++)
{
//printf("\r\n StarterTypeObjects[%d] = %s", k, StarterTypeObjects[k]);
if (strstr(pszBlocType, StarterTypeObjects[k]))
{
bHasStarterType = TRUE;
break;
}
}
if (bHasStarterType) StarterType = (long)GetPropDouble (lpszPictureName, lpszObjectName,"StarterType");
//printf("\r\n%s: TagPrefix = %s", FCT_NAME, szTagPrfx);
//printf("\r\n%s: has starter type = %d", FCT_NAME, bHasStarterType);
// printf("\r\n%s: ObjectFound (k-1=%d) = %s", FCT_NAME, k, StarterTypeObjects[k-1]);
// Window Title
//pszWindowTitle = GetPropChar( lpszPictureName, lpszObjectName, "Tag");
pszWindowTitle = szTagPrfx;
if (pszWindowTitle)
{
SetPropChar(szBasePicture, szPictureWindowName, "CaptionText", pszWindowTitle);
}
else
{
SetPropChar(szBasePicture, szPictureWindowName, "CaptionText", "Error while getting tag");
}
// Value comment
//pszComment = GetPropChar(lpszPictureName, lpszObjectName, "Comment");
pszComment = szTagPrfx;
if (pszComment == NULL)
{
SetPropChar(szPicturePath, "txtComment", "Text", " - ");
}
else
{
SetPropChar(szPicturePath, "txtComment", "Text", pszComment);
}
// Starting Mode for Motor Objects
if (bHasStarterType) SetOutputValueDouble(szPicturePath, "txtListStarterType", StarterType);
//
SetText(szPicturePath, "txtTagPrefix", szTagPrfx);
//printf("\r\n%s: pszBlocType = %s", FCT_NAME, pszBlocType);
if (strstr(pszBlocType, "M_Analog") || strstr(pszBlocType, "M_AO"))
{
LINKINFO Info;
SetText(szPicturePath, "txtUnit", GetPropChar(lpszPictureName, lpszObjectName, "Unit"));
if (!GetLink(lpszPictureName, lpszObjectName, "OutputValue", &Info))
printf("\r\n%s: Error with GetLink Function", FCT_NAME);
else
{
printf("\r\n%s: LinkName = %s", FCT_NAME, Info.szLinkName);
SetText(szPicturePath, "txtTag", Info.szLinkName);
}
}
SetVisible(szPicturePath, "WIN_STD", FALSE);
SetPropChar(szPicturePath, "WIN_STD", "TagPrefix", szTagPrfx);
SetVisible(szPicturePath, "WIN_STD", TRUE);
bWindowOK = TRUE;
}
if (bWindowOK)
break;
}
}
//printf("\r\n%s: End___", FCT_NAME);
return szRetValue;
}