7 #include <CalciumInterface.hxx>
10 extern "C" void transit_(void *compo,double *dt);
11 extern "C" void perma_(void *compo);
13 //! Constructor for component "NEUTRO" instance
17 NEUTRO_i::NEUTRO_i(CORBA::ORB_ptr orb,
18 PortableServer::POA_ptr poa,
19 PortableServer::ObjectId * contId,
20 const char *instanceName,
21 const char *interfaceName)
22 : Superv_Component_i(orb, poa, contId, instanceName, interfaceName)
24 cerr << "create component" << endl;
26 _id = _poa->activate_object(_thisObj);
29 //! Destructor for component "NEUTRO" instance
34 //! Register datastream ports for a component service given its name
36 * \param service_name : service name
37 * \return true if port registering succeeded, false if not
40 NEUTRO_i::init_service(const char * service_name) {
41 CORBA::Boolean rtn = false;
42 string s_name(service_name);
47 std::cerr << "NEUTRO: prun: " << std::endl;
48 //initialization CALCIUM ports IN
49 calcium_real_port_provides * p1;
50 p1 = add_port<calcium_real_port_provides>("CALCIUM_real","provides","tempi");
51 p1->setDependencyType(CalciumTypes::ITERATION_DEPENDENCY);
52 calcium_integer_port_provides * p2;
53 p2 = add_port<calcium_integer_port_provides>("CALCIUM_integer","provides","iconv");
54 p2->setDependencyType(CalciumTypes::ITERATION_DEPENDENCY);
56 //initialization CALCIUM ports OUT
57 add_port<calcium_real_port_uses>("CALCIUM_real","uses","puissi");
59 catch(const PortAlreadyDefined& ex)
61 std::cerr << "NEUTRO: " << ex.what() << std::endl;
62 //Ports already created : we use them
66 std::cerr << "NEUTRO: unknown exception" << std::endl;
75 std::cerr << "NEUTRO: trun: " << std::endl;
76 //initialization CALCIUM ports IN
77 calcium_real_port_provides * p1;
78 p1 = add_port<calcium_real_port_provides>("CALCIUM_real","provides","temperature");
79 p1->setDependencyType(CalciumTypes::TIME_DEPENDENCY);
80 //initialization CALCIUM ports OUT
81 add_port<calcium_real_port_uses>("CALCIUM_real","uses","puissance");
82 add_port<calcium_integer_port_uses>("CALCIUM_integer","uses","topo");
84 catch(const PortAlreadyDefined& ex)
86 std::cerr << "NEUTRO: " << ex.what() << std::endl;
87 //Ports already created : we use them
91 std::cerr << "NEUTRO: unknown exception" << std::endl;
100 std::cerr << "NEUTRO_i::prun" << std::endl;
101 beginService("NEUTRO_i::prun");
102 Superv_Component_i * component = dynamic_cast<Superv_Component_i*>(this);
103 char nom_instance[INSTANCE_LEN];
104 int info = cp_cd(component,nom_instance);
108 //to do or not to do ???
109 cp_fin(component,CP_ARRET);
111 catch ( const CalciumException & ex)
113 std::cerr << ex.what() << std::endl;
114 cp_fin(component,CP_ARRET);
118 std::cerr << "unexpected exception" << std::endl;
119 cp_fin(component,CP_ARRET);
121 endService("NEUTRO_i::prun");
122 std::cerr << "end of NEUTRO_i::prun" << std::endl;
125 void NEUTRO_i::trun(CORBA::Double dt)
127 std::cerr << "NEUTRO_i::trun" << std::endl;
128 beginService("NEUTRO_i::trun");
129 Superv_Component_i * component = dynamic_cast<Superv_Component_i*>(this);
130 char nom_instance[INSTANCE_LEN];
131 int info = cp_cd(component,nom_instance);
134 transit_(&component,&dt);
135 //to do or not to do ???
136 cp_fin(component,CP_ARRET);
138 catch ( const CalciumException & ex)
140 std::cerr << ex.what() << std::endl;
141 cp_fin(component,CP_ARRET);
145 std::cerr << "unexpected exception" << std::endl;
146 cp_fin(component,CP_ARRET);
148 endService("NEUTRO_i::trun");
149 std::cerr << "end of NEUTRO_i::trun" << std::endl;
154 PortableServer::ObjectId * NEUTROEngine_factory( CORBA::ORB_ptr orb,
155 PortableServer::POA_ptr poa,
156 PortableServer::ObjectId * contId,
157 const char *instanceName,
158 const char *interfaceName)
160 MESSAGE("PortableServer::ObjectId * NEUTROEngine_factory()");
161 NEUTRO_i * myEngine = new NEUTRO_i(orb, poa, contId, instanceName, interfaceName);
162 return myEngine->getId() ;