Skip to content

Commit

Permalink
Implement generation queue and add DTLZ2 script (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoelBiju committed Feb 27, 2021
1 parent c85e81b commit 3e08638
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 65 deletions.
Binary file modified documents/minutes/Project Meeting - 4.docx
Binary file not shown.
Binary file removed documents/minutes/~$oject Meeting - 4.docx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export const FetchRunsType = `${microFrontendMessageId}:fetch_runs`;
export const FetchRunsResultType = `${microFrontendMessageId}:fetch_runs_result`;
export const FetchRunResultType = `${microFrontendMessageId}:fetch_run_result`;
export const VisualisationNameType = `${microFrontendMessageId}:set_visualisation_name`;
export const DataRequestType = `${microFrontendMessageId}:data_request`;
export const DataType = `${microFrontendMessageId}:set_data`;

// Socket related actions
export const InitiateSocketSuccessType = `${microFrontendMessageId}:initiate_socket_success`;
export const DisconnectSocketSuccessType = `${microFrontendMessageId}:disconnect_socket_success`;
// export const RunGenerationSuccessType = `${microFrontendMessageId}:run_generation_success`;
export const SubscribedType = `${microFrontendMessageId}:set_subscribed`;

export interface RegisterRoutePayload {
Expand Down
18 changes: 8 additions & 10 deletions packages/frontend-common/src/state/actions/socket.actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Action } from "redux";
import ioclient from "socket.io-client";
import { ActionType, ThunkResult } from "../state.types";
import {
DataRequestType,
DisconnectSocketSuccessType,
InitiateSocketSuccessType,

Expand All @@ -24,15 +25,6 @@ export const disconnectSocketSuccess = (): Action => ({
type: DisconnectSocketSuccessType,
});

// export const runGenerationSuccess = (
// generation: number
// ): ActionType<RunGenerationPayload> => ({
// type: RunGenerationSuccessType,
// payload: {
// generation,
// },
// });

export const setSubscribed = (
subscribed: boolean
): ActionType<SubscribedPayload> => ({
Expand Down Expand Up @@ -90,6 +82,10 @@ export const subscribeToGenerations = (
};
};

export const dataRequest = (): Action => ({
type: DataRequestType,
});

// Retrieve the data from a run given the ID and generation number
export const fetchData = (
dataId: string,
Expand All @@ -98,8 +94,10 @@ export const fetchData = (
return async (dispatch, getState) => {
const { socket } = getState().frontend.configuration;

// socketConnected
if (socket && socket.connected) {
// Dispatch the fetch data request
dispatch(dataRequest());

// Emit the socket event
socket.emit("data", {
dataId,
Expand Down
26 changes: 11 additions & 15 deletions packages/frontend-common/src/state/reducers/common.reducer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as log from "loglevel";
import {
DataPayload,
DataRequestType,
DataType,
DisconnectSocketSuccessType,
FetchRunResultType,
Expand Down Expand Up @@ -33,14 +34,13 @@ export const initialState: FrontendState = {
},
settingsLoaded: false,
socket: null,
// socketConnected: false,
subscribed: false,
},
runs: [],
selectedRun: null,
selectedVisualisation: "",
data: null,
// currentGeneration: 0,
fetchingData: false,
};

const updatePlugins = (
Expand Down Expand Up @@ -143,7 +143,6 @@ export function handleInitiateSocket(
configuration: {
...state.configuration,
socket: payload.socket,
// socketConnected: true,
},
};
}
Expand All @@ -154,21 +153,10 @@ export function handleDisconnectSocket(state: FrontendState): FrontendState {
configuration: {
...state.configuration,
socket: null,
// socketConnected: false,
},
};
}

// export function handleRunGeneration(
// state: FrontendState,
// payload: RunGenerationPayload
// ): FrontendState {
// return {
// ...state,
// currentGeneration: payload.generation,
// };
// }

export function handleSubscribed(
state: FrontendState,
payload: SubscribedPayload
Expand All @@ -182,13 +170,21 @@ export function handleSubscribed(
};
}

export function handleDataRequest(state: FrontendState): FrontendState {
return {
...state,
fetchingData: true,
};
}

export function handleData(
state: FrontendState,
payload: DataPayload
): FrontendState {
return {
...state,
data: payload.data,
fetchingData: false,
};
}

Expand All @@ -201,9 +197,9 @@ const CommonReducer = createReducer(initialState, {
[FetchRunResultType]: handleFetchRun,
[InitiateSocketSuccessType]: handleInitiateSocket,
[DisconnectSocketSuccessType]: handleDisconnectSocket,
// [RunGenerationSuccessType]: handleRunGeneration,
[VisualisationNameType]: handleVisualisationName,
[SubscribedType]: handleSubscribed,
[DataRequestType]: handleDataRequest,
[DataType]: handleData,
});

Expand Down
5 changes: 1 addition & 4 deletions packages/frontend-common/src/state/state.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ export interface FrontendState {
urls: SettingsUrls;
settingsLoaded: boolean;
socket: SocketIOClient.Socket | null;
// TODO: Add subscribed to state?
// TODO: Remove socketConnected
// socketConnected: boolean;
subscribed: boolean;
};
runs: Run[];
selectedRun: Run | null;
selectedVisualisation: string;
data: Data;
// currentGeneration: number;
fetchingData: boolean;
}

export interface StateType {
Expand Down
7 changes: 4 additions & 3 deletions packages/frontend-plugin/src/visualisation.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ const VisualisationComponent = (props: VCProps): React.ReactElement => {
const chartRef: React.RefObject<SVGSVGElement> = React.createRef<SVGSVGElement>();

const margin = {
top: 10,
top: 50,
right: 30,
bottom: 30,
left: 60,
};

const width = 760 - margin.left - margin.right;
const height = 800 - margin.top - margin.bottom;
const height = 450 - margin.top - margin.bottom;

const xScale: d3.ScaleLinear<number, number> = d3
.scaleLinear()
Expand Down Expand Up @@ -178,7 +179,7 @@ const VisualisationComponent = (props: VCProps): React.ReactElement => {
.attr("cx", (d) => xScale(d[0]) as number)
.attr("cy", (d) => yScale(d[1]) as number)
.attr("r", 3)
.style("fill", "#69b3a2");
.style("fill", "blue");
},
[currentChart, xScale, yScale]
);
Expand Down
3 changes: 1 addition & 2 deletions packages/frontend/src/components/mainAppBar.component.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AppBar, CssBaseline, Link, Toolbar, Typography } from '@material-ui/core';
import { createStyles, makeStyles } from '@material-ui/core/styles';
import React from 'react';
import { Link as RouterLink } from 'react-router-dom';

const useStyles = makeStyles(() =>
createStyles({
Expand All @@ -20,7 +19,7 @@ const MainAppBar = (): React.ReactElement => {
<AppBar position="fixed">
<Toolbar>
<Typography variant="h6" noWrap>
<Link component={RouterLink} to="/" color="inherit" underline="none">
<Link href="/" color="inherit" underline="none">
Visualising Optimisation Data
</Link>
</Typography>
Expand Down
Loading

0 comments on commit 3e08638

Please sign in to comment.