source: Sophya/trunk/SophyaPI/ProgPI/sopiamodule.cc@ 1533

Last change on this file since 1533 was 1481, checked in by ansari, 24 years ago

correction petit bug ds sopiamodule.cc - Reza 30/4/2001

File size: 2.6 KB
Line 
1#include "machdefs.h"
2#include <stdio.h>
3#include <stdlib.h>
4#include <iostream.h>
5#include <math.h>
6
7#include <typeinfo>
8
9#include <vector>
10#include <string>
11
12#include "piacmd.h"
13#include "nobjmgr.h"
14#include "pistdimgapp.h"
15#include "servnobjm.h"
16#include "tvector.h"
17#include "pitvmaad.h"
18#include "fftpserver.h"
19#include "bruit.h"
20#include "piscdrawwdg.h"
21#include "ctimer.h"
22
23extern "C" {
24void sopiamodule_init();
25void sopiamodule_end();
26}
27
28void SophyaFFT(string& nom, string& nomout, string dopt);
29
30class sopiamoduleExecutor : public CmdExecutor {
31public:
32 sopiamoduleExecutor();
33 virtual ~sopiamoduleExecutor();
34 virtual int Execute(string& keyw, vector<string>& args, string& toks);
35};
36
37/* --Methode-- */
38sopiamoduleExecutor::sopiamoduleExecutor()
39{
40
41PIACmd * mpiac;
42NamedObjMgr omg;
43mpiac = omg.GetImgApp()->CmdInterpreter();
44
45string hgrp = "SophyaCmd";
46string kw = "powerspec";
47string usage = "FFT on a vector -> Plots power spectrum ";
48usage += "\n Usage: fftp vecName vecFFT [graphic_att] ";
49mpiac->RegisterCommand(kw, usage, this, hgrp);
50
51}
52
53/* --Methode-- */
54sopiamoduleExecutor::~sopiamoduleExecutor()
55{
56}
57
58/* --Methode-- */
59int sopiamoduleExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
60{
61
62if (kw == "powerspec") {
63 if (tokens.size() < 2) {
64 cout << "Usage: powerspec nameVec vecFFT [graphic_att]" << endl;
65 return(0);
66 }
67 if (tokens.size() < 3) tokens.push_back((string)"n");
68 SophyaFFT(tokens[0], tokens[1], tokens[2]);
69 }
70
71return(0);
72
73}
74
75static sopiamoduleExecutor * piaerex = NULL;
76/* Nouvelle-Fonction */
77void sopiamodule_init()
78{
79// Fonction d'initialisation du module
80// Appele par le gestionnaire de modules de piapp (PIACmd::LoadModule())
81if (piaerex) delete piaerex;
82piaerex = new sopiamoduleExecutor;
83}
84
85/* Nouvelle-Fonction */
86void sopiamodule_end()
87{
88// Desactivation du module
89if (piaerex) delete piaerex;
90piaerex = NULL;
91}
92
93
94/* --Methode-- */
95void SophyaFFT(string& nom, string& nomout, string dopt)
96{
97Timer tm("powerspec");
98NamedObjMgr omg;
99AnyDataObj* obj=omg.GetObj(nom);
100if (obj == NULL) {
101 cout << "SophyaFFT() Error , Pas d'objet de nom " << nom << endl;
102 return;
103}
104
105Vector* vin = dynamic_cast<Vector *>(obj);
106if (vin == NULL) {
107 cout << "SophyaFFT() Error , Objet n'est pas un vecteur " << endl;
108 return;
109 }
110TVector< complex<double> > * vout = new TVector< complex<double> > ;
111FFTPackServer ffts;
112cout << "SophyaFFT() - Computing FFT of vector size " << vin->NElts() << endl;
113ffts.FFTForward(*vin, *vout);
114// cout << " SophyaFFT - FFT done " << endl;
115 // tm.Split(" FFT done ");
116
117omg.AddObj(vout, nomout);
118omg.DisplayObj(nomout, dopt);
119return;
120
121}
Note: See TracBrowser for help on using the repository browser.