コード例 #1
0
/******************************************************************************
*Func Name   : PTPV2_ANN_PrintAnn
*Description : announce报文打印接口
*Input       : PTPV2_ANNOUNCE_MSG_S *pstAnnMsg: 消息头
*              TCPIP_PTP_ADDRINFO_S *pstAddrInfo:  接收/发送报文的地址以及UDP信息
*              ULONG ulFlag:        标记:0-发送报文;非0-接收报文
*Output      : 
*Return      : 
*Caution     : 
*Calls       : 
*Called by   : 
*-----------------------------------------------------------------------------
*  Modification History
*  DATE                 NAME           DESCRIPTION
*  2014-05-14           dutianyi       Create
*******************************************************************************/
VOID PTPV2_ANN_PrintAnn(PTPV2_ANNOUNCE_MSG_S *pstAnnMsg, TCPIP_PTP_ADDRINFO_S *pstAddrInfo, ULONG ulFlag)
{    
    CHAR szBuf[LEN_512] = {0};  /* 缓冲区长度512个字节,存放报文信息 */
    CHAR szInOrOut[10] = {0};
    INT32 i32Offset = 0;
    
    if ((NULL == pstAnnMsg) || (NULL == pstAddrInfo))
    {
        return;
    }
    
    if (0 == ulFlag)
    {
        i32Offset = TCPIP_SNPRINTF0(szInOrOut, 10, P0("send"));
    }
    else
    {
        i32Offset = TCPIP_SNPRINTF0(szInOrOut, 10, P0("receive"));
    }
    
    /* 先打印提示信息 */
    (VOID)TCPIP_SNPRINTF(szBuf + i32Offset, LEN_512 - i32Offset, P1("\r\n----------announce msg %s begin----------",szInOrOut));
    
    TCPIP_InfoOutput(szBuf);

    (VOID)TCPIP_Mem_Set(szBuf, 0, LEN_512);
    
    /* 打印消息头 */
    PTPV2_PrintHeader((PTPV2_MSGHEADER_S *)pstAnnMsg, pstAddrInfo);
    
    i32Offset = TCPIP_SNPRINTF0(szBuf, LEN_512, P0("\r\nANNOUNCE INFO:"));    

    /* 打印announce消息的其他内容 */
    i32Offset += TCPIP_SNPRINTF(szBuf + i32Offset, LEN_512 - i32Offset, P8("\r\n    originTimestamp : Nano-%u,Low-%u,High-%u \r\n    utcoffset : %d\r\n    grandmasterPri1 : %u\r\n    grandmasterQuality : Accuracy-%u,class-%u,offset-%u ",
                              pstAnnMsg->stOriginTimestamp.ulNanoseconds,
                              pstAnnMsg->stOriginTimestamp.ulSecondsLow,
                              pstAnnMsg->stOriginTimestamp.usSecondsHigh,
                              VOS_NTOHS(pstAnnMsg->sCurrentUtcOffset),
                              pstAnnMsg->ucGrandmasterPriority1,
                              pstAnnMsg->stGrandmasterClockQuality.ucClockAccuracy,
                              pstAnnMsg->stGrandmasterClockQuality.ucClockClass,
                              VOS_NTOHS(pstAnnMsg->stGrandmasterClockQuality.usOffsetScaledLogVariance)));

    i32Offset += TCPIP_SNPRINTF(szBuf + i32Offset, LEN_512 - i32Offset, P11("\r\n    grandmasterPri2 : %u\r\n    grandmasterId : %02x%02x%02x%02x%02x%02x%02x%02x\r\n    stepsremoved : %u\r\n    timesource : %u",
                              pstAnnMsg->ucGrandmasterPriority2,
                              pstAnnMsg->stGrandmasterIdentity[0],
                              pstAnnMsg->stGrandmasterIdentity[1],
                              pstAnnMsg->stGrandmasterIdentity[2],
                              pstAnnMsg->stGrandmasterIdentity[3],
                              pstAnnMsg->stGrandmasterIdentity[4],
                              pstAnnMsg->stGrandmasterIdentity[5],
                              pstAnnMsg->stGrandmasterIdentity[6],
                              pstAnnMsg->stGrandmasterIdentity[7],
                              VOS_NTOHS(pstAnnMsg->usStepsRemoved),
                              pstAnnMsg->ucTimeSource));
    (VOID)TCPIP_SNPRINTF(szBuf + i32Offset, LEN_512 - i32Offset, P1("\r\n----------announce msg %s end------------",szInOrOut));

    TCPIP_InfoOutput(szBuf);
    
}
コード例 #2
0
ファイル: raster.c プロジェクト: AaronRays468/glshim
    P(0), P(1), P(2), P(3),
    P(0), P(1), P(2), P(3),
    P(0), P(1), P(2), P(3),
    P(0), P(1), P(2), P(3),
    P(4), P(5), P(6), P(7),
    P(4), P(5), P(6), P(7),
    P(4), P(5), P(6), P(7),
    P(4), P(5), P(6), P(7),
};

const uint16_t bitmap[] = {
    0x0008, 0x0007, 0x0006, 0x0005, 0x0004, 0x0003, 0x0002, 0x0001,
};

const unsigned char bitmap_ref[] = {
    P8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF),
    P8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00),
    P8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF),
    P8(0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00),
    P8(0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF),
    P8(0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00),
    P8(0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF),
    P8(0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00),
};

void set_pos(int x, int y) {
    if (x < 0 || y < 0) {
        glWindowPos2i(0, 0);
        glBitmap(0, 0, 0, 0, x, y, NULL);
    } else {
        glWindowPos2i(x, y);
コード例 #3
0
ファイル: benchmark_lib.cpp プロジェクト: EvoNet/hpgl
int main() {

  Point center(41,29);

  // The numbering of the nodes corresponds to gslib's output order
  Node P5(38,28,0.5740);
  Node P8(45,29,1.2110);
  Node P4(41,26,2.1270);
  Node P3(39,31,8.3400);
  Node P6(38,31,18.6420);
  Node P2(39,30,7.9380);
  Node P7(39,32,2.2840);
  Node P1(40,31,2.5090);
  Node P9(37,20,0.5740);
  Node P10(25,28,1.2110);
  Node P11(39,26,2.1270);
  Node P12(32,31,8.3400);
  Node P13(30,34,18.6420);
  Node P14(33,35,7.9380);
  Node P15(42,32,2.2840);
  Node P16(31,23,2.5090);

  neighborhood voisin;
  voisin.add_node(P1);
  voisin.add_node(P2);
  voisin.add_node(P3);
  voisin.add_node(P4);
  voisin.add_node(P5);
  voisin.add_node(P6);
  voisin.add_node(P7);
  voisin.add_node(P8);
  voisin.add_node(P9);
  voisin.add_node(P10);
  voisin.add_node(P11);
  voisin.add_node(P12);
  voisin.add_node(P13);
  voisin.add_node(P14);
  voisin.add_node(P15);
  voisin.add_node(P16);
  


  

  typedef matrix_lib_traits<TNT_lib<double> >::Vector TNTvector;

  covariance covar;
  
  //______________________________
  // Simple Kriging
  //______________________________

  std::cout << std::endl <<std::endl;
  std::cout << "____________________________________________" 
	    << std::endl
	    << "Simple kriging"
	    << std::endl << std::endl;

  TNTvector SK_weights;
  SK_constraints SK;
  OK_constraints OK;
  double sk_variance;
  

  TNT::stopwatch chrono;
  chrono.start();
  for(int count = 0 ; count < 50000 ; count ++) {
    int change=1;
    if(drand48() <0.5) change = -1;
    (voisin[0].location())[0] += change;
    kriging_weights<GSTL_TNT_lib>(SK_weights,
				  center, voisin,
				  covar, OK );
  }

  chrono.stop();
  std::cout << "time elapsed using Gauss: " << chrono.read() << std::endl;
  
  chrono.reset();
  chrono.start();
  for(int count = 0 ; count < 50000 ; count ++) {
    int change=1;
    if(drand48() <0.5) change = -1;
    voisin[0].property_value() = 0.5*count;
    kriging_weights(SK_weights, 
		    center, voisin,
		    covar, OK );
  }

  chrono.stop();
  std::cout << "time elapsed using LU: " << chrono.read() << std::endl;
  
  
  /*
  //______________________________
  // Ordinary Kriging
  //______________________________

  std::cout << std::endl <<std::endl;
  std::cout << "____________________________________________" 
	    << std::endl
	    << "Ordinary kriging"
	    << std::endl << std::endl;

  TNTvector OK_weights;
  OK_constraints OK;
  double ok_variance;
  status = kriging_weights(OK_weights, ok_variance,
			   center, voisin,
			   covar, OK);
						   
  std::cout << "Here are the weights:" << std::endl
	    << OK_weights << std::endl;

  
  

  //______________________________
  // Kriging with Trend
  //______________________________

  std::cout << std::endl <<std::endl;
  std::cout << "____________________________________________" 
	    << std::endl
	    << "Kriging with Trend"
	    << std::endl << std::endl;
  
  TNTvector KT_weights;
  KT_constraints<functIter> KT(functArray.begin(),functArray.end());
  double kt_variance;
  status = kriging_weights(KT_weights, kt_variance,
			   center, voisin,
			   covar, KT);

						  
  std::cout << "Here are the weights:" << std::endl
	    << KT_weights << std::endl;

  */

  return 0;


}
コード例 #4
0
int main() {

  Node center_node(41,29,-99);

  // The numbering of the nodes corresponds to gslib's output order
  Node P5(38,28,0.5740);
  Node P8(45,29,1.2110);
  Node P4(41,26,2.1270);
  Node P3(39,31,8.3400);
  Node P6(38,31,18.6420);
  Node P2(39,30,7.9380);
  Node P7(39,32,2.2840);
  Node P1(40,31,2.5090);


  neighborhood voisin;
  voisin.add_node(P1);
  voisin.add_node(P2);
  voisin.add_node(P3);
  voisin.add_node(P4);
  voisin.add_node(P5);
  voisin.add_node(P6);
  voisin.add_node(P7);
  voisin.add_node(P8);

 

  
  typedef TNT_lib<double> TNT;
  typedef matrix_lib_traits<TNT>::Vector TNTvector;
  typedef matrix_lib_traits<TNT>::Symmetric_matrix TNTMatrix;

  covariance covar;


  
  //_____________________________
  // gaussian cdf estimator 
  //_____________________________

  std::cout << std::endl <<std::endl;
  std::cout << "____________________________________________" 
	    << std::endl
	    << "estimating gaussian cdf with SK"
	    << std::endl << std::endl;

  Gaussian_cdf g_ccdf;

  typedef Kriging_combiner<std::vector<double>::const_iterator,
                           neighborhood>   KCombiner;
  KCombiner sk_combiner( new SK_combiner<std::vector<double>::const_iterator,
                                          neighborhood>( 9.0 )   );
  typedef Kriging_constraints<neighborhood, Point, TNT> KConstraints;
  KConstraints constraints( new SKConstraints_impl<neighborhood, Point,TNT> );


  Gaussian_cdf_Kestimator<covariance,
    neighborhood,KConstraints,TNT>  gK_estimator( covar, constraints, sk_combiner ); 
  
  gK_estimator(center_node, voisin, g_ccdf);
  
  std::cout << "gaussian cdf : mean= " << g_ccdf.mean() << "   variance= " 
	    << g_ccdf.variance() << std::endl;


  /*  
  Gaussian_cdf g_ccdf2;
  
  Gaussian_cdf_Kestimator<covariance,
    neighborhood, SK_constraints>  gK_estimator2( covar, SK_constraints(), sk_combiner2 ); 
  gK_estimator2(center, voisin, g_ccdf2);
  
  std::cout << "gaussian cdf : mean= " << g_ccdf2.mean() << "   variance= " 
       << g_ccdf2.variance() << std::endl;
  */
}