Definition: [
"autonomous agent",
{
"init": "{
$nom_AA = 'Consultes';
$args = trigger.data;
$_Portal = $args._Portal;
$refcons = $args.refcons;
$refgeto = $args.geto;
$__dada = $refval =>
data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]];
$Lapse = $__dada( 'Lapse' );
$Origen = $__dada( 'Origen' );
$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', '_Validacions', '_Validadores',
'_FRO', '_Estels', 'Interval', 'Lapse',
'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio',
'Taxa_Conversio', 'Factor_Conversio', 'Compensacio_Interficie',
'Compensacio_Promocio', 'Generacio_Minima',
'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit',
'Diposit_Minim', '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C'
];
$respon = map( $refs_definidors, 24, $__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[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' );
response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' );
$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 == 'Valor_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;
response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' );
response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' );
$data_validacio = $__dada( 'validacio_' || $args.ref );
if ( !! $data_validacio ) {
response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' );
response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' );
}
}
if ( $refcons == 'Validacio' ) {
$data_validacio = $__dada( 'validacio_' || $args.idprop );
if ( !! $data_validacio ) {
response[ 'Proposta' ] = $args.idprop;
response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' );
response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' );
} else
response[ 'La proposta ' || $args.idprop ] = 'no consta com a validada';
}
if ( $refcons == 'Dades_Node' ) {
$ref_activacio = 'activacio_' || $args.adr || '_en_' || $refgeto;
$data_activacio = $__dada( $ref_activacio );
if ( !! $data_activacio ) {
response[ 'Node ' || $args.adr || ' activat per a' ] = $refgeto;
response[ 'Nom node' ] = $__dada( $ref_activacio || '_nom' );
response[ 'Aportació per activació' ] = $__dada( $ref_activacio || '_qt' );
response[ 'Cicle activació' ] = $__dada( $ref_activacio || '_cicle' );
response[ 'Escala activació' ] = $__dada( $ref_activacio || '_escala' );
response[ 'Interval activació' ] = $__dada( $ref_activacio || '_interval' );
response[ 'Data activació' ] = timestamp_to_string( $data_activacio, 'date' );
$ref_subscripcio = 'subscripcio_' || $args.adr || '_en_' || $refgeto;
$data_subscripcio = $__dada( $ref_subscripcio );
if ( !! $data_subscripcio ) {
response[ 'Subscripció per a ' || $refgeto || ' de' ] = $args.adr;
response[ 'Nom subscripció' ] = $__dada( $ref_subscripcio || '_nom' );
response[ '% derivació' ] = $__dada( $ref_subscripcio || '_derivacio' );
response[ 'Cicle subscripció' ] = $__dada( $ref_subscripcio || '_cicle' );
response[ 'Data subscripció' ] = timestamp_to_string( $data_subscripcio, 'date' );
response[ 'Total derivacions' ] =
$__dada( 'total_derivacions_' || $args.adr || '_en_' || $refgeto );
response[ 'Darrer cicle renovat' ] =
$__dada( 'renovacio_' || $args.adr || '_en_' || $refgeto || '_cicle' );
}
$ref_avis = 'avis_' || $refgeto || '_' || $args.adr;
$temps_avis = $__dada( $ref_avis );
if ( $temps_avis ) {
$avis_es_actual = $temps_avis + ( $Lapse * 2 ) < timestamp;
if ( $avis_es_actual ) {
response[ 'Avís' ] = $__dada( $ref_avis || '_text' );
response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' );
response[ 'Rebot' ] = $__dada( $ref_avis || '_rebot' );
}
}
} else {
response[ 'adr ' || $args.adr ] = 'NO activada per a ' || $refgeto;
}
response[ 'Cicle actual' ] = $cicle_actual;
}
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[ 'Mitjana baules' ] = $__dada( $ref_isox || '_mitjana_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' );
}
}
if ( $refcons == 'Dades_Diposit' ) {
response[ 'Ref' ] = $args.ref;
response[ 'Quantitat dipositada' ] = $dada_args_ref;
response[ 'Dipositant' ] = $__dada( $args.ref || '_dipositant' );
response[ 'Cicle dipòsit' ] = $__dada( $args.ref || '_cicle' );
response[ 'Getó dipòsit' ] = $__dada( $args.ref || '_geto_diposit' );
response[ 'Data dipòsit' ] = $__dada( $args.ref || '_data');
//response[ 'Data dipòsit' ] = timestamp_to_string( $__dada( $args.ref || '_data'), 'date' );
response[ 'Taxa' ] = $__dada( $args.ref || '_taxa' );
response[ 'Qt conversió' ] = $__dada( $args.ref || '_qt_conversio' );
response[ 'Cicle conversió' ] = $__dada( $args.ref || '_cicle_conversio' );
response[ 'Cicle actual' ] = $cicle_actual;
}
if ( $refcons == 'Dades_Contribucio' ) {
response[ 'Ref' ] = $args.ref;
response[ 'Quantitat' ] = $dada_args_ref;
response[ 'Contribuidora' ] = $__dada( $args.ref || '_contribuidora' );
response[ 'Cicle contribució' ] = $__dada( $args.ref || '_cicle' );
response[ 'Escala contribució' ] = $__dada( $args.ref || '_escala' );
response[ 'Interval contribució' ] = $__dada( $args.ref || '_interval' );
response[ 'Data contribució' ] = $__dada( $args.ref || '_data');
$data_escala = $__dada( 'data_escala_actual' );
response[ "Segons transcorreguts des del darrer salt d'escala" ] =
timestamp - $data_escala;
response[ 'Total Contribucions' ] = $__dada( 'total_contribucions_en_estels' );
}
if ( $refcons == 'Dades_Conversio' OR $refcons == 'Dades_Retribucio' ) {
response[ 'Ref' ] = $args.ref;
response[ 'Destinatària' ] = $__dada( $args.ref || '_destinataria' );
response[ 'Quantitat' ] = $__dada( $args.ref || '_qt' );
response[ 'Data' ] = timestamp_to_string( $__dada( $args.ref || '_data' ), 'date' );
if ( $refcons == 'Dades_Conversio' )
response[ 'Unitat' ] = $__dada( $args.ref || '_unitat' );
}
if ( $refcons == 'Totals' ) {
$total_geto = $__dada( 'total_en_' || $refgeto );
$total_FOP = $__dada( 'total_FOP_en_' || $refgeto );
$total_derivacions = $__dada( 'total_derivacions_en_' || $refgeto );
$total_activacions = $__dada( 'total_activacions_en_' || $refgeto );
$total_subscripcions = $__dada( 'total_subscripcions_en_' || $refgeto );
$total_renovacions = $__dada( 'total_renovacions_en_' || $refgeto );
$total_diposits = $__dada( 'total_diposits_en_' || $refgeto );
$total_contribucions = $__dada( 'total_contribucions_en_' || $refgeto );
$total_conversions = $__dada( 'total_conversions_de_' || $refgeto );
$total_taxes = $__dada( 'total_taxes_de_' || $refgeto );
$total_retribucions = $__dada( 'total_retribucions' );
$total_assignacions = $__dada( 'total_assignacions' );
response[ 'Total Getó' ] = $total_geto;
response[ 'Total FOP' ] = $total_FOP;
response[ 'Total Activacions' ] = $total_activacions;
response[ 'Total Subscripcions' ] = $total_subscripcions;
response[ 'Total Renovacions' ] = $total_renovacions;
response[ 'Total Derivacions' ] = $total_derivacions;
response[ 'Total Diposits' ] = $total_diposits;
response[ 'Total Contribucions' ] = $total_contribucions;
response[ 'Total Conversions' ] = $total_conversions;
response[ 'Total Taxes' ] = $total_taxes;
response[ 'Total Retribucions' ] = $total_retribucions;
response[ 'Total Assignacions' ] = $total_assignacions;
}
if ( $refcons == 'Cicle_Actual' ) {
$interval = $__dada( 'Interval' );
$segons_cicle_actual = ( $Origen + ( $cicle_actual * $interval ) ) - timestamp;
$percent_cicle_actual = $segons_cicle_actual / $interval * 100;
response[ 'Cicle actual' ] = $cicle_actual;
response[ 'Data actual' ] = timestamp;
response[ 'Data origen' ] = $Origen;
response[ 'Durada cicles' ] = $interval;
response[ 'Segons restants cicle actual' ] = $segons_cicle_actual;
response[ '% restant del cicle actual' ] =
round( $percent_cicle_actual, 0 ) || ' %';
}
if ( $refcons == 'Escala_Actual' ) {
$escala_actual = $__dada( 'escala_actual' );
$data_escala = $__dada( 'data_escala_actual' );
response[ 'Escala Actual' ] = $escala_actual;
response[ "Data del salt d'escala" ] = timestamp_to_string( $data_escala, 'date' );
response[ 'Data en segons' ] = $data_escala;
response[ 'Segons transcorreguts des de salt escala' ] = timestamp - $data_escala;
response[ 'Total Aportacions a FOP' ] = $__dada( 'total_FOP_en_estels' );
}
if ( $refcons == 'Romanents' ) {
response[ 'Romanent en bytes' ] = balance[ $_Portal ][ base ];
response[ "Romanent en estels" ] = balance[ $_Portal ][ $__dada( '_Estels' ) ];
}
}"
}
]
}
]