⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ictab8ts.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 3 页
字号:
  status = icSendTypedMessage (pRemote->linkList->linkId, IC_MSG_TYPE_PL_FORECAST,			       NULL, pRemote->taConditions,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend PowerPlantForecast Failed %d %s", status, icPerror (status));    }  }/************************************************************************//* doPlCurve: send Power Plant Curve message				*//************************************************************************/static void doPlCurve (ICTA_REMOTE_INFO *pRemote)  {icMsgTypeCurve		*ptkMsg;icTypeCurve   		*pstCurve;icTypeIccpHeader	*pstHeader;icTypeCurveSegDescription *pstSegDescr;icInt	      	msgSize, status, segDescrLen, floatLen;icUChar	      	*message, *tmpMsgPtr;int		numSegs = 5;	/* 5 segments per curve object		*/int		numFloats = 4;  /* 4 float values per curve descr	*/int 		i;icFloat		lowRange, hiRange, currFloat, *floatPtr;  /* determine message size 	*/  /* allocating memory for the message is the hard part here so     we will try to elaborate the details as much as possible	*/  segDescrLen = sizeof (icTypeCurveSegDescription);  IC_ALIGN_DATA (segDescrLen);  floatLen = numFloats * sizeof(icFloatValue);  IC_ALIGN_DATA (floatLen);  msgSize = sizeof (icMsgTypeCurve);		/* msg header space */  msgSize+= numSegs * segDescrLen;		/* curve descr space*/  msgSize+= numSegs * floatLen;			/* the float arrays */  message = chk_malloc (msgSize);  ptkMsg = (icMsgTypeCurve *) message;  pstCurve = &ptkMsg->MsgTypeHeader;  pstHeader = &ptkMsg->MsgHeader;  /* take care of the header	*//*  pstHeader->RemoteId = _hdrRemoteId; *//*  pstHeader->RequestId = _hdrRequestId; *//*  pstHeader->DestinationId = _hdrDestId; *//*  pstHeader->ReferenceNumber = _hdrRefNum; *//*  pstHeader->MessageType = msgType; *//*  pstHeader->Conditions = _hdrConditions; */  /* fill up the message struct */  pstCurve->PlantReferenceId = 800;  pstCurve->UnitId  =4513;  pstCurve->CurveType = 4;  pstCurve->NumberOfSegments = numSegs;  tmpMsgPtr = message + sizeof (icMsgTypeCurve);  lowRange = (icFloat) 1.1;  currFloat = (icFloat) 1.01;  hiRange = lowRange * currFloat;  for (i=0; i < numSegs; i++)    {    pstSegDescr = (icTypeCurveSegDescription *) tmpMsgPtr;    pstSegDescr->Order = numFloats;    pstSegDescr->LowRange = lowRange;    pstSegDescr->HighRange = hiRange;    lowRange = hiRange;    hiRange += lowRange * currFloat;    pstSegDescr->NumberOfSegments = numFloats;    tmpMsgPtr += segDescrLen;    floatPtr = (icFloat *) tmpMsgPtr;    *floatPtr = currFloat;    floatPtr++;    *floatPtr = currFloat * (icFloat) 2.0;    floatPtr++;    *floatPtr = currFloat * (icFloat) 3.0;    floatPtr++;    *floatPtr = currFloat * (icFloat) 4.0;    tmpMsgPtr += floatLen;    }  /* send the message	*/  status = icSendTypedMessage (pRemote->linkList->linkId, IC_MSG_TYPE_PL_CURVE, 			       NULL, pRemote->taConditions,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend PowerPlantCurve Failed %d %s", status, icPerror (status));    }  chk_free (message);  }/************************************************************************//* doPlGenDataRpt:  send General Data Report				*//************************************************************************/static void doPlGenDataRpt (ICTA_REMOTE_INFO *pRemote)  {icMsgTypeGeneralDataReport	*ptkMsg;icTypeGeneralDataReportHeader	*pstRpt;icTypeGDRDataHeader		*pstOffset;icTypeIccpHeader		*pstHeader;icUChar				*message, *tmpMsg;icInt msgSize, status;int headerLength, locRefLength, numLocalRef=0;int text1MatrixLength, text1Length, numText1=0, numText1Rows=0;int text2MatrixLength, text2Length, numText2=0, numText2Rows=0;int integer1MatrixLength, integer1Length, numInteger1=0, numInteger1Rows=0;    int integer2MatrixLength, integer2Length, numInteger2=0, numInteger2Rows=0;int float1MatrixLength, float1Length, numFloat1=0, numFloat1Rows=0;int float2MatrixLength, float2Length, numFloat2=0, numFloat2Rows=0;icReferenceNumType *pLocalRef;icMatrixId         *pMatrixId;icText32Value      *pText32;icInt		   *pIntVal;icFloatValue	   *pFloatVal;int i, j;  numLocalRef = 2;  numText1 = 2;  numText1Rows = 2;  numText2 = 2;  numText2Rows = 2;  numInteger1 = 2;  numInteger1Rows = 2;  numInteger2 = 2;  numInteger2Rows = 2;  numFloat1 = 2;  numFloat1Rows = 2;  numFloat2 = 2;  numFloat2Rows = 2;  /* allocate memory!!!!					*/  headerLength = sizeof (icMsgTypeGeneralDataReport);  locRefLength = numLocalRef * sizeof(icReferenceNumType);  IC_ALIGN_DATA(locRefLength);  text1MatrixLength = numText1 * sizeof(icMatrixId);  IC_ALIGN_DATA(text1MatrixLength);  text1Length = numText1 * numText1Rows * sizeof(icText32Value);  IC_ALIGN_DATA(text1Length);  text2MatrixLength = numText2 * sizeof(icMatrixId);  IC_ALIGN_DATA(text2MatrixLength);  text2Length = numText2 * numText2Rows * sizeof(icText32Value);  IC_ALIGN_DATA(text2Length);  integer1MatrixLength = numInteger1 * sizeof(icMatrixId);  IC_ALIGN_DATA(integer1MatrixLength);  integer1Length = numInteger1 * numInteger1Rows * sizeof(icInt);  IC_ALIGN_DATA(integer1Length);  integer2MatrixLength = numInteger2 * sizeof(icMatrixId);  IC_ALIGN_DATA(integer2MatrixLength);  integer2Length = numInteger2 * numInteger2Rows * sizeof(icInt);  IC_ALIGN_DATA(integer2Length);  float1MatrixLength = numFloat1 * sizeof(icMatrixId);  IC_ALIGN_DATA(float1MatrixLength);  float1Length = numFloat1 * numFloat1Rows * sizeof(icFloatValue);  IC_ALIGN_DATA(float1Length);  float2MatrixLength = numFloat2 * sizeof(icMatrixId);  IC_ALIGN_DATA(float2MatrixLength);  float2Length = numFloat2 * numFloat2Rows * sizeof(icFloatValue);  IC_ALIGN_DATA(float2Length);  msgSize = locRefLength + headerLength +    	text1MatrixLength + text2MatrixLength + 	text1Length + text2Length +    	integer1MatrixLength + integer2MatrixLength + 	integer1Length + integer2Length +    	float1MatrixLength + float2MatrixLength + 	float1Length + float2Length;  message = chk_malloc (msgSize);  ptkMsg = (icMsgTypeGeneralDataReport *) message;  pstRpt = &ptkMsg->MsgTypeHeader;  pstHeader = &ptkMsg->MsgHeader;  pstOffset = &ptkMsg->MsgDataHeader;  /* this offset data is important	*/  pstOffset->LocalRefOffset = 0;  pstOffset->Text1Offset = locRefLength;  pstOffset->Text2Offset = pstOffset->Text1Offset +   			   text1MatrixLength + text1Length;  pstOffset->Integer1Offset = pstOffset->Text2Offset +  			      text2MatrixLength + text2Length;  pstOffset->Integer2Offset = pstOffset->Integer1Offset +  			      integer1MatrixLength + integer1Length;  pstOffset->Float1Offset = pstOffset->Integer2Offset +  			    integer2MatrixLength + integer2Length;  pstOffset->Float2Offset = pstOffset->Float1Offset +  			    float1MatrixLength + float1Length;  /* take care of the header	*//*  pstHeader->RemoteId = _hdrRemoteId; *//*  pstHeader->RequestId = _hdrRequestId; *//*  pstHeader->DestinationId = _hdrDestId; *//*  pstHeader->ReferenceNumber = _hdrRefNum; *//*  pstHeader->MessageType = msgType; *//*  pstHeader->Conditions = _hdrConditions; */  /* fill up the general data report header struct */  pstRpt->GeneralDataReportRef = 900;  strcpy (pstRpt->ReportName, "GenDataReportName");  pstRpt->ReportDateAndTime = time (NULL);  pstRpt->NumberLocalRef = numLocalRef;  pstRpt->NumberText1 = numText1;  pstRpt->NumberText2 = numText2;  pstRpt->NumberInteger1 = numInteger1;  pstRpt->NumberInteger2 = numInteger2;  pstRpt->NumberFloat1 = numFloat1;  pstRpt->NumberFloat2 = numFloat2;  pstRpt->NumberText1Rows = numText1Rows;  pstRpt->NumberText2Rows = numText2Rows;  pstRpt->NumberInteger1Rows = numInteger1Rows;  pstRpt->NumberInteger2Rows = numInteger2Rows;  pstRpt->NumberFloat1Rows = numFloat1Rows;  pstRpt->NumberFloat2Rows = numFloat2Rows;  /* take care of local references	*/  tmpMsg = message + sizeof (icMsgTypeGeneralDataReport);  pLocalRef = (icReferenceNumType *) tmpMsg;  for (i=0; i<numLocalRef; i++, pLocalRef++)    *pLocalRef = LOCAL_REF_START * i;  /* take care of text1 matrix ids next	*/  tmpMsg += locRefLength;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numText1; i++, pMatrixId++)    *pMatrixId = i;  /* take care of text1 data next	*/  tmpMsg += text1MatrixLength;  pText32 = (icText32Value *) tmpMsg;  for (i=0; i<numText1; i++)    {    for (j=0; j<numText1Rows; j++, pText32++)      sprintf (*pText32, "Text1 item%d row%d", i, j);    }  /* take care of text2 matrix ids next	*/  tmpMsg += text1Length;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numText2; i++, pMatrixId++)    *pMatrixId = i;  /* take care of text2 data next	*/  tmpMsg += text2MatrixLength;  pText32 = (icText32Value *) tmpMsg;  for (i=0; i<numText2; i++)    {    for (j=0; j<numText2Rows; j++, pText32++)      sprintf (*pText32, "Text2 item%d row%d", i, j);    }  /* take care of integer 1 matrix ids	*/  tmpMsg += text2Length;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numInteger1; i++, pMatrixId++)    *pMatrixId = i;  /* take care of integer 1 data	*/  tmpMsg += integer1MatrixLength;  pIntVal = (icInt *) tmpMsg;  for (i=1; i<=numInteger1; i++)    {    for (j=1; j<=numInteger1Rows; j++, pIntVal++)      *pIntVal = INTEGER_START * i * j;    }  /* take care of integer 2 matrix ids	*/  tmpMsg += integer1Length;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numInteger2; i++, pMatrixId++)    *pMatrixId = i;  /* take care of integer 2 data	*/  tmpMsg += integer2MatrixLength;  pIntVal = (icInt *) tmpMsg;  for (i=1; i<=numInteger2; i++)    {    for (j=1; j<=numInteger2Rows; j++, pIntVal++)      *pIntVal = INTEGER_START * i * j;    }  /* take care of float 1 matrix ids	*/  tmpMsg += integer2Length;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numFloat1; i++, pMatrixId++)    *pMatrixId = i;  /* take care of float 1 data	*/  tmpMsg += float1MatrixLength;  pFloatVal = (icFloatValue *) tmpMsg;  for (i=1; i<=numFloat1; i++)    {    for (j=1; j<=numFloat1Rows; j++, pFloatVal++)      *pFloatVal = (icFloat) FLOAT_START * i * j;    }  /* take care of float 2 matrix ids	*/  tmpMsg += float1Length;  pMatrixId = (icMatrixId *) tmpMsg;  for (i=1; i<=numFloat2; i++, pMatrixId++)    *pMatrixId = i;  /* take care of float 2 data	*/  tmpMsg += float2MatrixLength;  pFloatVal = (icFloatValue *) tmpMsg;  for (i=1; i<=numFloat2; i++)    {    for (j=1; j<=numFloat2Rows; j++, pFloatVal++)      *pFloatVal = (icFloat) FLOAT_START * i * j;    }  /* send the message	*/  status = icSendTypedMessage (pRemote->linkList->linkId, IC_MSG_TYPE_GEN_DATA_REPORT, 			       NULL, pRemote->taConditions,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend GeneralDataReport Failed %d %s", status, icPerror (status));    }  chk_free (message);  }/************************************************************************//* doPlGenDataRsp: send General Data Response				*//************************************************************************/static void doPlGenDataRsp (ICTA_REMOTE_INFO *pRemote)  {icMsgTypeGeneralDataResponse	tkMsg;icTypeGeneralDataResponse	*pstMsgPtr;icInt				msgSize, status;icUChar				*message;  /* determine message size 	*/  msgSize = sizeof (icTypeIccpHeader) + sizeof (icTypeGeneralDataResponse);  pstMsgPtr = &tkMsg.MsgTypeHeader;  message = (icUChar *) &tkMsg;  /* fill up the message struct */  pstMsgPtr->GeneralDataResponseRef = 1000;  strcpy (pstMsgPtr->DataName, "GenDataResponseDataName");  pstMsgPtr->DataDateAndTime = time (NULL);  pstMsgPtr->ResponseData = 900;  pstMsgPtr->ResponseCode = 901;  strcpy (pstMsgPtr->ResponseText, "GenDataResponseRespText");  /* send the message	*/  status = icSendTypedMessage (pRemote->linkList->linkId, IC_MSG_TYPE_GEN_DATA_RESPONSE, 			       NULL, pRemote->taConditions,  			       message, msgSize);  if (status)    {    ICA_Log_Err2 ("ERROR:  icSendTypedMessage status = %d %s",                  status, icPerror(status));    printf ("\n\nSend GeneralDataResponse Failed %d %s", status, icPerror (status));    }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -