Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
xnkevinnguyen committed Feb 10, 2020
2 parents 86610b6 + 8f4a1eb commit 53b998f
Show file tree
Hide file tree
Showing 37 changed files with 5,098 additions and 5,083 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def debug_show(state):

if state != previous_state:
previous_state = copy.deepcopy(state)
message = utils.create_message(state, CONSTANTS.CPX)

updated_state = utils.update_state_with_device_name(state, CONSTANTS.CPX)
message = utils.create_message(updated_state)

update_state(json.dumps(message))


Expand Down
20 changes: 13 additions & 7 deletions src/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,30 @@
previous_state = {}


def create_message(state, device_name):
state_copy = dict(state)
def update_state_with_device_name(state, device_name):
updated_state = dict(state)

state_ext = {
"device_name": device_name,
}
state_copy.update(state_ext)
updated_state.update(state_ext)

return updated_state


message = {"type": "state", "data": json.dumps(state_copy)}
def create_message(state):
message = {"type": "state", "data": json.dumps(state)}
return message


def send_to_simulator(state, device_name):
global previous_state

message = create_message(state, device_name)
updated_state = update_state_with_device_name(state, device_name)
message = create_message(updated_state)

if state != previous_state:
previous_state = copy.deepcopy(state)
if updated_state != previous_state:
previous_state = copy.deepcopy(updated_state)
print(json.dumps(message) + "\0", end="", file=sys.__stdout__, flush=True)
time.sleep(CONSTANTS.TIME_DELAY)

Expand Down
8 changes: 5 additions & 3 deletions src/view/components/cpx/CpxSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

import * as React from "react";
import { CONSTANTS, WEBVIEW_MESSAGES } from "../../constants";
import { CONSTANTS, WEBVIEW_MESSAGES, DEVICE_LIST_KEY } from "../../constants";
import { sendMessage } from "../../utils/MessageUtils";

import "../../styles/Simulator.css";
Expand Down Expand Up @@ -77,7 +77,9 @@ class Simulator extends React.Component<{}, IState> {

handleMessage = (event: any): void => {
const message = event.data; // The JSON data our extension sent

if (message.active_device !== DEVICE_LIST_KEY.CPX) {
return;
}
switch (message.command) {
case "reset-state":
console.log("Clearing the state");
Expand Down Expand Up @@ -169,7 +171,7 @@ class Simulator extends React.Component<{}, IState> {
}

protected togglePlayClick() {
sendMessage("play-simulator", {
sendMessage(WEBVIEW_MESSAGES.TOGGLE_PLAY_STOP, {
selected_file: this.state.selected_file,
state: !this.state.play_button,
});
Expand Down
6 changes: 5 additions & 1 deletion src/view/components/microbit/MicrobitSimulator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import CONSTANTS, {
import {
WEBVIEW_MESSAGES,
MICROBIT_BUTTONS_KEYS,
DEVICE_LIST_KEY,
Expand Down Expand Up @@ -48,6 +48,10 @@ export class MicrobitSimulator extends React.Component<any, IState> {
handleMessage = (event: any): void => {
const message = event.data;

if (message.active_device !== DEVICE_LIST_KEY.MICROBIT) {
return;
}

switch (message.command) {
case "reset-state":
this.setState({
Expand Down
50 changes: 25 additions & 25 deletions vendor/node-usb-native/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"extends": [
"standard"
],
"plugins": [
"require-path-exists"
],
"env": {
"node": true,
"mocha": true
},
"rules": {
"arrow-parens": [2, "as-needed", {"requireForBlockBody": true }],
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
"object-curly-spacing": [2, "always"],
"prefer-arrow-callback": 2,
"prefer-const": 2,
"prefer-template": 2,
"require-path-exists/exists": 2,
"require-path-exists/notEmpty": 2,
"require-path-exists/tooManyArguments": 2,
"semi": [2, "always", {"omitLastInOneLineBlock": true}],
"space-before-function-paren": [2, "never"],
"standard/object-curly-even-spacing": 0
}
{
"extends": [
"standard"
],
"plugins": [
"require-path-exists"
],
"env": {
"node": true,
"mocha": true
},
"rules": {
"arrow-parens": [2, "as-needed", {"requireForBlockBody": true }],
"no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
"object-curly-spacing": [2, "always"],
"prefer-arrow-callback": 2,
"prefer-const": 2,
"prefer-template": 2,
"require-path-exists/exists": 2,
"require-path-exists/notEmpty": 2,
"require-path-exists/tooManyArguments": 2,
"semi": [2, "always", {"omitLastInOneLineBlock": true}],
"space-before-function-paren": [2, "never"],
"standard/object-curly-even-spacing": 0
}
}
28 changes: 14 additions & 14 deletions vendor/node-usb-native/.gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
$ cat .gitignore

# Can ignore specific files
.settings.xml
.monitor
.DS_Store

# Use wildcards as well
*~
#*.swp

# Can also ignore all directories and files in a directory.
node_modules/
build/
$ cat .gitignore

# Can ignore specific files
.settings.xml
.monitor
.DS_Store

# Use wildcards as well
*~
#*.swp

# Can also ignore all directories and files in a directory.
node_modules/
build/
4 changes: 2 additions & 2 deletions vendor/node-usb-native/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules/
build/
node_modules/
build/
8 changes: 4 additions & 4 deletions vendor/node-usb-native/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is a natvie package contains two modules: detector and serialport, detector provides the functionality of detecting usb changes and serialport provides the functionality of listing serial ports, openning serial ports and sending/receiving message to/from serial ports.

require("../../../vendor/node-usb-native").SerialPort;
require("../../../vendor/node-usb-native").detector;
This is a natvie package contains two modules: detector and serialport, detector provides the functionality of detecting usb changes and serialport provides the functionality of listing serial ports, openning serial ports and sending/receiving message to/from serial ports.

require("../../../vendor/node-usb-native").SerialPort;
require("../../../vendor/node-usb-native").detector;
126 changes: 63 additions & 63 deletions vendor/node-usb-native/binding.gyp
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
{
"targets": [
{
"target_name": "usb-native",
"sources": [
"src/detection.cpp",
"src/detection.h",
"src/deviceList.cpp",
"src/combined.cpp",
"src/serialport.cpp"
],
"include_dirs": [
"<!(node -e \"require('nan')\")"
],
"conditions": [
[
"OS=='win'",
{
"sources": [
"src/detection_win.cpp",
"src/serialport_win.cpp"
],
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": "2",
"DisableSpecificWarnings": [
"4530",
"4506"
]
}
},
"include_dirs+": []
}
],
[
"OS=='mac'",
{
"sources": [
"src/detection_mac.cpp",
"src/serialport_unix.cpp",
"src/serialport_poller.cpp"
],
"libraries": [
"-framework CoreFoundation -framework IOKit"
]
}
],
[
"OS=='linux'",
{
"sources": [
"src/detection_linux.cpp",
"src/serialport_unix.cpp",
"src/serialport_poller.cpp"
],
"defines": [
"DISABLE_USB_DETECTOR"
]
}
]
]
}
]
{
"targets": [
{
"target_name": "usb-native",
"sources": [
"src/detection.cpp",
"src/detection.h",
"src/deviceList.cpp",
"src/combined.cpp",
"src/serialport.cpp"
],
"include_dirs": [
"<!(node -e \"require('nan')\")"
],
"conditions": [
[
"OS=='win'",
{
"sources": [
"src/detection_win.cpp",
"src/serialport_win.cpp"
],
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": "2",
"DisableSpecificWarnings": [
"4530",
"4506"
]
}
},
"include_dirs+": []
}
],
[
"OS=='mac'",
{
"sources": [
"src/detection_mac.cpp",
"src/serialport_unix.cpp",
"src/serialport_poller.cpp"
],
"libraries": [
"-framework CoreFoundation -framework IOKit"
]
}
],
[
"OS=='linux'",
{
"sources": [
"src/detection_linux.cpp",
"src/serialport_unix.cpp",
"src/serialport_poller.cpp"
],
"defines": [
"DISABLE_USB_DETECTOR"
]
}
]
]
}
]
}
Loading

0 comments on commit 53b998f

Please sign in to comment.