Beispiel #1
0
bool DiscoveryManager::update_drive_status(const std::string& port_uuid, const std::string& drive_uuid) const {
    Port port{};
    try {
        log_debug("pnc-discovery", "Drive status update - gathering data");
        port = get_manager<Port>().get_entry(port_uuid);
        std::string chassis_uuid = m_tools.model_tool->get_chassis_uuid();
        Chassis chassis = get_manager<Chassis>().get_entry(chassis_uuid);

        log_debug("pnc-discovery", "Reading drive status (phys port = " << port.get_port_id()
                                                                        << "), twi_port = "
                                                                        << unsigned(port.get_twi_port())
                                                                        << ", twi_channel = "
                                                                        << unsigned(port.get_twi_channel()));

        Smart smart{chassis.get_platform()};
        if (m_tools.i2c_tool->get_smart(smart, port)) {
            attribute::Status status = m_tools.map_tool->get_status_from_smart(smart);
            int media_life_left = 100 - smart.fields.percentage_drive_life_used;
            log_debug("pnc-discovery", "Updating drive...");
            m_tools.model_tool->update_drive_status(drive_uuid, status, media_life_left);
        }
        else {
            throw std::runtime_error("Reading smart failed");
        }
        return true;
    }
    catch (const std::exception& e) {
        log_error("pnc-discovery", "Cannot read drive status for drive on port "
            << port.get_port_id() << ", exception: " << e.what());
        return false;
    }
}
int main() {
    Cabinet* cabinet = new Cabinet("PC cabinet");
    Chassis* chassis = new Chassis("PC Chassis");

    cabinet->Add(chassis);
    chassis->Add(new FloppyDisk("3.5 in Floppy"));


    return 0;
}
Beispiel #3
0
void dummy1 () {
	Cabinet* cabinet = new Cabinet("PC Cabinet");
	Chassis* chassis = new Chassis("PC Chassis");
	cabinet->Add(chassis);
	Bus* bus = new Bus("MCA Bus");
	bus->Add(new Card("16Mbs Token Ring"));
	chassis->Add(bus);
	chassis->Add(new FloppyDisk("3.5in Floppy"));

	std::cout << "The net price is " << chassis->NetPrice() << std::endl;
}
Beispiel #4
0
int Arm::doAction( int selection )
{
   if (selection == 0)
      dropItem( this );
   else if (selection == 1) {
      Chassis* ch = player->chassis;
      if (ch) {
         if (ch->addArm( this ) != 0)
            return -1;
      }
   }
   else
      return -1;

   return 0;
}
Beispiel #5
0
    json::Json get_chassis_endpoint(uint64_t id) {
        server::Request req;
        req.set_destination(std::string{"/redfish/v1/Chassis/"} + std::to_string(id));
        req.params[constants::PathParam::CHASSIS_ID] = std::to_string(id);
        server::Response res;
        m_endpoint.get(req, res);

        return json::Json::parse(res.get_body());;
    }
Beispiel #6
0
DiscoveryManager DiscoveryManager::create(const tools::Toolset& t) {
    std::string chassis_uuid = t.model_tool->get_chassis_uuid();
    Chassis chassis = get_manager<Chassis>().get_entry(chassis_uuid);
    DiscovererPtr discoverer{};
    BuilderFactoryPtr factory{};

    if (chassis.get_platform() == enums::PlatformType::EDK) {
        factory = std::make_shared<BuilderFactory>();
        discoverer = std::make_shared<Discoverer>(Discoverer(chassis.get_platform(), factory));
    }
    else if (chassis.get_platform() == enums::PlatformType::MF3) {
        factory = std::make_shared<BuilderFactoryMf3>();
        discoverer = std::make_shared<DiscovererMf3>(factory);
    }
    else {
        log_error("pnc-discovery", "Not supported platform specified in the configuration");
        throw std::runtime_error("Not supported platform");
    }

    return DiscoveryManager(discoverer, t, factory);
}
Beispiel #7
0
const std::string RmmKeyGenerator::generate_key(const Chassis& chassis) {
    const enums::ChassisType chassis_type = chassis.get_type();
    OptionalField<std::string> unique_property{};

    if (enums::ChassisType::Rack == chassis_type) {
        unique_property = chassis_type.to_string();
    }
    else if (enums::ChassisType::Drawer == chassis_type) {
        unique_property = chassis.get_fru_info().get_serial_number();
    }
    else {
        throw std::logic_error("Improper usage of RMM key generator.");
    }

    if (!unique_property.has_value()) {
        throw KeyValueMissingError(
            "Unique property for chassis of type " + std::string(chassis_type.to_string()) + " is missing");
    }

    return generate_key_base(chassis) + unique_property.value();
}
Beispiel #8
0
const std::string RmmKeyGenerator::generate_key(const Chassis& chassis, const NetworkInterface& nic) {
    const enums::ChassisType chassis_type = chassis.get_type();
    OptionalField<std::string> unique_property{};

    if (enums::ChassisType::Zone == chassis_type) {
        unique_property = nic.get_mac_address();
    }
    else {
        throw std::logic_error("Improper usage of RMM key generator.");
    }

    if (!unique_property.has_value()) {
        throw KeyValueMissingError(
            "Unique property for chassis of type " + std::string(chassis_type.to_string()) + " is missing");
    }

    return generate_key_base(chassis) + unique_property.value();
}
Beispiel #9
0
int main()
{	
	int count = 0;	
	int iterationCounter = 0;
	int countx = 1000;

	int middle = get_width()/2;
	setup_camera();
	
	clock_t begin = 0;
	clock_t diff = 0;

	//margin is the radius around the middle of the field of vision
	//in which we will allow the robot to go straight
	
	while(true)
	{
		panel.SetRed(true);
		panel.SetGreen(false);		
		chassis.Stop();

		//wait for user to press start
		while(!panel.GetStart())
		{
			usleep(10000);
		}	
		turn_on_camera();		
		panel.SetGreen(true);
		panel.SetRed(false);		

		/*//Go straight for a bit
		chassis.Drive(THROTTLE,0.0);
		usleep(5000000);
		chassis.Drive(0.0,0.0);
		usleep(3000000);

		//Go right for a bit
		chassis.Drive(THROTTLE,RIGHTTURN*1.0);
		usleep(2000000);
		chassis.Drive(0.0,0.0);
		usleep(3000000);

		//Go left for a bit
		chassis.Drive(THROTTLE,LEFTTURN*1.0);
		usleep(2000000);
		chassis.Drive(0.0,0.0);
		usleep(7000000);
*/
		initialize();
	
		int average = get_average(h,s,v, countx);
		float tFactor = 1.0;
		while(!panel.GetStop()) {

			//record timestamp to find elapsed time
			begin = clock();

			int difference = average - middle;
			
			if (chassis.OnHill())
			{
				cout<<"I'M ON A BOAT!!!!!!!!" <<endl; //tFactor = 0.5;
				tFactor = -.5;
			}
			else {
				 cout<<"I'M LAME!!!!!!!!!"<<endl;
				tFactor= 1.0;
			} //tFactor = 1.0;

			if(abs(difference) > STEER_TOLERANCE)
			{
				chassis.Drive(THROTTLE * tFactor, STEER_SCALE * difference * 2 / (float) get_width());
			} else {
				chassis.Drive(THROTTLE * tFactor, 0.0);
			}
			

			/*
			if (average < middle - margin) {
				//go right
				factor = abs(average - (middle - margin))/leftColumnWidth;
				chassis.Drive(THROTTLE,RIGHTTURN*factor);
			}
			else if (average > middle + margin) {
				//go left
				factor = abs(average - (middle + margin))/rightColumnWidth;
				chassis.Drive(THROTTLE,LEFTTURN*factor);
			}
			else { //go straight
				chassis.Drive(THROTTLE,0.0);
			}
			
		*/	
			if(iterationCounter%picModNumber == 0)
			{
				//save images		
				average = get_average(h,s,v,count);
				cout << average;	
				cout << "-- " <<iterationCounter << "---" << count;
				cout << "---" << "Picture taken";
				count++;
			}			
			else
			{
				//don't save
				average = get_average(h,s,v,countx);
				cout << average;	
				cout << "-- " <<iterationCounter << "---" << count;
		
			}

			diff = clock() - begin;
			cout << " --- " << (float) diff / (float) CLOCKS_PER_SEC << endl;
			usleep(5000);
			iterationCounter++;
		}
		count = 0;
		iterationCounter = 0;
		shut_down_camera();	
	}
	return 0;
}
Beispiel #10
0
int displayGame()
{
   if (current_level == NULL) return -1;

   if (game_state == EQUIP_SCREEN) {
      Chassis *ch = player->chassis;
      if (ch) {
         ch->drawEquipScreen( alt_selection );
      }
   }
   else if (game_state == EQUIP_INVENTORY) {
      Chassis *ch = player->chassis;
      if (ch) {
         ch->listEquipment( alt_selection );
         drawLimitedInventory();
      }
   }
   else if (game_state == INVENTORY_SCREEN || game_state == INVENTORY_SELECT)
   {
      drawInventory();
   }
   else if (game_state == SELECTING_ABILITY) 
   {
      drawUsableInventory();
   } 
   else
   {
      int x_start = 0;

      if (game_state == PICK_UP) {
         x_start = 25;
         drawItemStack( item_stack, "Pick up:", false, false );
      }

      doFOV();

      for (int x = x_start; x < 55; x++) {
         for (int y = 0; y < 28; y++) {

            int map_x = x + map_view_base.x, map_y = y + map_view_base.y;
            if (map_x < 0 || map_x >= current_level->x_dim ||
                  map_y < 0 || map_y >= current_level->y_dim)
               continue;

            int visibility = current_level->vision_map[map_y][map_x];
            if (visibility == 0)
               continue;

            Location &l = current_level->map[map_y][map_x];

            if (l.unit != NULL && visibility & MAP_VISIBLE) {
               l.unit->drawUnit(x, y);
            } else if (l.items != NULL) {
               l.items->drawItem(x, y);
            } else {
               if (l.ter == FLOOR)
                  writeChar( '.', C_WHITE, C_BLACK, x, y );
               else if (l.ter == IMPASSABLE_WALL)
                  writeChar( ' ', C_BLACK, C_WHITE, x, y );
               else if (l.ter >= STAIRS_UP_1 && l.ter <= STAIRS_UP_4)
                  writeChar( '<', C_WHITE, C_BLACK, x, y );
               else if (l.ter >= STAIRS_DOWN_1 && l.ter <= STAIRS_DOWN_4)
                  writeChar( '>', C_WHITE, C_BLACK, x, y );
            }

            if (visibility & MAP_SEEN && !(visibility & MAP_VISIBLE))
               dim( x, y, x, y );
         }
      }

      if (game_state == TARGETTING) {
         int x = reticle.x - map_view_base.x,
             y = reticle.y - map_view_base.y;
         colorInvert( x, y, x, y );
      }
   }

   drawSystemLog();
   drawBottomBar();

   drawDisplay();

   return 0;
}