Giter Club home page Giter Club logo

swe-gateway's People

Contributors

aletomm avatar brohpotato avatar fouadm96 avatar giovd8 avatar lorenzodeinegri avatar maxelweb avatar nfrison avatar nicolofrison avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

swe-gateway's Issues

[OTHER] Rivalutare i pacchetti inviati dal gateway

Cambiamenti per i pacchetti inviati a Kafka

I pacchetti inviati dal gateway dovranno contenere solamente un array di sensori registrati, con il relativo id dispositivo e valore.

  • Il timestamp verrà generato direttamente nel DB --> Maggiore inconsistenza in caso di intasamento dei dati, minore peso del pacchetto, nessun rischio di primary key
  • Il timestamp viene generato all'invio del pacchetto --> Maggiore peso del pacchetto, una operazione in meno per il DB, rischio di coincidenza con la primary key

Quale conviene fare?

[OTHER] Valori di base del simulatore dispositivi

US-GATEWAY-1

Host: 127.0.1.1
Porta 6969
Dispositivi ID:

  • 1 (2 sensori con valori impostati a 5) [1-2]
  • 2 (1 sensore con valore impostato a 10) [1]
  • 3 (1 sensore con valori impostati a 15) [1]
  • 4 (2 sensore con valori impostati a 20) [1-2]
  • 5 (3 sensori con valori impostati a 30) [1-2-3]
  • 6 (3 sensori con valori impostati a 35) [1-2-3]

Tutti gli altri sensori presenti nei dispositivi hanno un valore di default di 120
Variazione sul valore base: +2 / -2

[NEW] Progettazione e codifica Gateway

Obiettivi

  • Invio dati a Kafka
  • Invio richieste al device tramite un protocollo binario da 1 byte (4 bit dispositivo, 4 bit sensore) con ricezione dati
  • Traduzione (serializer) dati ricevuti (risposte device) in JSON

[FIX] Default config e configurazione del gateway

I gateway hanno un tempo globale di attesa dei dispositivi. Il cambio va fatto solo per un singolo dispositivo.

Soluzione di @nfrison che si potrebbe implementare:

Mantenendo il gateway stupido, si potrebbe implementare un campo dati ~last_sent nel dispositivo. Eseguire un for che controlla il last sent con il tempo di fetch aspettato ed esegue la richiesta.

Gateway arduino

GATEWAY_NAME: gw_arduino
BOOTSTRAP_SERVER = core.host.redroundrobin.site:29094 (in GatewayClient e in GatewayManager)
Resettare gateway config

SOSTITUITO SENSORE 1 CON UN LED BLU

SOSTITUITO SENSORE 1 CON UN LED BLU

deviceId: 1
sensors: 
  {
    sensorId: 1
    type: led blu
    cmdEnabled: true
  },
  {
    sensorId: 2
    type: potentiometer 1,
    cmdEnabled: false
  },
  {
    sensorId: 3
    type: potentiometer 2
    cmdEnabled: false
  },
  {
    sensorId: 4
    type: led giallo
    cmdEnabled: true
  },
  {
    sensorId: 5
    type: led arancione
    cmdEnabled: true
  },
  {
    sensorId: 6
    type: led rosso
    cmdEnabled: true
  }

[OTHER] Cose da realizzare per il PoC

  • Creare 3 compilati Java con all'interno dispositivi e sensori differenti
  • Per ciascun compilato, un Dockerfile direttamente avviabile con Java all'interno
  • Accoppiata /gateway - /java-simulator

[GLOBAL] - Collegarsi ad un topic di Kafka

https://community.boomi.com/s/article/howtoconnecttoanapachekafkatopic#jive_content_id_2_Configure_the_Local_Atom

import java.util.Properties;
import java.io.InputStream;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.*;

// Configure Kafka settings
String TOPIC_NAME = "BoomiTopic";
String SERVER_HOST = "localhost:9092";

// Initialize Kafka connection
Properties props = new Properties();
props.put("bootstrap.servers", SERVER_HOST)
props.put("acks", "all");
props.put("retries", 0);
props.put("batch.size", 16384);
props.put("linger.ms", 1);
props.put("buffer.memory", 33554432);
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");

Producer<String, String> producer = new KafkaProducer(props);

// Loop through documents and send to Kafka topic
for (int i = 0; i < dataContext.getDataCount(); i++) {
  InputStream is = dataContext.getStream(i);
  Properties Bprops = dataContext.getProperties(i);

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  byte[] buffer = new byte[1024];
  int length;
  while ((length = is.read(buffer)) != -1) {
    baos.write(buffer, 0, length);
  }

  String docString = baos.toString("UTF-8");

  producer.send(new ProducerRecord<String, String>(TOPIC_NAME, docString));
}

producer.close();

// Create simple response document to return to process
String responseDocument = "Success";
dataContext.storeStream(new ByteArrayInputStream(responseDocument.getBytes()), new Properties());

[OTHER] Simulatori Gateway per regione

KAFKA


API


Webapp

  • Website: localhost (da avviare in locale)

US-GATEWAY-1 / US-DEVICE-1

Host: us1.host.redroundrobin.site
Porta 6969
Dispositivi ID:

  • 1 (2 sensori con valori impostati a 5) [1-2]
  • 2 (1 sensore con valore impostato a 10) [1]

SG-GATEWAY-2 / SG-DEVICE-2

Host: sg2.host.redroundrobin.site
Porta 6970
Dispositivi ID:

  • 3 (1 sensore con valori impostati a 15) [1]
  • 4 (2 sensore con valori impostati a 20) [1-2]

DE-GATEWAY-3 / DE-DEVICE-1

Host: de3.host.redroundrobin.site
Porta 6971
Dispositivi ID:

  • 5 (3 sensori con valori impostati a 30) [1-2-3]
  • 6 (3 sensori con valori impostati a 35) [1-2-3]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.