Skip to content

Commit

Permalink
⚡ add UIA data to data chunk
Browse files Browse the repository at this point in the history
User now recieves UIA control and UIA state data
as part of the data chunk.
  • Loading branch information
geraldo-cisneros committed Feb 27, 2023
1 parent bb7b879 commit 813c5f0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 109 deletions.
30 changes: 20 additions & 10 deletions sequelize/models/imumsg.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,62 @@ module.exports = (sequelize) => {
heading: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
accel_x: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
accel_y: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
accel_z: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
gyro_x: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
gyro_y: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
gyro_z: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
mag_x: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
mag_y: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
},
mag_z: {
allowNull: true,
type: DataTypes.DOUBLE,
unique: false
unique: false,
defaultValue: null,
}
});
};
17 changes: 11 additions & 6 deletions sockets/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const server = http.createServer();
const wss = new SocketServer.WebSocketServer({ server });
const HMD_UPDATE_INTERVAL = 2000; //Milliseconds
const { models } = require('../sequelize');
const room_id = 1;

let parser = new Parser();

Expand Down Expand Up @@ -59,14 +60,18 @@ wss.on('connection', (ws, req) => {

setInterval(async function() {
try {
gps_val = await models.gpsmsg.findAll({ where: { id: 1 }});
imu_val = await models.imumsg.findAll({ where: { id: 1 }});
telem_val = await models.simulationstate.findAll({ where: { id: 1 }});
gps_val = await models.gpsmsg.findAll({ where: { id: room_id }});
imu_val = await models.imumsg.findAll({ where: { id: room_id }});
uia_val = await models.simulationstateuia.findAll({where: {id: room_id}});
uia_control_val = await models.simulationuia.findAll({where: {id: room_id}});
telem_val = await models.simulationstate.findAll({ where: { id: room_id }});

const data = {
gpsmsgs: gps_val,
imumsgs: imu_val,
simulationstates: telem_val
GPS: gps_val,
IMU: imu_val,
EVA: telem_val,
UIA: uia_control_val,
UIA_CONTROLS: uia_val
};

ws.send(JSON.stringify(data));
Expand Down
96 changes: 3 additions & 93 deletions sqlite-example-database/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,102 +34,10 @@ async function reset() {
await sequelize.sync({ force: true });

await sequelize.models.user.bulkCreate([
{
id: 1,
username: 'faiz',
room: 10,
guid: 'ef0110ad-cd77-413d-af5e-88cd4091f50c',
},
{
id: 2,
username: 'faiz2',
room: 11,
guid: 'a429f7b1-882a-4642-901b-f859687f8292',
}
// { username: 'jack-sparrow' },
// { username: 'white-beard' },
// { username: 'black-beard' },
// { username: 'brown-beard' },

]);

await sequelize.models.devices.bulkCreate([
{
name: 'VK01',
description: 'Student Kit',
guid: 'ef0110ad-cd77-413d-af5e-88cd4091f50c',
type: 'VK',
macaddress: 'B7-02-BC-4A-E2-61'
},
{
name: 'VK02',
description: 'Student Kit',
guid: 'a429f7b1-882a-4642-901b-f859687f8292',
type: 'VK',
macaddress: '8E-95-15-2A-A9-E0'
},
{
name: 'VK03',
description: 'Student Kit',
guid: null,
type: 'VK',
macaddress: 'F4-AF-1B-86-E5-AC'
},
{
name: 'VK04',
description: 'Student Kit',
guid: null,
type: 'VK',
macaddress: '51-C2-CC-74-73-D7'
},
{
name: 'VK05',
description: 'Student Kit',
guid: null,
type: 'VK',
macaddress: '5A-F9-2F-21-C0-8E'
},
{
name: 'HMD01',
description: 'Student Kit',
guid: 'ef0110ad-cd77-413d-af5e-88cd4091f50c',
type: 'HMD',
macaddress: '1F-4E-B3-1A-9D-05'
},
{
name: 'HMD02',
description: 'Student Kit',
guid: 'a429f7b1-882a-4642-901b-f859687f8292',
type: 'HMD',
macaddress: 'A7-DB-C5-CA-B4-69'
},
{
name: 'HMD03',
description: 'Student Kit',
guid: null,
type: 'HMD',
macaddress: 'CC-49-F8-98-CE-D7'
},
{
name: 'HMD04',
description: 'Student Kit',
guid: null,
type: 'HMD',
macaddress: 'C8-E2-26-01-EB-48'
},
{
name: 'HMD05',
description: 'Student Kit',
guid: null,
type: 'HMD',
macaddress: '4B-9B-39-86-47-43'
},
{
name: 'EVA01',
description: 'Student Kit',
guid: 'ef0110ad-cd77-413d-af5e-88cd4091f50c',
type: 'EVA',
macaddress: '6F-06-95-BB-22-63'
}

]);
await sequelize.models.lsar.bulkCreate([
Expand All @@ -154,6 +62,8 @@ async function reset() {
await sequelize.models.simulationstate.create(simRow);
await sequelize.models.simulationstateuia.create(simRow);
await sequelize.models.simulationuia.create(simRow);
await sequelize.models.gpsmsg.create(simRow);
await sequelize.models.imumsg.create(simRow);
});

await sequelize.models.role.bulkCreate([
Expand Down

0 comments on commit 813c5f0

Please sign in to comment.