2 #include "DSCCODCENG.hxx"
5 #include "CalciumInterface.hxx"
8 //! Constructor for component "DSCCODC" instance
12 DSCCODC_i::DSCCODC_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 "DSCCODC" instance
25 DSCCODC_i::~DSCCODC_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 DSCCODC_i::init_service(const char * service_name) {
36 CORBA::Boolean rtn = false;
37 string s_name(service_name);
42 std::cerr << "DSCCODC: prun: " << std::endl;
44 //initialization CALCIUM ports
45 calcium_integer_port_provides * p1;
46 /* ETP_EN T IN ENTIER */
47 p1 = add_port<calcium_integer_port_provides>("CALCIUM_integer","provides","ETP_EN");
48 p1->setDependencyType(CalciumTypes::TIME_DEPENDENCY);
49 /* STP_EN T OUT ENTIER */
50 add_port<calcium_integer_port_uses>("CALCIUM_integer","uses","STP_EN");
51 //end of initialization CALCIUM ports
53 catch(const PortAlreadyDefined& ex)
55 std::cerr << "DSCCODC: " << ex.what() << std::endl;
56 //Ports already created : we use them
60 std::cerr << "DSCCODC: unknown exception" << std::endl;
69 std::cerr << "DSCCODC: trun: " << std::endl;
70 calcium_real_port_provides * p1;
71 /* ETP_RE T IN REEL */
72 p1 = add_port<calcium_real_port_provides>("CALCIUM_real","provides","ETP_RE");
73 p1->setDependencyType(CalciumTypes::TIME_DEPENDENCY);
74 /* STP_RE T OUT REEL */
75 add_port<calcium_real_port_uses>("CALCIUM_real","uses","STP_RE");
77 catch(const PortAlreadyDefined& ex)
79 std::cerr << "DSCCODC: " << ex.what() << std::endl;
80 //Ports already created : we use them
84 std::cerr << "DSCCODC: unknown exception" << std::endl;
91 void DSCCODC_i::prun(CORBA::Long niter)
93 cerr << "DSCCODC_i::prun" << endl;
94 Superv_Component_i * component = dynamic_cast<Superv_Component_i*>(this);
95 std::cerr << "Valeur de component : " << component << std::endl;
96 std::cerr << "Valeur de this : " << this << std::endl;
97 char nom_instance[INSTANCE_LEN];
98 int SDATA_EN [3]; // buffer
99 int EDATA_EN [3]; // buffer
101 int info = cp_cd(component,nom_instance);
103 float ti_re = 0.0; // step time
104 int i = 0; // not used
108 info = cp_een(component,CP_TEMPS,ti_re,i,"STP_EN",2,SDATA_EN);
110 float tf_re = 1.0; // step start time
111 int max=3; // max size expected
112 int n; // real size received
114 info = cp_len(component,CP_TEMPS,&ti_re,&tf_re,&i,"ETP_EN",max,&n,EDATA_EN);
116 for (int i = 0; i < n; ++i)
117 cerr << "seqLongData[" << i << "] = " << EDATA_EN[i] << endl;
119 cerr << "end of DSCCODC_i::prun" << endl;
122 void DSCCODC_i::trun(CORBA::Long niter)
124 cerr << "DSCCODC_i::trun" << endl;
125 Superv_Component_i * component = dynamic_cast<Superv_Component_i*>(this);
126 char nom_instance[INSTANCE_LEN];
127 int info = cp_cd(component,nom_instance);
129 float SDATA_RE [3], EDATA_RE [3];
134 float ti_re = 0.0; // time
135 int i = 0; // not used
137 info = cp_ere(component,CP_TEMPS,ti_re,i,"STP_RE",2,SDATA_RE);
138 cerr << "apres cp_ere: " << info << endl;
140 int max=3; // max size expected
141 int n=2; // real size received
142 float tf_re = 1.0; // time
143 info = cp_lre(component,CP_TEMPS,&ti_re,&tf_re,&i,"ETP_RE",max,&n,EDATA_RE);
145 for (int i = 0; i < n; ++i)
146 cerr << "seqRealData[" << i << "] = " << EDATA_RE[i] << endl;
147 cerr << "end of DSCCODC_i::trun" << endl;
152 PortableServer::ObjectId * DSCCODCEngine_factory( CORBA::ORB_ptr orb,
153 PortableServer::POA_ptr poa,
154 PortableServer::ObjectId * contId,
155 const char *instanceName,
156 const char *interfaceName)
158 MESSAGE("PortableServer::ObjectId * DSCCODCEngine_factory()");
159 DSCCODC_i * myEngine = new DSCCODC_i(orb, poa, contId, instanceName, interfaceName);
160 return myEngine->getId() ;