[
"autonomous agent",
{
"init": "{
$nom_AA = 'Consultes';
$args = trigger.data;
$refcons = $args.refcons;
$geto = $args.geto;
$__dada = $refval =>
data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]];
$Lapse = $__dada( 'Lapse' );
$Origen = $__dada( 'Origen' );
$Estels = $__dada( 'Estels' );
$cicle_actual =
1 + floor( ( timestamp - $Origen ) / $__dada( 'Interval' ) );
}",
"messages": [
{
"app": "state",
"state": "{
response[ 'consulta' ] = $refcons;
//$dada_args_ref = !! $args.ref ? $__dada( $args.ref ) : false;
if ( $refcons == 'Portal' ) {
$__resp = $r => {
response[ $r ] = $__dada( $r );
};
$refs_definidors = [
'_Accions', '_Getons', '_Portal', '_Portal_Original',
'_Convocatories', '_Pronunciaments', '_Vinculacions',
'_Getons', '_Emissions', '_Implementacions',
'_FRO', '_Calaix', 'Estels', 'Interval', 'Lapse',
'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio',
'Taxa_Conversio', 'Factor_Conversio', 'Donacio_Minima',
'Compensacio_Interficie', 'Compensacio_Promocio', 'Generacio_Minima',
'Factor_Topall_Index_Baules', 'Nombre_Delegades',
'Nombre_Aprovacions', 'Cicles_Diposit',
'Diposit_Minim', 'Provisio', 'Romanent_Minim', 'Topall_Emissions',
'_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C'
];
$respon = map( $refs_definidors, 36, $__resp );
}
if ( $refcons == 'Valor_Dada' ) {
response[ 'Valor ' || $args.ref ] = $__dada( $args.ref );
}
if ( $refcons == 'Darrera_Proposta' ) {
$id_proposta = 'proposta_' || $args.ref || '_' || $__dada( 'ordinal_' || $args.ref );
$temps_prop = $__dada( $id_proposta );
if ( !! $temps_prop ) {
$data_confirmacio = $temps_prop + $Lapse;
response[ 'Ref proposta' ] = $__dada( $id_proposta || '_ref' );
response[ 'Valor proposta' ] = $__dada( $id_proposta || '_val' );
response[ 'Proposant' ] = $__dada( $id_proposta || '_proposant' );
response[ 'Moment de la proposta' ] =
timestamp_to_string( $temps_prop, 'datetime' );
response[ 'Moment confirmacio possible' ] =
timestamp_to_string( $data_confirmacio, 'datetime' );
$data_validacio = $__dada( 'validacio_' || $id_proposta );
if ( !! $data_validacio ) {
response[ 'Hora validació' ] =
timestamp_to_string( $data_validacio, 'time' );
response[ 'Data validació' ] =
timestamp_to_string( $data_validacio, 'date' );
}
} else {
response[ 'No hi ha cap proposta per a aquest param definidor' ] = $id_proposta;
}
}
if ( $refcons == 'Dades_Calaix' ) {
$_Calaix = $__dada( '_Calaix' );
if ( !! $geto ) {
$idgeto = $__dada( $geto || '_id' );
response[ "Id getó" ] = $idgeto;
response[ "Romanent en " || $geto ] =
balance[ $_Calaix ][ $idgeto ];
response[ "Entrades en " || $geto ] =
$__dada( 'total_entrades_' || $geto );
}
response[ 'Total entrades en Bytes' ] =
$__dada( 'total_entrades_Bytes') otherwise 0;
response[ 'Total sortides en Bytes' ] =
$__dada( 'total_sortides_Bytes') otherwise 0;
response[ 'Total entrades en MBytes' ] =
round( $__dada( 'total_entrades_Bytes') / 1e6 );
response[ 'Total sortides en MBytes' ] =
round( $__dada( 'total_sortides_MBytes') / 1e6 );
response[ 'Total entrades en Estels' ] =
$__dada( 'total_entrades_Estels') otherwise 0;
response[ 'Total sortides en Estels' ] =
$__dada( 'total_sortides_Estels') otherwise 0;
response[ "Romanent en Bytes" ] =
balance[ $_Calaix ][ base ];
response[ "Romanent en MBytes" ] =
round( balance[ $_Calaix ][ base ] / 1e6 );
response[ "Romanent en Estels" ] =
balance[ $_Calaix ][ $Estels ];
}
if ( $refcons == 'Dades_Proposta' ) {
response[ 'Ref proposta ' || $args.ref ] =
$__dada( $args.ref || '_ref' );
response[ 'Valor proposta ' || $args.ref ] =
$__dada( $args.ref || '_val' );
response[ 'Proposant proposta ' || $args.ref ] =
$__dada( $args.ref || '_proposant' );
$temps_prop = $__dada( $args.ref );
$data_confirmacio = $temps_prop + $Lapse;
if ( ! $temps_prop )
bounce( 'No hi ha cap proposta amb aquesta referència ' || $temps_prop );
response[ 'Data de la proposta' ] =
timestamp_to_string( $temps_prop, 'datetime' );
response[ 'Data inici confirmacio' ] =
timestamp_to_string( $data_confirmacio, 'datetime' );
$data_aprovacio = $__dada( 'validacio_' || $args.ref );
$data_refus = $__dada( 'refus_' || $args.ref );
if ( !! $data_aprovacio )
response[ 'Proposta aprovada' ] =
timestamp_to_string( $data_aprovacio, 'date' );
if ( !! $data_refus )
response[ 'Proposta refusada' ] =
timestamp_to_string( $data_refus, 'date' );
}
if ( $refcons == 'Dades_Isox' ) {
$ref_isox = 'isox_' || $args.adr;
$data_confirmacio = $__dada( $ref_isox || '_data' );
if ( !! $data_confirmacio ) {
response[ 'Ordinal' ] = $__dada( $ref_isox || '_ordinal' );
response[ 'Proposant' ] = $__dada( $ref_isox || '_proposant' );
response[ 'Confirmant' ] = $__dada( $ref_isox || '_confirmant' );
response[ 'Data confirmació' ] = $data_confirmacio;
response[ 'Estat' ] = $__dada( $ref_isox || '_estat' );
response[ 'Index baules' ] = $__dada( $ref_isox || '_index_baules' );
} else {
response[ 'No consta cap isox amb aquesta adreça' ] = $args.adr;
$data_aspirant = $__dada( 'aspirant_' || $args.adr ) otherwise '';
if ( $data_aspirant != '' )
response[ 'Consta com a aspirant des de' ] =
timestamp_to_string( $data_aspirant, 'date' );
}
response[ 'Mitjana index baules' ] = $__dada( 'mitjana_index_baules' );
}
if ( $refcons == 'Dades_Vincle' ) {
$ref_vincle = $args.tipus || '_' || $args.nom;
$ord_vincle = $__dada( $ref_vincle );
response[ 'Ref' ] = $ref_vincle;
response[ 'Ordinal' ] = $ord_vincle;
response[ 'Adreça' ] = $__dada( $ref_vincle || '_adr' );
response[ 'Estat' ] = $__dada( $ref_vincle || '_estat' );
if ( $args.tipus == 'entitat' ) {
response[ 'Delegada 1' ] = $__dada( $ref_vincle || '_delegada_1' );
response[ 'Delegada 2' ] = $__dada( $ref_vincle || '_delegada_2' );
response[ 'Delegada 3' ] = $__dada( $ref_vincle || '_delegada_3' );
response[ 'Delegada 4' ] = $__dada( $ref_vincle || '_delegada_4' );
response[ 'Delegada 5' ] = $__dada( $ref_vincle || '_delegada_5' );
}
}
if ( $refcons == 'Dades_Assignacio' ) {
$ord_assignacio = $__dada( $args.ref );
$data_assignacio = $__dada( $ord_assignacio || '_data' );
response[ 'Ref' ] = $args.ref;
response[ 'Ordinal' ] = $ord_assignacio;
response[ 'Quantitat' ] = $__dada( $ord_assignacio || '_qt' );
response[ 'Unitat' ] = $__dada( $ord_assignacio || '_unitat' );
response[ 'Rebedora' ] = $__dada( $ord_assignacio || '_rebedora' );
response[ 'Requeriment' ] = $__dada( $ord_assignacio || '_unitat' );
response[ 'Data' ] = timestamp_to_string( $data_assignacio, 'date' );
}
if ( $refcons == 'Saldo_AA' ) {
$agent = $args.agent;
$_AA =
$agent == 'Portal' ? $args._Portal :
$agent == 'Capsa' ? $__dada( $geto || '__Capsa' ) :
$__dada( '_' || $agent );
if( $args.idgeto != 'cap' )
$idgeto = $args.idgeto;
else
$idgeto =
$geto == 'Estels' ?
$Estels :
$geto == 'Bytes' ?
'base' :
$__dada( $geto || '_id' );
response[ "Id getó" ] = $idgeto;
response[ "_AA" ] = $_AA;
$saldo = !! $idgeto ? balance[ $_AA ][ $idgeto ] : 'Getó desconegut';
if ( $geto != 'Estels' )
response[ "Romanent de " || $agent || " en " || $geto ] = $saldo;
response[ "Romanent de " || $agent || " en Bytes" ] =
balance[ $_AA ][ base ];
response[ "Romanent de " || $agent || " en MBytes" ] =
round( balance[ $_AA ][ base ] / 1e6 );
response[ "Romanent de " || $agent || " en Estels" ] =
balance[ $_AA ][ $Estels ];
}
if ( $refcons == 'Adr_AA' ) {
response[ "Adreça AA " || $args.nom ] = $__dada( '_' || $args.nom );
}
if ( $refcons == 'Missatge' ) {
$_Missatges = $__dada( '_Missatges' );
$missatge = var[ $_Missatges ][ $args.ref ];
response[ "Ref" ] = $args.ref;
response[ "Missatge" ] = $missatge;
response[ "Adreça AA Missatges" ] = $_Missatges;
}
}"
}
]
}
]