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

Last change on this file since 855 was 722, checked in by ansari, 26 years ago

Creation module ProgPI pour piapp/SOPHYA Reza 6/2/2000

File size: 2.5 KB
RevLine 
[722]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);
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)
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{
97NamedObjMgr omg;
98AnyDataObj* obj=omg.GetObj(nom);
99if (obj == NULL) {
100 cout << "SophyaFFT() Error , Pas d'objet de nom " << nom << endl;
101 return;
102}
103
104Vector* vin = dynamic_cast<Vector *>(obj);
105if (vin == NULL) {
106 cout << "SophyaFFT() Error , Objet n'est pas un vecteur " << endl;
107 return;
108 }
109
110TVector< complex<double> > * vout = new TVector< complex<double> > (1) ;
111FFTPackServer ffts;
112cout << "SophyaFFT() - Executing FFT of vector size " << vin->NElts() << endl;
113ffts.FFTForward(*vin, *vout);
114Timer tm;
115tm.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.