/* ebstrans.cc Cut & Cat program for ebs files Copyright (C) 1993/94 C.Taegert-Kilger, Institut fuer Physiologie und Biokybernetik (IPB), Universitaet Erlangen, Deutschland Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and related publications and that both that copyright notice and this permission notice appear in supporting documentation. The authors make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. Send your comments, suggestions or bug reports to ftpebs@uni-erlangen.de Or mail to Institut fuer Physiologie und Biokybernetik Markus Prosch Universitaetsstrasse 17 D-91054 Erlangen Germany $Id: ebstrans.cc,v 1.2 1994/12/15 10:52:35 msprosch Exp $ */ /* Necessary files: ebscuttr.h ebscuttr.cc parse1.h parse1.cc trace.h ebsclass.h ebsclass.cc ebshead.h ebshead.c ebs.h ebs.c */ #include "ebscuttr.h" #ifdef MSDOS #include "alloc.h" #include #endif #include //#define TRACE #undef TRACE #include "trace.h" EBSParser *t; EBSTrans *ebs_trans; // THE program int main(int argc, char **argv) { // Recording of duration // Initialize timer timeb t_first,t_second; uint32 tdiff; ftime(&t_first); // Auxiliary variables int command; // Print versioninfo MESSAGE(version,NULL,NULL); P_TRACE("Memory 1: %lu\n", (unsigned long) coreleft()); // With newly created parsing object do... t = new EBSParser(argc,argv); // Parse command and test result if (!(command = t->ParseCommand())) ERROR(ERR_INV_ARG,"Invalid command in: ",t->args_orig); P_TRACE("Command parsed\n"); // Parse arguments and test result if (!t->ParseParameters(command)) ERROR(ERR_INV_ARG,"Unable to parse parameters for command in: ", t->args_orig); P_TRACE("Parameters parsed\n"); // Try to evaluate command as simple message command if (!EvaluateParserAsMessage(t)) { // Create EBSTrans object from parsed command line ebs_trans=new EBSTrans(t); if (!ebs_trans->Valid()) ERROR(ERR_INV_OUTFILE,"Not able to open output file",NULL); P_TRACE("Output file opened\n"); // Create input objects if (!ebs_trans->CreateInputObjects()) ERROR(ERR_INV_INFILE,"Unable to create input objects",NULL); P_TRACE("Input objects created\n"); // Update input objects data if (!ebs_trans->UpdateInputObjects(command)) ERROR(ERR_INV_INFILE,"Unable to adjust input file info",NULL); P_TRACE("Input objects updated\n"); // Compute ranges for samples, channels if (!ebs_trans->ComputeRanges(command)) ERROR(ERR_UNKNOWN,"Unable to adapt integer ranges",NULL); P_TRACE("Ranges computed\n"); // Compute new starting time ebs_trans->ComputeStartingTime(command); P_TRACE("Starting time computed\n"); // Initialize data part if (!ebs_trans->InitializeData()) ERROR(ERR_UNKNOWN,"Unable to initialize data part",NULL); P_TRACE("Data part initialized\n"); // Compute units translation etc if (!ebs_trans->DeriveUnitsAndRange()) ERROR(ERR_UNKNOWN,"Problem withs units translation.\n",NULL); P_TRACE("Units and ranges derived\n"); // Transfer header data ebs_trans->ComputeNewPatientsData(); ebs_trans->ComputeNewInstitution(); ebs_trans->ComputeNewDescriptions(); ebs_trans->ComputeNewProcessingHistory(); P_TRACE("Header data transformed\n"); // Transfer channel descriptions ebs_trans->TransferChannelDescriptions(command); P_TRACE("Channel descriptions transferred\n"); // Transfer channel groups ebs_trans->TransferChannelGroups(); P_TRACE("Channel groups transferred\n"); // Extract event lists ebs_trans->GetInputEventLists(); P_TRACE("Event lists from input files transformed\n"); // Create new events for limits of input files ebs_trans->CreateInputFileEventLists(); P_TRACE("New event lists created\n"); // Get & check filters ebs_trans->DeriveFilters(); P_TRACE("Filters derived\n"); // Channel location diagram, locations ebs_trans->TransferLocationDiagrams(); P_TRACE("Location diagram transferred\n"); // Channel description // !!!!!!!!!!!!!!!!!!! // Copy data if (!ebs_trans->TransferData(command)) ERROR(ERR_UNKNOWN,"Problem with data transfer.\n",NULL); P_TRACE("Data transferred\n"); delete(ebs_trans); } delete(t); P_TRACE("Memory 1: %lu\n", (unsigned long) coreleft()); // Get time difference ftime(&t_second); tdiff=-(t_first.time*1000 + t_first.millitm)+ (t_second.time*1000 + t_second.millitm); char* time_mess; time_mess=new char[50]; sprintf(time_mess,"%lu.%3lu s", (unsigned long) tdiff/1000, (unsigned long) tdiff%1000); MESSAGE("Time elapsed since start of program: ",time_mess,"\n"); return(0); }