scp-decode.cpp

来自「c++编写的用于生物信号处理的软件库」· C++ 代码 · 共 2,178 行 · 第 1/5 页

CPP
2,178
字号
		des.acquiring.manifacturer_trade_name=FindString(dim-filepos COMPAT);	}}//end section_1_14void section_1_15(descriptive &des)// section 1 tag 15{	U_int_M dim;	U_int_S i, mask, code_;	int_M pos;	//fpos_t filepos;	long filepos;	ReadByte(dim);	filepos = iftell(in); //FGETPOS(in,&filepos);	dim+=filepos COMPAT;	ReadByte(des.analyzing.institution_number);	ReadByte(des.analyzing.department_number);	ReadByte(des.analyzing.ID);	ReadByte(des.analyzing.type);	if(des.analyzing.type>1)		des.analyzing.type=2;	ReadByte(des.analyzing.manifacturer);	if(des.analyzing.manifacturer>20 && des.analyzing.manifacturer!=255)		des.analyzing.manifacturer=0;	des.analyzing.model_description=ReadString(des.analyzing.model_description=NULL,6);	ReadByte(des.analyzing.protocol_revision_number);	ReadByte(des.analyzing.category);	pos=Look(compatibility,0,3,des.analyzing.category);	if(pos<0)		pos=4;	des.analyzing.category=pos;	ReadByte(code_);	if(code_<128U)		pos=0;	else if((code_<192U) && (code_>=128U))		pos=1;	else	{		pos=Look(language_code,2,15,code_);		if(pos<0)			pos=16;	}	des.analyzing.language=pos;	ReadByte(code_);	mask=0x10;	for(i=0;i<4;i++)	{		if(code_&mask)			des.analyzing.capability[i]=i+4;		else			des.analyzing.capability[i]=i;		mask<<=1;	}	ReadByte(des.analyzing.AC);	if(des.analyzing.AC>2)		des.analyzing.AC=0;	Skip(16);	des.analyzing.analysing_program_revision_number="\0";	des.analyzing.serial_number_device="\0";	des.analyzing.device_system_software="\0";	des.analyzing.device_SCP_implementation_software="\0";	des.analyzing.manifacturer_trade_name="\0";	ReadByte(i);	if(!i)		des.analyzing.analysing_program_revision_number="\0";	else		des.analyzing.analysing_program_revision_number=ReadString(des.analyzing.analysing_program_revision_number=NULL,i);	filepos = iftell(in); //FGETPOS(in,&filepos);	des.analyzing.serial_number_device=FindString(dim-filepos COMPAT);	filepos = iftell(in); //FGETPOS(in,&filepos);	des.analyzing.device_system_software=FindString(dim-filepos COMPAT);	filepos = iftell(in); //FGETPOS(in,&filepos);	des.analyzing.device_SCP_implementation_software=FindString(dim-filepos COMPAT);	filepos = iftell(in); //FGETPOS(in,&filepos);	des.analyzing.manifacturer_trade_name=FindString(dim-filepos COMPAT);}//end section_1_15void section_1_16(descriptive &des)// section 1 tag 16{	U_int_M dim;	ReadByte(dim);	des.acquiring_institution=ReadString(des.acquiring_institution=NULL,dim);}//end section_1_16void section_1_17(descriptive &des)// section 1 tag 17{	U_int_M dim;	ReadByte(dim);	des.analyzing_institution=ReadString(des.analyzing_institution=NULL,dim);}//end section_1_17void section_1_18(descriptive &des)// section 1 tag 18{	U_int_M dim;	ReadByte(dim);	des.acquiring_department=ReadString(des.acquiring_department=NULL,dim);}//end section_1_18void section_1_19(descriptive &des)// section 1 tag 19{	U_int_M dim;	ReadByte(dim);	des.analyzing_department=ReadString(des.analyzing_department=NULL,dim);}//end section_1_19void section_1_20(clinic &cli)// section 1 tag 20{	U_int_M dim;	ReadByte(dim);	cli.referring_physician=ReadString(cli.referring_physician=NULL,dim);}//end section_1_20void section_1_21(clinic &cli)// section 1 tag 21{	U_int_M dim;	ReadByte(dim);	cli.latest_confirming_physician=ReadString(cli.latest_confirming_physician=NULL,dim);}//end section_1_21void section_1_22(clinic &cli)// section 1 tag 22{	U_int_M dim;	ReadByte(dim);	cli.technician_description=ReadString(cli.technician_description=NULL,dim);}//end section_1_22void section_1_23(descriptive &des)// section 1 tag 23{	U_int_M dim;	ReadByte(dim);	des.room=ReadString(des.room=NULL,dim);}//end section_1_23void section_1_24(descriptive &des)// section 1 tag 24{	U_int_M dim;	ReadByte(dim);	ReadByte(des.stat_code);}//end section_1_24void section_1_25(device &dev)// section 1 tag 25{	U_int_M dim;	char data[18], temp[18];	U_int_S m, g, num;	U_int_M a;	ReadByte(dim);	ReadByte(a);	ReadByte(m);	ReadByte(g);		sprintf(data,"%u%s%u",g,_month[m].sentence,a);	num=strlen(data);                                               // by E.C. may 2004	if(num!=0 && (dev.date_acquisition=(char*)mymalloc(num+1))==NULL)	{		fprintf(stderr,"Not enough memory");  // no, exit //		exit(2);	}	strcpy(dev.date_acquisition,data);        struct tm tmf;                      // by E.C. feb 2006        tmf.tm_year = a - 1900;        tmf.tm_mon  = m - 1;        tmf.tm_mday = g;        tmf.tm_hour = 0;        tmf.tm_min  = 0;        tmf.tm_sec  = 0;        tmf.tm_isdst = 0;        dev.date_acquisition2 = mktime(&tmf);    // store date in native format}//end section_1_25void section_1_26(device &dev)// section 1 tag 26{	U_int_M dim;	char hour[9], temp[9];	U_int_S h, m, s, num;	ReadByte(dim);	ReadByte(h);	ReadByte(m);	ReadByte(s);		sprintf(hour,"%u:%u:%u",h,m,s);	num=strlen(hour);                                               // by E.C. may 2004	if(num!=0 && (dev.time_acquisition=(char*)mymalloc(num+1))==NULL)	{		fprintf(stderr,"Not enough memory");  // no, exit //		exit(2);	}	strcpy(dev.time_acquisition,hour);        dev.time_acquisition2 = (time_t) (s + m*(60 + h*24));   // by E.C. feb 2006 time in seconds}//end section_1_26void section_1_27(device &dev)// section 1 tag 27{	U_int_M dim;	ReadByte(dim);	ReadByte(dev.baseline_filter);}//end section_1_27void section_1_28(device &dev)// section 1 tag 28{	U_int_M dim;	ReadByte(dim);	ReadByte(dev.lowpass_filter);}//end section_1_28void section_1_29(device &dev)// section 1 tag 29{	U_int_M dim;	U_int_S mask=0x1, val, i, max=4, ris=0;	ReadByte(dim);	ReadByte(val);	for(i=0;i<max;i++)	{		if(val&mask)			dev.other_filter[i]=i+1;		else			dev.other_filter[i]=0;		ris|=val&mask;		mask<<=1;	}	int w=dim;	while (--w) ReadByte(val);        // by E.C. may 2004 CARDIOLINE 1.0}//end section_1_29void section_1_30(clinic &cli, U_int_M &dim)// section 1 tag 30{	U_int_M val;	char *temp_string, *pos_char;	ReadByte(val);	if(val)	{		if((cli.free_text=(numeric*)realloc(cli.free_text,sizeof(numeric)*(cli.number_text+1)))==NULL)		{			fprintf(stderr,"Not enough memory");  // no, exit //			exit(2);		}		cli.free_text[cli.number_text].unit=cli.number_text+1;		cli.free_text[cli.number_text].value=val;		temp_string=ReadString(temp_string=NULL,cli.free_text[cli.number_text].value);		strcat(temp_string,STR_END);		dim+=strlen(temp_string);		if((cli.text_free_text=(char*)realloc(cli.text_free_text,dim+1))==NULL)		{			fprintf(stderr,"Not enough memory");  // no, exit //			exit(2);		}		pos_char=cli.text_free_text;		pos_char+=dim-strlen(temp_string);		strcpy(pos_char,temp_string);		free(temp_string);		cli.number_text++;	}}//end section_1_30void section_1_31(device &dev)// section 1 tag 31{	U_int_M dim;	ReadByte(dim);	if(dim)		dev.sequence_number=ReadString(dev.sequence_number=NULL,dim);	else		dev.sequence_number=STR_NULL;}//end section_1_31void section_1_32(clinic &cli, U_int_M &dim, int_S version)// section 1 tag 32{	U_int_M val;	U_int_S pos;	int_M ris;	ReadByte(val);	if(val)	{		dim+=val;		//first byte designates the Diagnostic Code Table which is applied; if 0 then the codes used are documented in the standard book.		// second byte is the code		if((cli.medical_hystory=(numeric*)realloc(cli.medical_hystory,sizeof(numeric)*(cli.number_hystory+1)))==NULL)		{			fprintf(stderr,"Not enough memory");  // no, exit //			exit(2);		}		ReadByte(pos);		cli.medical_hystory[cli.number_hystory].value=pos;		if (version != 10) {			ReadByte(pos);                 // 1 byte vers. 1.0; 2 byte vers. 2.0 by E.C. may 2004			ris=Look(_hystory,0,26,pos);			if(ris<0)				pos=26;			else				pos=ris;			cli.medical_hystory[cli.number_hystory].unit=pos;		}		cli.number_hystory++;	}}//end section_1_32void section_1_33(device &dev)// section 1 tag 33{	U_int_M dim;	U_int_S pos;	ReadByte(dim);	ReadByte(pos);	if(pos>6)		pos=0;	dev.electrode_configuration.value=pos;	ReadByte(pos);	if(pos>6)		pos=0;	dev.electrode_configuration.unit=pos;}//end section_1_33void section_1_34(device &dev)// section 1 tag 34{	U_int_M dim;	ReadByte(dim);	ReadByte(dev.TZ.offset); //complemented if negative	ReadByte(dev.TZ.index);	if(dim-4)		dev.TZ.description=FindString(dim-4);	else		dev.TZ.description="-";}//end section_1_34void section_1_35(clinic &cli, U_int_M &dim)// section 1 tag 35{	U_int_M val;	char *temp_string, *pos_char;	ReadByte(val);	if(val)	{		if((cli.free_medical_hystory=(numeric*)realloc(cli.free_medical_hystory,sizeof(numeric)*(cli.number_free_hystory+1)))==NULL)		{			fprintf(stderr,"Not enough memory");  // no, exit //			exit(2);		}		cli.free_medical_hystory[cli.number_free_hystory].unit=cli.number_free_hystory+1;		cli.free_medical_hystory[cli.number_free_hystory].value=val;		temp_string=ReadString(temp_string=NULL,cli.free_medical_hystory[cli.number_free_hystory].value);		strcat(temp_string,STR_END);		dim+=strlen(temp_string);		if((cli.text_free_medical_hystory=(char*)realloc(cli.text_free_medical_hystory,dim+1))==NULL)		{			fprintf(stderr,"Not enough memory");  // no, exit //			exit(2);		}		pos_char=cli.text_free_medical_hystory;		pos_char+=dim-strlen(temp_string);		strcpy(pos_char,temp_string);		free(temp_string);		cli.number_free_hystory++;	}}//end section_1_35void section_1_()// section 1 tag 36..254 are manufacturer specifics and are not utilized{	U_int_M dim;	ReadByte(dim);	Skip(dim);}//end section_1_void section_1_255()// section 1 tag 255{	U_int_M dim;	ReadByte(dim);}//end section_1_255#endif //______________________________________________________________________________//                              section 2//______________________________________________________________________________void section_2(pointer_section info_sections,DATA_DECODE &data)//build Huffman tables if included in the file; if none then use del default one//cannot read the dummy Huffman table{	U_int_M nt, i, j, ns=0, pos, dim;	//fpos_t filepos;	long filepos;	int_S version;	_COUNT_BYTE=info_sections.index;	ifseek(in,info_sections.index-1,0);	ID_section(info_sections.index, version);	dim=info_sections.length-16;	ReadByte(nt);	if(nt!=19999U)

⌨️ 快捷键说明

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