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

📄 c086408ba45f001d1289bbda6de18a35

📁 Vxworks环境下
💻
📖 第 1 页 / 共 2 页
字号:
/*$Log$*//*** ---------------------------------------------------------------------**                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** ** ---------------------------------------------------------------------*//*F*/
/*======================================================================
**           >>>>    Include all necessary headfiles     <<<<
** ==================================================================== */#include "dab_h_allheadfiles.h"
/*F*//*======================================================================**           >>>>    Local definitions               <<<<** ==================================================================== */
#define CHAN 1
int RunFlags; //if this Flags=0 Program is stop ,else Program is running.LOCAL int FeedAxisNmb;LOCAL int AuxAxisNmb;
LOCAL int AxisNumberDone;      /*static int SpindleNmb;*/LOCAL Ncs_MCoAxisDataInt_t drivetypes;
LOCAL Ncs_Acb_ActZerOf_t ZeroOffsetdata;
typedef struct {	double *AxValue;	int size;	int version;	int abbruch;} OwnActAxPosValue_t;LOCAL OwnActAxPosValue_t OwnActAxPosValue;			/* ist position */
LOCAL OwnActAxPosValue_t OwnActAxEndPosValue;		/* end position */
LOCAL OwnActAxPosValue_t OwnActAxRestwegValue;		/* Restweg */

IMPORT char CurrentFileWantToRun[100]; //It will save the file name and it's path.

/*F*/
/*
************************************************************************
** >AUTHOR        : 
**  FUNCTION NAME : 
** 
** >DESCRIPTION:
**   After load a program activate or deactiveate 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*/

EXPORT int Dab_h_DeleteProcress(char* program)
{
	int flags;
	int loc_errncs;
	int status;

	flags = NCS_SAV_FLAG_PROCESSDELETE_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; 
}


EXPORT void Dab_h_InitAxisinterface(void)
{
	
	
	int size;
	while(!AxisNumberDone) /* wait for geting Axis Number*/
	{
		
#ifndef HWDS_WINDOWS
		(void)Pxr_Delay(500,1); /* wait*/
#endif
	} /* OF  While */
	
	size =((FeedAxisNmb+AuxAxisNmb)*(int)sizeof(double));
	
	
	OwnActAxPosValue.AxValue=(double *)Dab_h_Memalloc(size);
	OwnActAxEndPosValue.AxValue=(double *)Dab_h_Memalloc(size);
	OwnActAxRestwegValue.AxValue=(double *)Dab_h_Memalloc(size);
	
	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 */
		
		/* display the axis number directly on tilcon windows */
		sprintf(Output, "%d", FeedAxisNmb); /* int to char */
		TRT_SetValues(TRT_cid2,"Table1#1#0",
			TRT_ATT_TEXT, Output,NULL);
			}		return 0;}  /* OF GetAxisNmb_Rec *//*F*//*************************************************************************** >AUTHOR        : AB**  FUNCTION NAME : Dab_h_GetAxisNmb_Req** ** >DESCRIPTION:  Asyncron Request of the Axis number
**
**** >NOTES: none** ** >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: none** ** >PARAMETER: ncsmsg Pointer of received Message**             para : User Parameter** ** >RETURN VALUE: none** ** >INCLUDES: none** */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,"Table0#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,"Table0#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,"Table0#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 */ 				"Oscilloscop",/* Name */ 				Draw_X+20, 				Draw_Y+20, /*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: none** ** >PARAMETER:none** ** >RETURN VALUE:none** ** >INCLUDES:"dab_h_axis_if.h"** */EXPORT void Dab_h_GetAxisValues_Req (void){		Ncs_Error_t loc_errncs;				loc_errncs=Ncs_MCoGetService_A(GetAxisValues_Rec,		(Ncs_RecPara_t)&OwnActAxPosValue,		Ncs_MCoNoChannel_C,		Ncs_MCoActAxPosValue_Id);	if (loc_errncs!=Ncs_ErrOk)	{		/* Treatment of error because of act. axis position*/ 			}
	
	}  /* OF Dab_h_GetAxisValues_Req *//*F*/
/*
************************************************************************
** >AUTHOR        : AB
**  FUNCTION NAME : GetAxisEndPosValues_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: none
** 
** >PARAMETER: ncsmsg Pointer of received Message
**             para : User Parameter
** 
** >RETURN VALUE: none
** 
** >INCLUDES: none
** 
*/
LOCAL int GetAxisEndPosValues_Rec (Ncs_Msg_t *ncsmsg,Ncs_RecPara_t para)
{
	double * ptrvalue;
	
	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,"Table0#0#2",
				TRT_ATT_TEXT,Output,NULL);
			
			TilconError=TRT_SetValues(TRT_cid2,"Table0#0#4",
				TRT_ATT_TEXT,Output,NULL);
			
			/* 2.Axis */
			ptrvalue++;
			sprintf(Output, "% .3f", *ptrvalue);
			TilconError+=TRT_SetValues(TRT_cid2,"Table0#1#2",
				TRT_ATT_TEXT,Output,NULL);
			
			sprintf(Output, "% .3f", *ptrvalue);
			TilconError+=TRT_SetValues(TRT_cid2,"Table0#1#4",
				TRT_ATT_TEXT,Output,NULL);
			
			
			/* 3. Axis */
			ptrvalue++;
			sprintf(Output, "% .3f", *ptrvalue);
			TilconError+=TRT_SetValues(TRT_cid2,"Table0#2#2",
				TRT_ATT_TEXT,Output,NULL);
			
			sprintf(Output, "% .3f", *ptrvalue);
			TilconError+=TRT_SetValues(TRT_cid2,"Table0#2#4",
				TRT_ATT_TEXT,Output,NULL);
			
			
			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(GetAxisEndPosValues_Rec,
			(Ncs_RecPara_t)&OwnActAxEndPosValue,
			0,
			(int)ldata->version,
			Ncs_MCoBlkBlockEndPoint_Id);
	}
	if (loc_errncs!=Ncs_ErrOk)
	{ /*Treatment of Error */ 
		
		return 2;
	}
	return 0;  
}  /* OF GetAxisValues_Rec */


/*F*/
/*
************************************************************************
** >AUTHOR        : AB
**  FUNCTION NAME : Dab_h_GetAxisEndPosValues_Req
** 
** >DESCRIPTION: Asyncron Request of the Axis end position.

⌨️ 快捷键说明

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