2 #include "DSCCODDENG.hxx"
5 #include "CalciumInterface.hxx"
8 //! Constructor for component "DSCCODD" instance
12 DSCCODD_i::DSCCODD_i(CORBA::ORB_ptr orb,
13 PortableServer::POA_ptr poa,
14 PortableServer::ObjectId * contId,
15 const char *instanceName,
16 const char *interfaceName)
17 : Superv_Component_i(orb, poa, contId, instanceName, interfaceName)
19 cerr << "create component" << endl;
21 _id = _poa->activate_object(_thisObj);
24 //! Destructor for component "DSCCODD" instance
25 DSCCODD_i::~DSCCODD_i()
29 //! Register datastream ports for a component service given its name
31 * \param service_name : service name
32 * \return true if port registering succeeded, false if not
35 DSCCODD_i::init_service(const char * service_name) {
36 CORBA::Boolean rtn = false;
37 string s_name(service_name);
42 std::cerr << "DSCCODD: prun: " << std::endl;
43 //initialization CALCIUM ports
44 calcium_integer_port_provides * p1;
45 /* ETP_EN T IN ENTIER */
46 p1 = add_port<calcium_integer_port_provides>("CALCIUM_integer","provides","ETP_EN");
47 p1->setDependencyType(CalciumTypes::TIME_DEPENDENCY);
48 /* STP_EN T OUT ENTIER */
49 add_port<calcium_integer_port_uses>("CALCIUM_integer","uses","STP_EN");
50 //end of initialization CALCIUM ports
52 catch(const PortAlreadyDefined& ex)
54 std::cerr << "DSCCODD: " << ex.what() << std::endl;
55 //Ports already created : we use them
59 std::cerr << "DSCCODD: unknown exception" << std::endl;
68 std::cerr << "DSCCODD: trun: " << std::endl;
69 calcium_real_port_provides * p1;
70 /* ETP_RE T IN REEL */
71 p1 = add_port<calcium_real_port_provides>("CALCIUM_real","provides","ETP_RE");
72 p1->setDependencyType(CalciumTypes::TIME_DEPENDENCY);
73 /* STP_RE T OUT REEL */
74 add_port<calcium_real_port_uses>("CALCIUM_real","uses","STP_RE");
76 catch(const PortAlreadyDefined& ex)
78 std::cerr << "DSCCODD: " << ex.what() << std::endl;
79 //Ports already created : we use them
83 std::cerr << "DSCCODD: unknown exception" << std::endl;
90 void DSCCODD_i::prun(CORBA::Long niter)
92 cerr << "DSCCODD_i::prun" << endl;
93 Superv_Component_i * component = dynamic_cast<Superv_Component_i*>(this);
94 std::cerr << "Valeur de component : " << component << std::endl;
95 std::cerr << "Valeur de this : " << this << std::endl;
96 char nom_instance[INSTANCE_LEN];
97 int SDATA_EN [3]; // buffer
98 int EDATA_EN [3]; // buffer
100 int info = cp_cd(component,nom_instance);
102 int i = 0; // not used
103 float ti_re = 0.0; // step time
104 float tf_re = 1.0; // step start time
105 int max=3; // max size expected
106 int n; // real size received
108 info = cp_len(component,CP_TEMPS,&ti_re,&tf_re,&i,(char *)"ETP_EN",max,&n,EDATA_EN);
110 for (int i = 0; i < n; ++i)
112 SDATA_EN[i]=EDATA_EN[i]*2;
113 cerr << "seqLongData[" << i << "] = " << EDATA_EN[i] << endl;
116 info = cp_een(component,CP_TEMPS,ti_re,i,(char *)"STP_EN",n,SDATA_EN);
117 cerr << "end of DSCCODD_i::prun" << endl;
120 void DSCCODD_i::trun(CORBA::Long niter)
122 cerr << "DSCCODD_i::trun" << endl;
123 Superv_Component_i * component = dynamic_cast<Superv_Component_i*>(this);
124 char nom_instance[INSTANCE_LEN];
125 int info = cp_cd(component,nom_instance);
127 float SDATA_RE [3], EDATA_RE [3];
129 int i = 0; // not used
130 float ti_re = 0.0; // time
131 int max=3; // max size expected
132 int n=2; // real size received
133 float tf_re = 1.0; // time
135 info = cp_lre(component,CP_TEMPS,&ti_re,&tf_re,&i,(char *)"ETP_RE",max,&n,EDATA_RE);
137 cerr << "apres cp_lre: " << n << endl;
138 for (int i = 0; i < n; ++i)
140 SDATA_RE[i]=EDATA_RE[i]*2;
141 cerr << "seqRealData[" << i << "] = " << EDATA_RE[i] << endl;
144 info = cp_ere(component,CP_TEMPS,ti_re,i,(char *)"STP_RE",n,SDATA_RE);
145 cerr << "end of DSCCODD_i::trun" << endl;
150 PortableServer::ObjectId * DSCCODDEngine_factory( CORBA::ORB_ptr orb,
151 PortableServer::POA_ptr poa,
152 PortableServer::ObjectId * contId,
153 const char *instanceName,
154 const char *interfaceName)
156 MESSAGE("PortableServer::ObjectId * DSCCODDEngine_factory()");
157 DSCCODD_i * myEngine = new DSCCODD_i(orb, poa, contId, instanceName, interfaceName);
158 return myEngine->getId() ;