23 static const int WILDCARD = -1;
55 bool apply(
JModule& module)
const
57 if (action == setx_t) {
61 }
else if (action == addx_t) {
65 }
else if (action == subx_t) {
69 }
else if (action == sety_t) {
73 }
else if (action == addy_t) {
77 }
else if (action == suby_t) {
81 }
else if (action == setz_t) {
85 }
else if (action == addz_t) {
89 }
else if (action == subz_t) {
93 }
else if (action == mul_t) {
108 }
else if (action == div_t) {
139 friend inline std::istream&
operator>>(std::istream&
in, JModifier& modifier)
141 return in >> modifier.action >> modifier.value;
152 friend inline std::ostream&
operator<<(std::ostream& out,
const JModifier& modifier)
154 return out << modifier.action <<
' ' << modifier.value;
170 inline void print(std::ostream& out,
const JModule& module,
const JModifier& modifier)
175 out <<
"Modifier" <<
' '
177 << setw(10) << module.
getID() <<
' '
178 <<
"action " << modifier << endl;
209 int main(
int argc,
char **argv)
225 JParser<> zap(
"Auxiliary program to modify detector.");
227 zap[
'a'] =
make_field(detectorFile,
"detector file I/O");
231 zap[
'N'] =
make_field(size,
"internal buffer size") = 500000;
236 catch(
const exception &error) {
237 FATAL(error.what() << endl);
253 io.open(detectorFile.c_str(), ios::binary |
ios_base::in | ios_base::out);
256 FATAL(
"Error opening file " << detectorFile << endl);
263 io.read(buffer.data() + len, buffer.size() - len);
270 buffer.resize(2 * buffer.size());
284 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
286 if (module->
getID() ==
i->first ||
i->first == WILDCARD ){
289 print(cout, *module,
i->second);
292 if (!
i->second.apply(*module)) {
293 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
302 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
304 if (module->
getString() ==
i->first ||
i->first == WILDCARD) {
307 print(cout, *module,
i->second);
310 if (!
i->second.apply(*module)) {
311 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
320 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
324 if (module->
getString() ==
i->first ||
i->first == WILDCARD) {
327 print(cout, *module,
i->second);
330 if (!
i->second.apply(*module)) {
331 ERROR(
"No valid action: " <<
i->first <<
' ' <<
i->second << endl);
343 io.seekp(0, ios_base::beg);
345 io.write(buffer.data(), buffer.size());
Utility class to parse command line options.
JCombinatorics::pair_type pair_type
int main(int argc, char *argv[])
int getFloor() const
Get floor number.
Data structure for a composite optical module.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
static const char *const BINARY_DETECTOR_FILE_FORMAT[]
JIO binary file format.
Data structure for detector geometry and calibration.
JModule & sub(const JVector3D &pos)
Subtract position.
I/O formatting auxiliaries.
Data structure for vector in three dimensions.
const JLocation & getLocation() const
Get location.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int getID() const
Get identifier.
double getY() const
Get y position.
const JPosition3D & getPosition() const
Get position.
General purpose messaging.
int getString() const
Get string number.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Utility class to parse command line options.
std::string getFilenameExtension(const std::string &file_name)
Get file name extension, i.e. part after last JEEP::FILENAME_SEPARATOR if any.
double getX() const
Get x position.
Byte array binary output.
do set_variable DETECTOR_TXT $WORKDIR detector
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
JModule & set(const JVector3D &pos)
Set position.
double getZ() const
Get z position.
JModule & add(const JVector3D &pos)
Add position.