25 #define DIR_SEPARATOR '\\'
27 #define DIR_SEPARATOR '/'
29 #include <sys/types.h>
35 #include <sys/syslimits.h>
39 #include "driver_interface.h"
40 #include "JackCompilerDeps.h"
41 #include "JackError.h"
42 #include "JackException.h"
62 static void KillServer();
64 static int MkDir(
const char* path);
65 static char* UserDir();
66 static char* ServerDir(
const char* server_name,
char* server_dir);
67 static const char* DefaultServerName();
68 static void CleanupFiles(
const char* server_name);
69 static int GetTmpdir();
70 static void RewriteName(
const char* name,
char* new_name);
71 static void ThrowJackNetException();
74 static int ComputationMicroSec(
int buffer_size)
76 if (buffer_size < 128) {
78 }
else if (buffer_size < 256) {
106 uint32_t fMeasureCnt;
107 uint32_t fMeasurePoints;
115 JackGnuPlotMonitor ( uint32_t measure_cnt = 512, uint32_t measure_points = 5, std::string name = std::string (
"default" ) )
117 jack_log (
"JackGnuPlotMonitor::JackGnuPlotMonitor %u measure points - %u measures", measure_points, measure_cnt );
119 fMeasureCnt = measure_cnt;
120 fMeasurePoints = measure_points;
123 fCurrentMeasure =
new T[fMeasurePoints];
124 fMeasureTable =
new T*[fMeasureCnt];
125 for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ )
127 fMeasureTable[cnt] =
new T[fMeasurePoints];
128 fill_n ( fMeasureTable[cnt], fMeasurePoints, 0 );
134 jack_log (
"JackGnuPlotMonitor::~JackGnuPlotMonitor" );
136 for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ )
137 delete[] fMeasureTable[cnt];
138 delete[] fMeasureTable;
139 delete[] fCurrentMeasure;
142 T AddNew ( T measure_point )
145 return fCurrentMeasure[fMeasureId++] = measure_point;
150 return fMeasureId = 0;
153 T Add ( T measure_point )
155 return fCurrentMeasure[fMeasureId++] = measure_point;
158 uint32_t AddLast ( T measure_point )
160 fCurrentMeasure[fMeasureId] = measure_point;
167 for ( uint32_t point = 0; point < fMeasurePoints; point++ )
168 fMeasureTable[fTablePos][point] = fCurrentMeasure[point];
169 if ( ++fTablePos == fMeasureCnt )
174 int Save ( std::string name = std::string (
"" ) )
176 std::string filename = ( name.empty() ) ? fName : name;
179 jack_log (
"JackGnuPlotMonitor::Save filename %s", filename.c_str() );
181 std::ofstream file ( filename.c_str() );
183 for ( uint32_t cnt = 0; cnt < fMeasureCnt; cnt++ )
185 for ( uint32_t point = 0; point < fMeasurePoints; point++ )
186 file << fMeasureTable[cnt][point] <<
" \t";
194 int SetPlotFile ( std::string* options_list = NULL, uint32_t options_number = 0,
195 std::string* field_names = NULL, uint32_t field_number = 0,
196 std::string name = std::string (
"" ) )
198 std::string title = ( name.empty() ) ? fName : name;
199 std::string plot_filename = title +
".plt";
200 std::string data_filename = title +
".log";
202 std::ofstream file ( plot_filename.c_str() );
204 file <<
"set multiplot" << std::endl;
205 file <<
"set grid" << std::endl;
206 file <<
"set title \"" << title <<
"\"" << std::endl;
208 for ( uint32_t i = 0; i < options_number; i++ )
209 file << options_list[i] << std::endl;
212 for ( uint32_t row = 1; row <= field_number; row++ )
214 file <<
"\"" << data_filename <<
"\" using " << row <<
" title \"" << field_names[row-1] <<
"\" with lines";
215 file << ( ( row < field_number ) ?
", " :
"\n" );
218 jack_log (
"JackGnuPlotMonitor::SetPlotFile - Save GnuPlot file to '%s'", plot_filename.c_str() );
225 void BuildClientPath(
char* path_to_so,
int path_len,
const char* so_name);
226 void PrintLoadError(
const char* so_name);