24 package org.lightvoting.simulation.action.message;
26 import org.lightjason.agentspeak.action.IBaseAction;
27 import org.lightjason.agentspeak.agent.IAgent;
28 import org.lightjason.agentspeak.common.CPath;
29 import org.lightjason.agentspeak.common.IPath;
30 import org.lightjason.agentspeak.language.CLiteral;
31 import org.lightjason.agentspeak.language.CRawTerm;
32 import org.lightjason.agentspeak.language.ITerm;
33 import org.lightjason.agentspeak.language.execution.IContext;
34 import org.lightjason.agentspeak.language.execution.fuzzy.CFuzzyValue;
35 import org.lightjason.agentspeak.language.execution.fuzzy.IFuzzyValue;
36 import org.lightjason.agentspeak.language.instantiable.plan.trigger.CTrigger;
37 import org.lightjason.agentspeak.language.instantiable.plan.trigger.ITrigger;
40 import java.util.List;
42 import java.util.concurrent.ConcurrentHashMap;
49 public final class CSend extends IBaseAction
54 private final Map<String, CVotingAgent>
m_agents =
new ConcurrentHashMap<>();
62 m_agents.put( p_agent.name(), p_agent );
73 m_agents.remove( p_agent.name() );
80 return CPath.from(
"message/send" );
90 public final IFuzzyValue<Boolean>
execute(
final IContext p_context,
final boolean p_parallel,
final List<ITerm> p_argument,
91 final List<ITerm> p_return )
96 final IAgent<?> l_receiver = m_agents.get( p_argument.get( 0 ).<String>raw() );
99 if ( l_receiver == null )
100 return CFuzzyValue.from( false );
105 ITrigger.EType.ADDGOAL,
117 p_argument.subList( 1, p_argument.size() ).stream().map( i -> CRawTerm.from( i.raw() ) )
123 CLiteral.from(
"from", CRawTerm.from( p_context.agent().<
CVotingAgent>raw().name() ) )
129 return CFuzzyValue.from( true );
final IFuzzyValue< Boolean > execute(final IContext p_context, final boolean p_parallel, final List< ITerm > p_argument, final List< ITerm > p_return)
final CVotingAgent unregister(final CVotingAgent p_agent)
Unregisters agent Removes agent from map.
final Map< String, CVotingAgent > m_agents
thread-safe map for storing name and agent object
Action to send messages for communication.
BDI agent with voting capabilities.
final int minimalArgumentNumber()