void GyroModel::run() { checkGyroRPM(); xplaneGyro = XPlaneData->getOrigGyro(); if(XPlaneData->arrest() > 0) { addDeviation(); } else { cage(); } addYawDeviation(); finalGyro.pitch = xplaneGyro.pitch - cageGyro.pitch; finalGyro.roll = xplaneGyro.roll - cageGyro.roll; finalGyro.yaw = xplaneGyro.yaw - cageGyro.yaw; if(finalGyro.roll>90) {finalGyro.roll = 90; } if(finalGyro.pitch>60) {finalGyro.pitch = 60; } if(finalGyro.roll<-90) {finalGyro.roll = -90; } if(finalGyro.pitch<-60) {finalGyro.pitch = -60; } XPlaneData->setGyro(finalGyro); setEQOff(); }
int exp() { /*************************************************************************** * Configuration ****************************************************************************/ // CommunicationPolicy typedef graybat::communicationPolicy::BMPI CP; // GraphPolicy typedef graybat::graphPolicy::BGL<Function> GP; // Cage typedef graybat::Cage<CP, GP> Cage; typedef typename Cage::Vertex Vertex; typedef typename Cage::Edge Edge; /*************************************************************************** * Initialize Communication ****************************************************************************/ // Create GoL Graph Config config; CP communicationPolicy(config); Cage cage(communicationPolicy); // Set communication pattern cage.setGraph(graybat::pattern::BiStar(cage.getPeers().size())); // Distribute vertices cage.distribute(graybat::mapping::Consecutive()); /*************************************************************************** * Run Simulation ****************************************************************************/ //std::vector<Event> events; std::array<unsigned, 1> input {{0}}; std::array<unsigned, 1> output {{0}}; const Vertex reply = cage.getVertex(0); for(Vertex v : cage.hostedVertices){ if(v == reply){ while(true){ Edge e = cage.recv(output); std::cout << "Got msg from " << e.source.id << ": "<< output[0] << std::endl; output[0]++; cage.send(e.inverse(), output); } } else { input[0] = v.id; v.spread(input); v.collect(input); std::cout << " Got input from master:" << input[0] << std::endl; } } return 0; }