Skip to content

Commit

Permalink
Pis structure mppt maarya jennifer (#71)
Browse files Browse the repository at this point in the history
* after conflicts

* finished up showing data for MPPT

* after conflicts

* finished up showing data for MPPT

* added Alive and checked units

---------

Co-authored-by: jenniferja <[email protected]>
  • Loading branch information
maaryaahmed and JenniferJa authored Feb 25, 2024
1 parent 1a6aead commit 33f295f
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 247 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/eslint.yml

This file was deleted.

4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd app
npx lint-staged
npx eslint . --config .eslintrc.cjs --fix
cd app && npx lint-staged
5 changes: 0 additions & 5 deletions app/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@ node_modules
dist
out
.gitignore
vite.config.ts
tailwind.config.ts
electron.vite.config.ts
src/main/*
src/preload/*
12 changes: 5 additions & 7 deletions app/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ const project = path.join(__dirname, "./src/renderer/tsconfig.json");

/** @type {import("eslint").Linter.Config} */
const config = {
settings: {
react: {
version: "detect",
},
},
overrides: [
{
extends: [
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:promise/recommended",
],
files: ["src/renderer/**/*.tsx", "src/renderer/**/*.ts"],
files: ["*.ts", "*.tsx"],
parserOptions: {
project,
},
Expand All @@ -29,6 +24,9 @@ const config = {
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
project,
},
plugins: ["@typescript-eslint", "prettier", "promise"],
extends: [
"plugin:react/recommended",
Expand All @@ -50,7 +48,7 @@ const config = {
"prettier/prettier": ["error", prettierConfig],
"no-eval": "error",
"no-var": "error",
"prettier/prettier": "error",
// "prettier/prettier": "error",
"no-restricted-imports": ["error", { patterns: [".*"] }],
"tailwindcss/no-custom-classname": "off",
"tailwindcss/classnames-order": "off", // tcss prettier plugin handles this
Expand Down
2 changes: 1 addition & 1 deletion app/src/preload/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ElectronAPI } from "@electron-toolkit/preload";
import { ElectronAPI } from "@electron-toolkit/preload";

declare global {
interface Window {
Expand Down
3 changes: 2 additions & 1 deletion app/src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ if (process.contextIsolated) {
console.error(error);
}
} else {
// @ts-ignore (define in dts)
window.electron = electronAPI;

// @ts-ignore (define in dts)
window.api = api;
}
3 changes: 2 additions & 1 deletion app/src/renderer/code/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";

import App from "@/App";
import { render, screen } from "@testing-library/react";

import App from "./App";

test("renders learn react link", () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
Expand Down
112 changes: 7 additions & 105 deletions app/src/renderer/code/components/tabs/MpptTab.tsx
Original file line number Diff line number Diff line change
@@ -1,111 +1,13 @@
/* eslint-disable @typescript-eslint/restrict-plus-operands */
import MpptComponent from "@/components/molecules/HeroMolecules/MpptTabMolecules/MpptComponent";
import { type MpptData } from "@/objects/MpptProps";
import { faker } from "@faker-js/faker";
// eslint-disable-next-line prettier/prettier
import PISTransformer from "@/components/transformers/PIStransformer";
import mppt from "@/objects/PIS/PIS.mppt";

const fakeData: MpptData = {
Unit0: {
Channel0: {
arrayVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
arrayCurrent:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "C",
batteryVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
temperature:
faker.number.float({ min: 22.0, max: 100.0, precision: 0.01 }) + "C",
},
Channel1: {
arrayVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
arrayCurrent:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "C",
batteryVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
temperature:
faker.number.float({ min: 22.0, max: 100.0, precision: 0.01 }) + "C",
},
},
Unit1: {
Channel0: {
arrayVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
arrayCurrent:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "C",
batteryVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
temperature:
faker.number.float({ min: 22.0, max: 100.0, precision: 0.01 }) + "C",
},
Channel1: {
arrayVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
arrayCurrent:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "C",
batteryVoltage:
faker.number.float({ min: 0.0, max: 100.0, precision: 0.01 }) + "V",
temperature:
faker.number.float({ min: 22.0, max: 100.0, precision: 0.01 }) + "C",
},
},
};

function MpptTab() {
function MpptTab(): JSX.Element {
return (
<>
<div className="flex h-full flex-nowrap justify-evenly text-center">
<div id="Unit 0" className="w-full ">
<h1 className="text-lg font-medium">Unit 0</h1>
<div id="channels" className="flex justify-center">
<div id="Channel 0" className=" w-full pr-2">
<div className="flex justify-center">
<h2 className="font-medium">Channel 0</h2>
<div className="ml-2 mt-1.5 size-3 rounded-full bg-green dark:bg-green-dark"></div>
</div>
<MpptComponent channelData={fakeData.Unit0.Channel0} />
<div className="h-36 rounded-lg bg-slate-300">
Placeholder Graph
</div>
</div>
<div id="Channel 1" className=" w-full pr-2">
<div className="flex justify-center">
<h2 className="font-medium">Channel 1</h2>
<div className="ml-2 mt-1.5 size-3 rounded-full bg-green dark:bg-green-dark"></div>
</div>
<MpptComponent channelData={fakeData.Unit0.Channel1} />
<div className="h-36 rounded-lg bg-slate-200">
Placeholder Graph
</div>
</div>
</div>
</div>
<div id="Unit 1" className="w-full">
<h1 className="text-lg font-medium">Unit 1</h1>
<div id="channels" className="flex justify-center">
<div id="Channel 0" className=" w-full pr-2">
<div className="flex justify-center">
<h2 className="font-medium">Channel 0</h2>
<div className="ml-2 mt-1.5 size-3 rounded-full bg-green dark:bg-green-dark"></div>
</div>
<MpptComponent channelData={fakeData.Unit1.Channel0} />
<div className="h-36 rounded-lg bg-slate-300">
Placeholder Graph
</div>
</div>
<div id="Channel 1" className=" w-full">
<div className="flex justify-center">
<h2 className="font-medium">Channel 1</h2>
<div className="ml-2 mt-1.5 size-3 rounded-full bg-green dark:bg-green-dark"></div>
</div>
<MpptComponent channelData={fakeData.Unit1.Channel1} />
<div className="h-36 rounded-lg bg-slate-200">
Placeholder Graph
</div>
</div>
</div>
</div>
</div>
</>
<div>
<PISTransformer root={mppt()} />
</div>
);
}

Expand Down
21 changes: 21 additions & 0 deletions app/src/renderer/code/contexts/PacketContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,27 @@ export function PacketContextProvider({
BatteryVoltage: faker.number.int({ min: 0, max: 100 }),
Temperature: faker.number.int({ min: 0, max: 100 }),
},
{
Alive: faker.datatype.boolean(),
ArrayCurrent: faker.number.int({ min: 0, max: 100 }),
ArrayVoltage: faker.number.int({ min: 0, max: 100 }),
BatteryVoltage: faker.number.int({ min: 0, max: 100 }),
Temperature: faker.number.int({ min: 0, max: 100 }),
},
{
Alive: faker.datatype.boolean(),
ArrayCurrent: faker.number.int({ min: 0, max: 100 }),
ArrayVoltage: faker.number.int({ min: 0, max: 100 }),
BatteryVoltage: faker.number.int({ min: 0, max: 100 }),
Temperature: faker.number.int({ min: 0, max: 100 }),
},
{
Alive: faker.datatype.boolean(),
ArrayCurrent: faker.number.int({ min: 0, max: 100 }),
ArrayVoltage: faker.number.int({ min: 0, max: 100 }),
BatteryVoltage: faker.number.int({ min: 0, max: 100 }),
Temperature: faker.number.int({ min: 0, max: 100 }),
},
],
TimeStamp: faker.number.int({ min: 0, max: 100 }),
});
Expand Down
3 changes: 1 addition & 2 deletions app/src/renderer/code/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ root.render(
</React.StrictMode>,
);

// TO DO
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
void reportWebVitals();
reportWebVitals();
Loading

0 comments on commit 33f295f

Please sign in to comment.