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

📄 000fdaa2b25f001d1289bbda6de18a35

📁 Vxworks环境下
💻
📖 第 1 页 / 共 2 页
字号:
/*$Log:**** Rev /main/NC_V0_integration/5** Date: Nov 1 17:22:0 2007 abdeaity** Kommentar HMI Demo V2 **** Rev /main/NC_V0_integration/4** Date: Jun 1 15:14:9 2007 abdeaity** Kommentar:exclude pxr0xx.h**** Rev /main/NC_V0_integration/3** Date: May 9 16:9:57 2007 abdeaity** Kommentar: clear SF3464+ new functions**** Rev /main/NC_V0_integration/2** Date: Mar 13 13:57:44 2007 rolfglei** Log-Syntax geaendert*//*** ---------------------------------------------------------------------**                Copyright (c) Bosch Rexroth AG 1997 - 2007**                        All Rights Reserved** ---------------------------------------------------------------------** **    File: dab_h_axis_if.c** **    Responsible: AB**  **    Description of functions: **          This file is an example to understand how to get data from **          NC kernel and to display it on a Tilcon Window.**          in this file we will:**	     -  get the axis number of the system **	     -  start a mechanism to get the actual axis values so that **               if a value of an axes in the system was changed this **               application recieve an event  and will display the **               actuele values** ** ---------------------------------------------------------------------*//*======================================================================**           >>>>    C - Standard Headerfiles        <<<<** ==================================================================== */#ifdef HWDS_WINDOWS #include <windows.h>       /* required for all Windows applications */#endif#include <stdio.h>/*lint -e46*//*lint -e49*//*lint -e10*/#include <tilcon/TRTAPI.h> 	// Tilcon API functions/*lint +e46*//*lint +e49*//*lint +e10*//*======================================================================**           >>>>    General definitions for c-files <<<<**        these lines are generated automatically , do not modify !** ==================================================================== */#include <ty3c_mac.h>/*F*//*======================================================================**           >>>>    MTX - Headerfiles               <<<<** ==================================================================== */#ifndef NCS1BAS_INCLUDED#include "ncs1bas.h"#endif#ifndef NCS1MCO_INCLUDED#include "ncs1mco.h"#endif#ifndef NCS1SAV_INCLUDED#include "ncs1sav.h"#endif/*======================================================================**           >>>>    Headerfiles of the subsystem    <<<<** ==================================================================== */#ifndef DAB_H_ENGINE_IF_INCLUDED#include "dab_h_engine_if.h"#endif#ifndef DAB_H_AXIS_IF_INCLUDED#include "dab_h_axis_if.h"#endif#ifndef DAB_H_OBJIDS_INCLUDED#include "dab_h_ObjIDs.h"#endif#ifndef DAB_H_MEM_INCLUDED#include "dab_h_mem.h"#endif#include "dab_h_cpl.h" /*Jiang add it*//*======================================================================**       >>>>     Local definitions      <<<<** ==================================================================== */#define CHAN 1LOCAL int FeedAxisNmb;LOCAL int AuxAxisNmb;LOCAL int AxisNumberDone;/*static int SpindleNmb;*/LOCAL Ncs_MCoAxisDataInt_t drivetypes;typedef struct{  double *AxValue;  int size;  int version;  int abbruch;} OwnActAxPosValue_t;LOCAL OwnActAxPosValue_t OwnActAxPosValue;LOCAL OwnActAxPosValue_t OwnActAxEndPosValue;LOCAL OwnActAxPosValue_t OwnActAxRestwegValue;IMPORT char CurrentFileWantToRun[100]; //It will save the file name and it's path./*F*//*************************************************************************** >AUTHOR        : Jiang**  FUNCTION NAME : ** ** >DESCRIPTION:**   After load a program activate a procress to active a NC program            ** ** >NOTES: ** ** >PARAMETER:** ** >RETURN VALUE:** ** >INCLUDES : ** */EXPORT int Dab_h_CreateProcress(char* program){	int flags;	int loc_errncs;	int status;	flags = NCS_SAV_FLAG_LINK_BEFORE_READY_C;	loc_errncs=Ncs_SavProcessCreate(1,program,"","",flags,&status);		if ((status!=NCS_SAV_SERVICEOK_C) || (loc_errncs!=Ncs_ErrOk))	{ //Error handle; 	}	else	{ //service successful;  	}	return loc_errncs; } /* OF Dab_h_CreateProcress*//*F*//*************************************************************************** >AUTHOR        : Jiang**  FUNCTION NAME : ** ** >DESCRIPTION:**   After load a program deactiveate a procress to active a NC program            ** ** >NOTES: ** ** >PARAMETER:** ** >RETURN VALUE:** ** >INCLUDES : ** */EXPORT int Dab_h_DeleteProcress(char* program){	int loc_errncs;	int status;	//flags = NCS_SAV_FLAG_PROCESSDELETE_C;	loc_errncs=Ncs_SavProcessCreate(1,program,"","",NCS_SAV_FLAG_PROCESSDELETE_C,&status);		if ((status!=NCS_SAV_SERVICEOK_C) || (loc_errncs!=Ncs_ErrOk))	{ //Error handle; 	}	else	{ //service successful;  	}	return loc_errncs; }EXPORT void Dab_h_InitAxisinterface(void){  int size;  while(!AxisNumberDone)  {    Dab_h_Delay(500);  } /* OF  While */	    size =((FeedAxisNmb+AuxAxisNmb)*(int)sizeof(double));  /*get mem for act. position value*/  OwnActAxPosValue.AxValue=(double *)Dab_h_Memalloc((unsigned int)size);   if(!OwnActAxPosValue.AxValue) /* if no memory more*/  {/* Traitement of the Error*/  }  /* get mem for act. end position values*/  OwnActAxEndPosValue.AxValue=(double *)Dab_h_Memalloc((unsigned int)size);  if(!OwnActAxEndPosValue.AxValue) /* if no memory more*/  {/* Traitement of the Error*/  }  /* get mem for restweg  values*/  OwnActAxRestwegValue.AxValue=(double *)Dab_h_Memalloc((unsigned int)size);  if(!OwnActAxRestwegValue.AxValue) /* if no memory more*/  {/* Traitement of the Error*/  }  /* initialisation*/  OwnActAxPosValue.size=size;  OwnActAxPosValue.abbruch=0;  OwnActAxPosValue.version=0;  OwnActAxEndPosValue.size=size;  OwnActAxEndPosValue.abbruch=0;  OwnActAxEndPosValue.version=0;  OwnActAxRestwegValue.size=size;  OwnActAxRestwegValue.abbruch=0;  OwnActAxRestwegValue.version=0;}  /* OF Dab_h_InitAxisInterface*//*F*//*************************************************************************** >AUTHOR        : AB**  FUNCTION NAME : GetAxisNmb_Rec** ** >DESCRIPTION:recieve function when we Request axis number from System.**           this function will be called automaticlly when a response**           for  the function Dab_h_GetAxisNmb_Req  is arrived from NCS.**           the response will bes extracted  whith NCS extract function**               ** ** >NOTES: this funktion has been assigned to the request in **          Dab_h_GetAxisNmb_Req ** ** >PARAMETER: ncsmsg: Pointer of received Message** ** >RETURN VALUE: 1 if an error was occurred else 0** ** >INCLUDES :      none** */LOCAL int GetAxisNmb_Rec (Ncs_Msg_t *ncsmsg,Ncs_RecPara_t para){  /* Ncs_MCoAxisDataInt_t *ldrivetypes = (Ncs_MCoAxisDataInt_t *)para;*/  Ncs_Error_t loc_errncs;/* Error status of the NCS*/  int status;  char Output[3];  loc_errncs=Ncs_MCoRqDriveTypes_X(ncsmsg ,/*NCS message*/                                                                     /*Pointer to a buffer for data*/                                      /*Structur(integer field)*/                                  (int*)para,                                             /*buffer size*/                                                 sizeof(Ncs_MCoAxisDataInt_t),                                   &status);/*returns the error status*/  if ((status!=NCS_SAV_SERVICEOK_C) || (loc_errncs!=Ncs_ErrOk))  { /*Treatment of Errors*/    return 1;  }  else  { //* OK */    /*Return the number of primary axes from the data structur*/         /*determined with Ncs_MCoRqDriveTypes*/    FeedAxisNmb=Ncs_MCoGetFeedAxisNmb_X((int*)para,0);    /*Return the number of Auxiliary  axes from the data structur */    /*determined with Ncs_MCoRqDriveTypes*/    AuxAxisNmb=Ncs_MCoGetAuxAxisNmb_X((int*)para,0);    /* SpindleNmb=Ncs_MCoGetSpindleAxisNmb_X((int*)ldrivetypes,0);*/	AxisNumberDone=1;	/* Output in Tilcon interface, */	/* before that will the dataformat changed according to Tilcon */		/* int to char*/	sprintf(Output, "%d", FeedAxisNmb); 	(void)TRT_SetValues(TRT_cid2,AXIS_NMBR_DISPLAY_ID,		      TRT_ATT_TEXT, Output,NULL);  }  {        /*To do ....for Example Data Display */  }	  return 0;}  /* OF GetAxisNmb_Rec *//*F*//*************************************************************************** >AUTHOR        : AB**  FUNCTION NAME : Dab_h_GetAxisNmb_Req** ** >DESCRIPTION:  Asyncron Request of the Axis number** >NOTES:** ** >PARAMETER: none** ** >RETURN VALUE: none** ** >INCLUDES:"dab_h_sxis_if.h"** */EXPORT void  Dab_h_GetAxisNmb_Req (void){  Ncs_Error_t loc_errncs;/* Error status of the NCS*/  AxisNumberDone=0;	   /* General asynchronous variable service(see the ncs Help)*/  loc_errncs=Ncs_MCoGetService_A(GetAxisNmb_Rec,/*Receive function*/                                 /*Parameter of Receive function*/                                 (Ncs_RecPara_t)drivetypes,                                 Ncs_MCoNoChannel_C,                                 /*Service ID*/                                 Ncs_MCoRqDriveTypes_Id);  if (loc_errncs!=Ncs_ErrOk)  {     /* Treatment of Errors */			  }}  /* OF Dab_h_GetAxisNmb_Req *//*F*//*************************************************************************** >AUTHOR        : AB**  FUNCTION NAME : GetAxisValues_Rec** ** >DESCRIPTION: recieve function when we Request axis Values **           from System.**           this function will be called automaticlly when a response**           for  the function Dab_h_GetAxisValues_Req is received **           from NCS.**           the response will bes extracted  whith NCS extract function**               ** ** >NOTES:** ** >PARAMETER: ncsmsg Pointer of received Message**             para : User Parameter** ** >RETURN VALUE:** ** >INCLUDES:** */LOCAL int GetAxisValues_Rec (Ncs_Msg_t *ncsmsg,Ncs_RecPara_t para){  double * ptrvalue;  int Draw_X=0,Draw_Y=0; /* for drawing */            OwnActAxPosValue_t *ldata = (OwnActAxPosValue_t*)para;  Ncs_Error_t loc_errncs; /* Error status of the NCS*/  int status;  long TilconError=0;  char Output[30];            /* Evaluat th asynchronous NCS response that contain Axis values*/  /* see the ncs Help*/  loc_errncs=Ncs_MCoDoubleValue_X(ncsmsg,                                  &(ldata->version),                                  ldata->AxValue,                                  (int)ldata->size,                                  &status);  if ((status!=NCS_SAV_SERVICEOK_C) || (loc_errncs!=Ncs_ErrOk))  { /*Fehlerbehandlung*/		       return 1;  }  else  { /*ok*/ /*to do whith data ldata->AxValue*/     {       /* as example we display the neue axis Values on the display*/             /* 1. Axis */      ptrvalue=ldata->AxValue;                     sprintf(Output, "% .3f", *ptrvalue);      TilconError=TRT_SetValues(TRT_cid2,IST_X_DISPL_ID,                                TRT_ATT_TEXT,Output,NULL);      TilconError=TRT_SetValues(TRT_cid2,"Table_MachinPostiion_ID#0#1",                                TRT_ATT_TEXT,Output,NULL);      Draw_X=(int)((*ptrvalue));      /* 2.Axis */      ptrvalue++;      sprintf(Output, "% .3f", *ptrvalue);      TilconError+=TRT_SetValues(TRT_cid2,IST_Y_DISPL_ID,                                 TRT_ATT_TEXT,Output,NULL);      TilconError+=TRT_SetValues(TRT_cid2,"Table_MachinPostiion_ID#1#1",                                 TRT_ATT_TEXT,Output,NULL);      Draw_Y=(int)((*ptrvalue));      /* 3. Axis */      ptrvalue++;      sprintf(Output, "% .3f", *ptrvalue);      TilconError+=TRT_SetValues(TRT_cid2,IST_Z_DISPL_ID,                                 TRT_ATT_TEXT,Output,NULL);      TilconError+=TRT_SetValues(TRT_cid2,"Table_MachinPostiion_ID#2#1",                                 TRT_ATT_TEXT,Output,NULL);      /* Oscilloscop Test*/      /* as Example we draw the machine move on a Spectograph*/      /* for mor infos a bout this funktion see Tilcon Help*/      TilconError+=TRT_SpectrographUpdateCell (TRT_cid2,/*chanal id*/                                                OSCILOSCOPE_DISPLAY_ID,/*Name*/                                                Draw_X,                                                Draw_Y, /*Draw position*/                                               'c',                                                0, 44);/*Color*/      if(TilconError)      {        /*Treatment of Errors if an objekt not defined*/      }    }		   		    }  if (!ldata->abbruch)  {                /* if the Pannel of coordinates  is not displayed stop the loop*/                /* send a new asynchronous request */    /* this Service returns the Axis values whose ID later than*/    /* the ID that has been preset by the input parameter"version"*/    loc_errncs=Ncs_MCoGetServiceEvent_A(GetAxisValues_Rec,                                        (Ncs_RecPara_t)&OwnActAxPosValue,                                        Ncs_MCoNoChannel_C,                                        (int)ldata->version,                                        Ncs_MCoActAxPosValue_Id);  }  if (loc_errncs!=Ncs_ErrOk)  { /*Treatment of Error */ 	          return 2;  }  return 0;  }  /* OF GetAxisValues_Rec *//*F*//*************************************************************************** >AUTHOR        : AB**  FUNCTION NAME : Dab_h_GetAxisValues_Req** ** >DESCRIPTION: Asyncron Request of the Axis number**               if we call this funktion we start the mechanism to **               receive an event from NCS when the axis Values has been**               changed in the system.** ** >NOTES:** ** >PARAMETER:none** ** >RETURN VALUE:none** ** >INCLUDES:"dab_h_axis_if.h"** */EXPORT void Dab_h_GetAxisValues_Req (void){   

⌨️ 快捷键说明

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