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

Commit

Permalink
changed var name from state_copy to updated_state
Browse files Browse the repository at this point in the history
  • Loading branch information
andreamah committed Feb 10, 2020
1 parent afc1a5a commit 3611b56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def debug_show(state):
if state != previous_state:
previous_state = copy.deepcopy(state)

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

update_state(json.dumps(message))

Expand Down
18 changes: 9 additions & 9 deletions src/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@


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

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

return state_copy
return updated_state


def create_message(state_copy):
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

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

if state_copy != previous_state:
previous_state = copy.deepcopy(state_copy)
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

0 comments on commit 3611b56

Please sign in to comment.