| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes'; |
| 6 | |
| 7 | $args = trigger.data; |
| 8 | $refcons = $args.refcons; |
| 9 | $refgeto = $args.geto; |
| 10 | |
| 11 | $__dada = $refval => |
| 12 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]; |
| 13 | |
| 14 | $Lapse = $__dada( 'Lapse' ); |
| 15 | $Origen = $__dada( 'Origen' ); |
| 16 | $cicle_actual = |
| 17 | 1 + floor( ( timestamp - $Origen ) / $__dada( 'Interval' ) ); |
| 18 | }", |
| 19 | "messages": [ |
| 20 | { |
| 21 | "app": "state", |
| 22 | "state": "{ |
| 23 | response[ 'consulta' ] = $refcons; |
| 24 | |
| 25 | |
| 26 | if ( $refcons == 'Portal' ) { |
| 27 | |
| 28 | $__resp = $r => { |
| 29 | response[ $r ] = $__dada( $r ); |
| 30 | }; |
| 31 | |
| 32 | $refs_definidors = [ |
| 33 | '_Accions', '_Getons', '_Validacions_TEST', |
| 34 | '_Convocatories', '_Pronunciaments', '_Validadores', |
| 35 | '_Getons', '_Emissions', '_Implementacions', |
| 36 | '_FRO', '_FOP', 'Estels', 'Interval', 'Lapse', |
| 37 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 38 | 'Taxa_Conversio', 'Factor_Conversio', 'Compensacio_Interficie', |
| 39 | 'Compensacio_Promocio', 'Generacio_Minima', |
| 40 | 'Factor_Topall_Index_Baules', 'Nombre_Delegades', |
| 41 | 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 42 | 'Diposit_Minim', 'Provisio', 'Romanent_Minim', 'Topall_Emissions', |
| 43 | '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 44 | ]; |
| 45 | |
| 46 | $respon = map( $refs_definidors, 34, $__resp ); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | if ( $refcons == 'Valor_Dada' ) { |
| 51 | response[ 'Valor ' || $args.ref ] = $__dada( $args.ref ); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | if ( $refcons == 'Darrera_Proposta' ) { |
| 56 | $id_proposta = 'proposta_' || $args.ref || '_' || $__dada( 'ordinal_' || $args.ref ); |
| 57 | $temps_prop = $__dada( $id_proposta ); |
| 58 | |
| 59 | if ( !! $temps_prop ) { |
| 60 | $data_confirmacio = $temps_prop + $Lapse; |
| 61 | |
| 62 | response[ 'Ref proposta' ] = $__dada( $id_proposta || '_ref' ); |
| 63 | response[ 'Valor proposta' ] = $__dada( $id_proposta || '_val' ); |
| 64 | response[ 'Proposant' ] = $__dada( $id_proposta || '_proposant' ); |
| 65 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 66 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 67 | |
| 68 | $data_validacio = $__dada( 'validacio_' || $id_proposta ); |
| 69 | if ( !! $data_validacio ) { |
| 70 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 71 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 72 | } |
| 73 | } else { |
| 74 | response[ 'No hi ha cap proposta per a aquest param definidor' ] = $id_proposta; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | |
| 79 | if ( $refcons == 'Valor_Proposta' ) { |
| 80 | response[ 'Ref proposta ' || $args.ref ] = $__dada( $args.ref || '_ref' ); |
| 81 | response[ 'Valor proposta ' || $args.ref ] = $__dada( $args.ref || '_val' ); |
| 82 | response[ 'Proposant proposta ' || $args.ref ] = $__dada( $args.ref || '_proposant' ); |
| 83 | $temps_prop = $__dada( $args.ref ); |
| 84 | $data_confirmacio = $temps_prop + $Lapse; |
| 85 | |
| 86 | if ( ! $temps_prop ) |
| 87 | bounce( 'No hi ha cap proposta amb aquesta referència ' || $temps_prop ); |
| 88 | |
| 89 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 90 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 91 | |
| 92 | $data_aprovacio = $__dada( 'validacio_' || $args.ref ); |
| 93 | $data_refus = $__dada( 'refus_' || $args.ref ); |
| 94 | |
| 95 | if ( !! $data_aprovacio ) |
| 96 | response[ 'Proposta aprovada' ] = timestamp_to_string( $data_aprovacio, 'date' ); |
| 97 | if ( !! $data_refus ) |
| 98 | response[ 'Proposta refusada' ] = timestamp_to_string( $data_refus, 'date' ); |
| 99 | } |
| 100 | |
| 101 | |
| 102 | if ( $refcons == 'Dades_Isox' ) { |
| 103 | $ref_isox = 'isox_' || $args.adr; |
| 104 | $data_confirmacio = $__dada( $ref_isox || '_data' ); |
| 105 | |
| 106 | if ( !! $data_confirmacio ) { |
| 107 | response[ 'Ordinal' ] = $__dada( $ref_isox || '_ordinal' ); |
| 108 | response[ 'Proposant' ] = $__dada( $ref_isox || '_proposant' ); |
| 109 | response[ 'Confirmant' ] = $__dada( $ref_isox || '_confirmant' ); |
| 110 | response[ 'Data confirmació' ] = $data_confirmacio; |
| 111 | response[ 'Estat' ] = $__dada( $ref_isox || '_estat' ); |
| 112 | response[ 'Index baules' ] = $__dada( $ref_isox || '_index_baules' ); |
| 113 | } else { |
| 114 | response[ 'No consta cap isox amb aquesta adreça' ] = $args.adr; |
| 115 | $data_aspirant = $__dada( 'aspirant_' || $args.adr ) otherwise ''; |
| 116 | if ( $data_aspirant != '' ) |
| 117 | response[ 'Consta com a aspirant des de' ] = |
| 118 | timestamp_to_string( $data_aspirant, 'date' ); |
| 119 | } |
| 120 | response[ 'Mitjana index baules' ] = $__dada( 'mitjana_index_baules' ); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | if ( $refcons == 'Dades_Vincle' ) { |
| 125 | response[ 'Nom' ] = $__dada( $args.ref_vincle || '_nom' ); |
| 126 | response[ 'Estat' ] = $__dada( $args.ref_vincle || '_estat' ); |
| 127 | } |
| 128 | |
| 129 | if ( $refcons == 'Dades_Entitat' ) { |
| 130 | $ref_vincle = $__dada( 'Entitat_' || $args.ordinal ); |
| 131 | response[ 'Nom' ] = $__dada( $ref_vincle || '_nom' ); |
| 132 | response[ 'Adreça' ] = $__dada( $ref_vincle || '_adr' ); |
| 133 | response[ 'Estat' ] = $__dada( $ref_vincle || '_estat' ); |
| 134 | response[ 'Delegada 1' ] = $__dada( $ref_vincle || '_delegada_1' ); |
| 135 | response[ 'Delegada 2' ] = $__dada( $ref_vincle || '_delegada_2' ); |
| 136 | response[ 'Delegada 3' ] = $__dada( $ref_vincle || '_delegada_3' ); |
| 137 | response[ 'Delegada 4' ] = $__dada( $ref_vincle || '_delegada_4' ); |
| 138 | response[ 'Delegada 5' ] = $__dada( $ref_vincle || '_delegada_5' ); |
| 139 | } |
| 140 | |
| 141 | if ( $refcons == 'Romanents' ) { |
| 142 | response[ 'Romanent en bytes Portal' ] = balance[ $args._Portal ][ base ]; |
| 143 | response[ "Romanent en estels Portal" ] = balance[ $args._Portal ][ $__dada( 'Estels' ) ]; |
| 144 | response[ 'Romanent en bytes Validacions' ] = balance[ $__dada( '_Validacions' ) ][ base ]; |
| 145 | response[ "Romanent en estels Validacions" ] = balance[ $__dada( '_Validacions' ) ][ $__dada( 'Estels' ) ]; |
| 146 | response[ 'Romanent en bytes Registre' ] = balance[ $args._Registre ][ base ]; |
| 147 | response[ "Romanent en estels Registre" ] = balance[ $args._Registre ][ $__dada( 'Estels' ) ]; |
| 148 | } |
| 149 | |
| 150 | if ( $refcons == 'Saldo_AA' ) { |
| 151 | $agent = $args.agent; |
| 152 | $nomgeto = $args.nomgeto; |
| 153 | $_AA = $agent == 'Portal' ? $args._Portal : $__dada( '_' || $agent ); |
| 154 | |
| 155 | if( $args.idgeto != 'cap' ) |
| 156 | $idgeto = $args.idgeto; |
| 157 | else |
| 158 | $idgeto = |
| 159 | $nomgeto == 'Estels' ? |
| 160 | $__dada( 'Estels' ) : |
| 161 | $__dada( 'geto_' || $nomgeto || '_id' ); |
| 162 | |
| 163 | response[ "Id getó" ] = $idgeto; |
| 164 | response[ "_AA" ] = $_AA; |
| 165 | |
| 166 | $saldo = !! $idgeto ? balance[ $_AA ][ $idgeto ] : 'Getó desconegut'; |
| 167 | |
| 168 | if ( $nomgeto != 'Estels' ) |
| 169 | response[ "Romanent de " || $agent || " en " || $nomgeto ] = $saldo; |
| 170 | |
| 171 | response[ "Romanent de " || $agent || " en bytes" ] = |
| 172 | balance[ $_AA ][ base ]; |
| 173 | |
| 174 | response[ "Romanent de " || $agent || " en Estels" ] = |
| 175 | balance[ $_AA ][ $__dada( 'Estels' ) ]; |
| 176 | } |
| 177 | }" |
| 178 | } |
| 179 | ] |
| 180 | } |
| 181 | ] |