redroundrobin / swe-gateway Goto Github PK
View Code? Open in Web Editor NEWswe-thirema // Componente gateway per i dispositivi e kafka
Home Page: http://gateway.redroundrobin.site
License: MIT License
swe-thirema // Componente gateway per i dispositivi e kafka
Home Page: http://gateway.redroundrobin.site
License: MIT License
I pacchetti inviati dal gateway dovranno contenere solamente un array di sensori registrati, con il relativo id dispositivo e valore.
Quale conviene fare?
Host: 127.0.1.1
Porta 6969
Dispositivi ID:
Tutti gli altri sensori presenti nei dispositivi hanno un valore di default di
120
Variazione sul valore base: +2 / -2
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_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
}
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());
Host: us1.host.redroundrobin.site
Porta 6969
Dispositivi ID:
Host: sg2.host.redroundrobin.site
Porta 6970
Dispositivi ID:
Host: de3.host.redroundrobin.site
Porta 6971
Dispositivi ID:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.