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

📄 f0fd80ddc45f001d1289bbda6de18a35

📁 Vxworks环境下
💻
📖 第 1 页 / 共 2 页
字号:

/*
$Log$
*/
/*
** ---------------------------------------------------------------------
**                Copyright (c) Bosch Rexroth AG 1997 - 2008
**                        All Rights Reserved
** ---------------------------------------------------------------------
**
**    File: dab_h_toolmanage.c
** 
**    Responsible: MY
** 
**    Description of functions:
**          test file for cpl management like variable list or debug
**          
**         
**	     -  CPL Debugger
**           -  set/delete breakpoint
**	     -  CPL Variable list
**           -  Add watch point and so on
**       -  **
** 
** ---------------------------------------------------------------------
*/
/*F*/
/*======================================================================
**           >>>>    Include all necessary headfiles     <<<<
** ==================================================================== */
/*======================================================================
**           >>>>    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

#ifndef NCS1FSR_INCLUDED
#include "ncs1fsr.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 "string.h"


/*F*/
/*======================================================================
**           >>>>    Local definitions               <<<<
** ==================================================================== */

/***********************************************************************/
/** Here are some variables defined used in the CPL debug example.**/

#define MAXFILESIZE  1024*3            /*the size of the buffer saving the context of the NC Program to be showed in the HMI*/
LOCAL struct File_Name_Id{
	long fileid;
	char filename[15];
}record[100];                          /* use it to record the file name and id list in the folder */

IMPORT char Currentfileselect[20];     /*It will save the file name only.*/
EXPORT char CurrentFileToRun[100];        /*It will save the file name and it's path.*/
char Currentpath[20]="";               /*It will save the file path.*/



/*F*/
/*
************************************************************************
** >AUTHOR        : Jiang
**  FUNCTION NAME : DirShowtest
** 
** >DESCRIPTION: Example to Load directory into the HMI.
**               
**
** 
** >NOTES:	
**         
**         
**   
** >PARAMETER: none
** 
** >RETURN VALUE: none 
** 
** >INCLUDES :  none
** 
*/
EXPORT void Directory_Load(void){
	char buf[1024];
	char *entry;
	int  ret;
	char buffer[4096]="";
	char filebuffer[20];
	struct stat file_state;
	char BufferSelectPath[20]="";
	char item_base[5]="item";
	char imagebuf[50]="";
	char child_item[10]="";
	int  n=1;
	int  itemnumber=0;
	char tempr[3];
	
	TRT_SetValues(TRT_cid2, "FilesUnderFold",
		TRT_ATT_TEXT,"",
		NULL);
	//Get file path of access from HMI
	TRT_GetValues(TRT_cid2,"FoldSelect",
		TRT_ATT_TEXT,BufferSelectPath,NULL);
	
	//Mybe at here we will add a procress to modify the pathbuffer by delete redundant '/'! 
	Delete_RepetCharacter(BufferSelectPath,'/');
	
	TRT_SetValues(TRT_cid2,"FoldSelect",
		TRT_ATT_TEXT,BufferSelectPath,NULL);
	
	
	//How to prepare to add a item to a tree
	//at first you should know the parent item id 
	//at second you should know the item id of itself 
	//at 3rd you should know the item name which is be added to the tree.
	//at last you should add a ico to the item ,but it must not be done.
	sprintf(imagebuf,"%s\3%s\3%s\3%s\0",
		"item", "item0",BufferSelectPath,"folderop.ico");
	
	/* show root on the Tree view */
	TRT_SetValues(TRT_cid2, "Test_tree",
		/* del all already exist info on the tree view */
		TRT_ATT_LIST_DELETE_ITEMS, -1,
		/* add the item with the itemname and its icon */
		TRT_ATT_TREE_ITEMS_ADD_ID_IMAGE , imagebuf,
		NULL);
	
	//At first you should clear the filelist every time.
	TRT_SetValues(TRT_cid2, "FilesUnderFold",
		TRT_ATT_LIST_DELETE_ITEMS,-1,
		NULL); 
	
	//login the file system
	Ncs_Fsr_login("root", 0, 0, 0);
	
	//open a directory and record the "context" in the bufferXX
	
	ret=Ncs_Fsr_fopendir(BufferSelectPath,buf,1024);
	Ncs_Fsr_chdir(BufferSelectPath);
	Ncs_Fsr_getcwd(Currentpath);

	if (ret< 0)
	{
		TRT_SetValues(TRT_cid2,"Message_Display1",
			TRT_ATT_TEXT,"Read_file_Error!!!",NULL);
		return;
	}
	entry=NULL;
	do
	{
		//extract entry from the bufferXX
		ret=Ncs_Fsr_fgetdirentry(buf,&entry);
		//Get the entry state
		Ncs_Fsr_stat(entry,&file_state);
		if(ret>0) 
		{   //prepare to got a filename;
			strcpy(filebuffer,entry);
			if(S_ISDIR(file_state.st_mode)!=0){
				//make a new item id as  
				sprintf(tempr,"%d",n);
				strcat(item_base,tempr);
				
				strcpy(child_item,item_base);
				sprintf(imagebuf,"%s\3%s\3%s\3%s\0",
					"item0", child_item, entry, "folder.ico");
			
				TRT_SetValues(TRT_cid2, "Test_tree",
					TRT_ATT_TREE_ITEMS_ADD_ID_IMAGE,imagebuf,
					NULL);
				n++;
			}
			else{
				
				TRT_SetValues(TRT_cid2, "FilesUnderFold",
					TRT_ATT_ITEM_CREATE,entry,
					NULL); 
				//do someting record in order to show file list in this fold
				record[itemnumber].fileid=itemnumber;
				strcpy(record[itemnumber].filename,entry);
				itemnumber++;
			}
		}
		if (ret< 0)
		{
			TRT_SetValues(TRT_cid2,"Message_Display1",
				TRT_ATT_TEXT,"Get_Entry_Error!!!",
				NULL);
		}
	} while (ret>0);

	strcpy(BufferSelectPath,Currentpath);
	TRT_SetValues(TRT_cid2,"FoldSelect",
		TRT_ATT_TEXT,BufferSelectPath,
		NULL);
	Ncs_Fsr_fclosedir(buf);
	Ncs_Fsr_logout("root",0);
	
}

/*F*/
/*
************************************************************************
** >AUTHOR        : Jiang
**  FUNCTION NAME : FileReadTest
** 
** >DESCRIPTION: Example to Load directory into the HMI.
**               
**
** 
** >NOTES:	
**         
**         
**   
** >PARAMETER: none
** 
** >RETURN VALUE: none 
** 
** >INCLUDES :  none
** 
*/
EXPORT void FileReadTest(void){   
	
	char filenamewithpath[20]="";
	char fileselect[20]="";
	char filecontextfuffer[MAXFILESIZE];		/*have problem here.*/
	long itemid=0;
	char itemtxt[15]="";
	struct stat file_state;
	int error;
	char* point=NULL;							/*check the npg file.*/
	int number=0;
	int BreakpointPlace[20]={0};
	int i=0;
	int n=0;
	int m=0;
	char tempbuffer[4]="";
	char tablename_my[20]="";

	TRT_SetValues(TRT_cid2, "FileContext",       /* At first you shoud clear the old file context! */
		TRT_ATT_TEXT,"",
		NULL);
	error=Ncs_Fsr_login("root", 0, 0, 0);
	TRT_GetValues(TRT_cid2,"FoldSelect",

⌨️ 快捷键说明

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