| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Consultes'; |
| 6 | $versio = '0.1'; |
| 7 | |
| 8 | $args = trigger.data; |
| 9 | $_Portal = $args._Portal; |
| 10 | $refcons = $args.refcons; |
| 11 | $refgeto = $args.geto; |
| 12 | |
| 13 | $__dada = $refval => |
| 14 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]; |
| 15 | }", |
| 16 | "messages": [ |
| 17 | { |
| 18 | "app": "state", |
| 19 | "state": "{ |
| 20 | response[ 'consulta' ] = $refcons; |
| 21 | |
| 22 | $Lapse = $__dada( 'Lapse' ); |
| 23 | $cicle_actual = $__dada( 'cicle_actual' ); |
| 24 | |
| 25 | |
| 26 | if ( $refcons == 'Definidors' ) { |
| 27 | |
| 28 | $__resp = $r => { |
| 29 | response[ $r ] = $__dada( $r ); |
| 30 | }; |
| 31 | |
| 32 | $refs_definidors = [ |
| 33 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 34 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 35 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 36 | 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', |
| 37 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 38 | 'Diposit_Minim', '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 39 | ]; |
| 40 | |
| 41 | $respon = map( $refs_definidors, 22, $__resp ); |
| 42 | } |
| 43 | |
| 44 | if ( $refcons == 'Valor_Definidor' ) { |
| 45 | response[ 'Valor ' || $args.ref ] = $__dada( $args.ref ); |
| 46 | } |
| 47 | |
| 48 | if ( $refcons == 'Valor_Proposta' ) { |
| 49 | response[ 'Ref proposta ' || $args.ref ] = $__dada( $args.ref || '_ref' ); |
| 50 | response[ 'Valor proposta ' || $args.ref ] = $__dada( $args.ref || '_val' ); |
| 51 | response[ 'Proposant proposta ' || $args.ref ] = $__dada( $args.ref || '_proposant' ); |
| 52 | $temps_prop = $__dada( $args.ref ); |
| 53 | $data_confirmacio = $temps_prop + $Lapse; |
| 54 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 55 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 56 | |
| 57 | $data_validacio = $__dada( 'validacio_' || $args.ref ); |
| 58 | if ( !! $data_validacio ) { |
| 59 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 60 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | if ( $refcons == 'Darrera_Proposta' ) { |
| 65 | $ordinal_prop = $__dada( 'ordinal_' || $args.ref ); |
| 66 | $id_proposta = $args.ref || '_' || $ordinal_prop; |
| 67 | |
| 68 | if ( !! $__dada( $id_proposta ) ) { |
| 69 | $temps_prop = $__dada( $id_proposta ); |
| 70 | $data_confirmacio = $temps_prop + $Lapse; |
| 71 | |
| 72 | response[ 'Proposant' ] = $__dada( $id_proposta || '_proposant' ); |
| 73 | response[ 'Data de la proposta' ] = timestamp_to_string( $temps_prop, 'date' ); |
| 74 | response[ 'Data inici confirmacio' ] = timestamp_to_string( $data_confirmacio, 'date' ); |
| 75 | |
| 76 | $data_validacio = $__dada( 'validacio_' || $id_proposta ); |
| 77 | if ( !! $data_validacio ) { |
| 78 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 79 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 80 | } |
| 81 | } else { |
| 82 | response[ 'No hi ha cap proposta per a aquest param definidor' ] = $id_proposta; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | if ( $refcons == 'Validacio' ) { |
| 87 | $data_validacio = $__dada( 'validacio_' || $args.idprop ); |
| 88 | response[ 'Proposta' ] = $args.idprop; |
| 89 | if ( !! $data_validacio ) { |
| 90 | response[ 'Hora validació' ] = timestamp_to_string( $data_validacio, 'time' ); |
| 91 | response[ 'Data validació' ] = timestamp_to_string( $data_validacio, 'date' ); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /* |
| 96 | if ( $refcons == 'Dades_Geto' ) { |
| 97 | $refs_getons = var[ $_Portal ][ 'refs_getons' ]; |
| 98 | $ids_getons = var[ $_Portal ][ 'ids_getons' ]; |
| 99 | |
| 100 | response[ 'Id getó' ] = $ids_getons[ $refgeto ]; |
| 101 | |
| 102 | $refs = [ |
| 103 | '_FOG', '_AUT_A', 'factor_conversio', |
| 104 | 'valors_esmenables', 'llistats_editables', |
| 105 | 'bloqueig_possible', 'import_activacio', |
| 106 | 'import_subscripcio', 'import_renovacio', |
| 107 | 'taxa_conversio', 'cicles_diposit', 'derivacio', |
| 108 | '_AUT_B', '_AUT_C', '_AUT_0' |
| 109 | ]; |
| 110 | |
| 111 | $__resposta = $r => { |
| 112 | response[ $r ] = $__dada( $refgeto || '_' || $r ); |
| 113 | }; |
| 114 | |
| 115 | $resps = map( $refs, 15, $__resposta ); |
| 116 | |
| 117 | response[ 'Data implementació' ] = timestamp_to_string( $__dada( $refgeto ), 'date' ); |
| 118 | response[ 'Hora implementació' ] = timestamp_to_string( $__dada( $refgeto ), 'time' ); |
| 119 | } |
| 120 | */ |
| 121 | |
| 122 | if ( $refcons == 'Dades_Node' ) { |
| 123 | $ref_activacio = 'activacio_' || $args.adr || '_en_' || $refgeto; |
| 124 | |
| 125 | $activacio = $__dada( $ref_activacio ); |
| 126 | |
| 127 | if ( !! $activacio ) { |
| 128 | |
| 129 | $cicle_renovacio = $__dada( 'renovacio_' || $args.adr || '_' || $refgeto ); |
| 130 | |
| 131 | response[ 'Node ' || $args.adr || ' activat per a' ] = $refgeto; |
| 132 | response[ 'Nom node' ] = $__dada( $ref_activacio || '_nom' ); |
| 133 | response[ 'Aportació per activació' ] = $__dada( $ref_activacio || '_qt' ); |
| 134 | response[ 'Cicle activació' ] = $__dada( $ref_activacio || '_cicle' ); |
| 135 | response[ 'Escala activació' ] = $__dada( $ref_activacio || '_escala' ); |
| 136 | response[ 'Data activació' ] = timestamp_to_string( $__dada( $ref_activacio), 'date' ); |
| 137 | |
| 138 | $ref_subscripcio = 'subscripcio_' || $args.adr || '_en_' || $refgeto; |
| 139 | $subscripcio = $__dada( $ref_subscripcio ); |
| 140 | |
| 141 | if ( !! $subscripcio ) { |
| 142 | response[ 'Subscripció per a ' || $refgeto || ' de' ] = $args.adr; |
| 143 | response[ 'Nom subscripció' ] = $__dada( $ref_subscripcio || '_nom' ); |
| 144 | response[ '% derivació' ] = $__dada( $ref_subscripcio || '_derivacio' ); |
| 145 | response[ 'Cicle subscripció' ] = $__dada( $ref_subscripcio || '_cicle' ); |
| 146 | response[ 'Data subscripció' ] = timestamp_to_string( $__dada( $ref_subscripcio ), 'date' ); |
| 147 | response[ 'Hora subscripció' ] = timestamp_to_string( $__dada( $ref_subscripcio ), 'time' ); |
| 148 | response[ 'Total derivacions' ] = |
| 149 | $__dada( 'total_derivacions_' || $args.adr || '_en_' || $refgeto ); |
| 150 | response[ 'Darrer cicle renovat' ] = |
| 151 | $__dada( 'renovacio_' || $args.adr || '_en_' || $refgeto || '_cicle' ); |
| 152 | } |
| 153 | |
| 154 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 155 | $temps_avis = $__dada( $ref_avis ); |
| 156 | if ( !! $temps_avis ) { |
| 157 | $avis_es_actual = $temps_avis + ( $Lapse * 2 ) < timestamp; |
| 158 | if ( $avis_es_actual ) { |
| 159 | response[ 'Avís' ] = $__dada( $ref_avis || '_text' ); |
| 160 | response[ 'Hora' ] = timestamp_to_string( $temps_avis, 'time' ); |
| 161 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 162 | response[ 'Rebot' ] = $__dada( $ref_avis || '_rebot' ); |
| 163 | |
| 164 | } |
| 165 | } |
| 166 | } else { |
| 167 | response[ 'adr ' || $args.adr ] = 'NO activada per a ' || $refgeto; |
| 168 | } |
| 169 | response[ 'Cicle actual' ] = $cicle_actual; |
| 170 | } |
| 171 | |
| 172 | if ( $refcons == 'Dades_Diposit' ) { |
| 173 | response[ 'Ref' ] = $args.ref; |
| 174 | response[ 'Quantitat dipositada' ] = $__dada( $args.ref ); |
| 175 | response[ 'Dipositant' ] = $__dada( $args.ref || '_dipositant' ); |
| 176 | response[ 'Cicle dipòsit' ] = $__dada( $args.ref || '_cicle' ); |
| 177 | response[ 'Getó dipòsit' ] = $__dada( $args.ref || '_geto_diposit' ); |
| 178 | response[ 'Data dipòsit' ] = $__dada( $args.ref || '_data'); |
| 179 | |
| 180 | response[ 'Taxa' ] = $__dada( $args.ref || '_taxa' ); |
| 181 | response[ 'Qt conversió' ] = $__dada( $args.ref || '_qt_conversio' ); |
| 182 | response[ 'Cicle conversió' ] = $__dada( $args.ref || '_cicle_conversio' ); |
| 183 | } |
| 184 | |
| 185 | if ( $refcons == 'Dades_Contribucio' ) { |
| 186 | $data_cont = $__dada( $args.ref || '_data'); |
| 187 | response[ 'Ref' ] = $args.ref; |
| 188 | response[ 'Quantitat' ] = $__dada( $args.ref ); |
| 189 | response[ 'Contribuidora' ] = $__dada( $args.ref || '_contribuidora' ); |
| 190 | response[ 'Cicle contribució' ] = $__dada( $args.ref || '_cicle' ); |
| 191 | response[ 'Escala contribució' ] = $__dada( $args.ref || '_escala' ); |
| 192 | response[ 'Data contribució' ] = $data_cont; |
| 193 | response[ 'Data contribució' ] = timestamp_to_string( $data_cont, 'date' ); |
| 194 | response[ 'Total Contribucions' ] = $__dada( 'total_contribucions_en_estels' ); |
| 195 | } |
| 196 | |
| 197 | if ( $refcons == 'Totals' ) { |
| 198 | $total_geto = $__dada( 'total_en_' || $refgeto ); |
| 199 | $total_FOP = $__dada( 'total_FOP_en_' || $refgeto ); |
| 200 | $total_derivacions = $__dada( 'total_derivacions_' || '_en_' || $refgeto ); |
| 201 | $total_activacions = $__dada( 'total_activacions_en_' || $refgeto ); |
| 202 | $total_subscripcions = $__dada( 'total_subscripcions_en_' || $refgeto ); |
| 203 | $total_renovacions = $__dada( 'total_renovacions_en_' || $refgeto ); |
| 204 | $total_diposits = $__dada( 'total_diposits_en_' || $refgeto ); |
| 205 | $total_contribucions = $__dada( 'total_contribucions_en_' || $refgeto ); |
| 206 | |
| 207 | response[ 'Total Getó' ] = $total_geto; |
| 208 | response[ 'Total FOP' ] = $total_FOP; |
| 209 | response[ 'Total Activacions' ] = $total_activacions; |
| 210 | response[ 'Total Subscripcions' ] = $total_subscripcions; |
| 211 | response[ 'Total Renovacions' ] = $total_renovacions; |
| 212 | response[ 'Total Contribucions' ] = $total_contribucions; |
| 213 | response[ 'Total Derivacions' ] = $total_derivacions; |
| 214 | response[ 'Total Diposits' ] = $total_diposits; |
| 215 | } |
| 216 | |
| 217 | if ( $refcons == 'Cicle_Actual' ) { |
| 218 | $data_cicle = $__dada( 'data_cicle_' || $cicle_actual ); |
| 219 | response[ 'Cicle Actual' ] = $cicle_actual; |
| 220 | response[ 'Escala del cicle' ] = $__dada( 'escala_cicle_' || $cicle_actual ); |
| 221 | response[ 'Data en segons' ] = $data_cicle; |
| 222 | response[ 'Data del cicle' ] = timestamp_to_string( $data_cicle, 'date' ); |
| 223 | } |
| 224 | |
| 225 | if ( $refcons == 'Escala_Actual' ) { |
| 226 | $escala_actual = $__dada( 'escala_actual' ); |
| 227 | $data_escala = $__dada( 'data_escala_' || $escala_actual ); |
| 228 | response[ 'Escala Actual' ] = $escala_actual; |
| 229 | response[ "Cicle del salt d'escala" ] = $__dada( 'cicle_escala_' || $escala_actual ); |
| 230 | response[ "Data del salt d'escala" ] = timestamp_to_string( $data_escala, 'date' ); |
| 231 | response[ 'Data en segons' ] = $data_escala; |
| 232 | response[ 'Total Aportacions a FOP' ] = $__dada( 'total_FOP_en_estels' ); |
| 233 | } |
| 234 | |
| 235 | if ( $refcons == 'Avis' ) { |
| 236 | $ref_avis = 'avis_' || $refgeto || '_' || $args.adr; |
| 237 | $temps_avis = $__dada( $ref_avis ); |
| 238 | $avis_es_actual = $temps_avis + ( $Lapse * 2 ) < timestamp; |
| 239 | if ( $avis_es_actual ) { |
| 240 | response[ 'Avís' ] = $__dada( $ref_avis|| '_text' ); |
| 241 | response[ 'Hora' ] = timestamp_to_string( $temps_avis, 'time' ); |
| 242 | response[ 'Data' ] = timestamp_to_string( $temps_avis, 'date' ); |
| 243 | response[ 'Rebot' ] = $__dada( $ref_avis || '_rebot' ); |
| 244 | } else { |
| 245 | response[ 'No hi ha cap avís per a' ] = $args.adr; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if ( $refcons == 'Capacitacio' ) { |
| 250 | $ref_capacitacio = 'capacitacio_' || $refgeto || '_' || $args.accio || '_' || $args.adr; |
| 251 | |
| 252 | response[ 'Capacitacio' ] = $__dada( $ref_capacitacio ); |
| 253 | } |
| 254 | |
| 255 | if ( $refcons == 'Romanents' ) { |
| 256 | response[ 'Romanent en bytes' ] = balance[ $_Portal ][ base ]; |
| 257 | response[ "Romanent en estels" ] = balance[ $_Portal ][ $__dada( '_Estels' ) ]; |
| 258 | } |
| 259 | }" |
| 260 | } |
| 261 | ] |
| 262 | } |
| 263 | ] |