API — Environnement

Module gagent/env : environnement partagé et pile de snapshots NSAP.

Environnement

class Environnement

Public Functions

Environnement()
virtual ~Environnement()
virtual void start() final
virtual void clear_nsap() final
virtual int push_nsap() final
virtual int pull_nsap() final
virtual std::map<int, std::string> *get_nsaps() final
inline virtual void init_env()
inline virtual void event_loop()
virtual void make_agent() final
virtual void readDataFromQueueMsg()
void serve(const std::string &socket_path)
int sendMsgMonitor(std::string msg)

Public Members

std::string id = "id"
std::string name = "name"
std::string shape = "shape"
std::string size = "size"
std::string size_x = "size_x"
std::string size_y = "size_y"
std::string size_z = "size_z"
std::string color = "color"
std::string pos_x = "pos_x"
std::string pos_y = "pos_y"
std::string val = "val"
std::string pattern = "pattern"
std::vector<std::string> vals
std::vector<VisualAgent*> list_visual_agents
int map_width = 600
int map_height = 300

Méthodes NSAP

Méthode

Retour

Description

push_nsap()

int

Empile l’état courant. Retourne la taille de la pile.

pull_nsap()

int

Restaure le snapshot le plus récent (LIFO). Retourne la taille restante, -1 si vide.

clear_nsap()

void

Vide toute la pile sans modifier l’état courant.

get_nsaps()

map<int,string>*

Retourne l’index { séquence timestamp ISO }.

Voir Snapshots de simulation (NSAP) pour des exemples complets.

Socket de visualisation

serve(socket_path) démarre un serveur Unix socket (dans un thread séparé) qui expose list_attr en JSON. Appelé automatiquement par AgentCore::initEnvironnementSystem().

Commande socket

Réponse

GET_AGENTS

JSON {width, height, agents:[...]}

GET_NSAP

JSON {count, snaps:[{seq, timestamp},...]}

Voir Visualisation web — agentview pour l’usage complet.

VisualAgent

class VisualAgent

Public Functions

VisualAgent()
VisualAgent(std::string _id)
VisualAgent(std::string _id, std::string _name)
VisualAgent(std::string _id, std::string _name, int _pos_x, int _pos_y)
VisualAgent(std::string _id, std::string _name, int _pos_x, int _pos_y, std::string _val)
virtual ~VisualAgent()

Public Members

std::string id = ""
std::string name = ""
std::string shape = ""
std::string color = ""
std::string pattern = ""
float size = 1.0
float size_x = 1.0
float size_y = 1.0
float size_z = 1.0
float pos_x = 0
float pos_y = 0
std::string val
std::vector<std::string> vals

EnvClient

gagent::platform::EnvClient (include/gagent/platform/EnvClient.hpp) est le client C++ du socket Environnement.

Méthode

Description

getAgents() string

Retourne le JSON GET_AGENTS (chaîne vide si env absent)

getNsap() string

Retourne le JSON GET_NSAP (chaîne vide si env absent)

#include <gagent/platform/EnvClient.hpp>

gagent::platform::EnvClient env;
std::string json = env.getAgents();
if (json.empty())
    std::cerr << "Environnement non disponible\n";