Skip to content

Commit

Permalink
Bug fix, enable force stop from command center, update controller ser…
Browse files Browse the repository at this point in the history
…ver config
  • Loading branch information
Chalkman071 authored and tom1484 committed Mar 22, 2024
1 parent f20d735 commit 9e33df8
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 45 deletions.
57 changes: 21 additions & 36 deletions controller-server/configs/dancerTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,38 +242,38 @@ const dancerTable: DancerData = {
// connected: false,
// interface: "wifi",
// },
// "B8:27:EB:BB:57:AD": { // 15
// IP: "192.168.0.0",
// MAC: "B8:27:EB:BB:57:AD",
// dancer: "15_nian_1",
// hostname: "lightdance-15",
// connected: false,
// interface: "ethernet",
// },
// "B8:27:EB:EE:02:F8": { // 15
// IP: "192.168.0.0",
// MAC: "B8:27:EB:EE:02:F8",
// dancer: "15_nian_1",
// hostname: "lightdance-15",
// connected: false,
// interface: "wifi",
// },
"B8:27:EB:3A:21:4F": { // 16
"B8:27:EB:82:79:49": { // 15
IP: "192.168.0.0",
MAC: "B8:27:EB:3A:21:4F",
MAC: "B8:27:EB:82:79:49",
dancer: "15_nian_1",
hostname: "lightdance-15",
connected: false,
interface: "ethernet",
},
"B8:27:EB:6F:74:1A": { // 16
"B8:27:EB:D7:2C:1C": { // 15
IP: "192.168.0.0",
MAC: "B8:27:EB:6F:74:1A",
MAC: "B8:27:EB:D7:2C:1C",
dancer: "15_nian_1",
hostname: "lightdance-15",
connected: false,
interface: "wifi",
},
"B8:27:EB:3A:21:4F": { // 16
IP: "192.168.0.0",
MAC: "B8:27:EB:3A:21:4F",
dancer: "16_nian_2",
hostname: "lightdance-16",
connected: false,
interface: "ethernet",
},
"B8:27:EB:6F:74:1A": { // 16
IP: "192.168.0.0",
MAC: "B8:27:EB:6F:74:1A",
dancer: "16_nian_2",
hostname: "lightdance-16",
connected: false,
interface: "wifi",
},
"D8:3A:DD:22:AC:AA": { // 17
IP: "192.168.0.0",
MAC: "D8:3A:DD:22:AC:AA",
Expand Down Expand Up @@ -341,22 +341,7 @@ const dancerTable: DancerData = {
},
// 22 replaced
// 23 broken
"B8:27:EB:82:79:49": { // 24
IP: "192.168.0.0",
MAC: "B8:27:EB:82:79:49",
dancer: "24",
hostname: "lightdance-24",
connected: false,
interface: "ethernet",
},
"B8:27:EB:D7:2C:1C": { // 24
IP: "192.168.0.0",
MAC: "B8:27:EB:D7:2C:1C",
dancer: "24",
hostname: "lightdance-24",
connected: false,
interface: "wifi",
}
// 24 replaced
};

export const dancerToMAC: Record<
Expand Down
5 changes: 2 additions & 3 deletions controller-server/configs/pinMapTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,10 @@ const pinMapTable: PinMapTable = {
belly: 35,
},
LEDPARTS: {
backfoot_right_LED: { id: 0, len: 57 },
backfoot_left_LED: { id: 3, len: 30 },
backfoot_right_LED: { id: 0, len: 120 },
backfoot_left_LED: { id: 3, len: 70 },
back_LED: { id: 4, len: 76 },
tail_LED: { id: 5, len: 119 },
slash_LED: { id: 6, len: 40 },
},
LEDPARTS_MERGE: {},
},
Expand Down
7 changes: 7 additions & 0 deletions controller-server/websocket/controlPanel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ export async function handleOnControlPanelMessage(
handleSync(msg);
break;
case "play":
if (music_subprocess?.pid && !music_subprocess.killed) {
console.log(music_subprocess.pid+1);
try {
process.kill(music_subprocess.pid+1, 'SIGHUP')
} catch {}
console.log("killed music");
}
music_subprocess = handlePlay(msg);
break;
case "pause":
Expand Down
37 changes: 37 additions & 0 deletions editor-blender/operators/command_center/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,42 @@ async def async_execute(self, context: bpy.types.Context):
return {"FINISHED"}


class CommandCenterForceStopOperator(AsyncOperator):
bl_idname = "lightdance.command_center_force_stop"
bl_label = "Force stop"

@classmethod
def poll(cls, context: bpy.types.Context):
return True

async def async_execute(self, context: bpy.types.Context):
try:
stop_payload = ToControllerServerStopPartial.from_dict(
{"topic": "stop", "payload": {"dancers": get_selected_dancer()}}
)

await command_agent.send_to_controller_server(stop_payload)
bpy.context.scene.frame_current = 0

sync_payload = ToControllerServerWebShellPartial.from_dict(
{
"topic": "webShell",
"payload": {
"dancers": get_selected_dancer(),
"command": f"sudo systemctl restart player.service",
},
}
)

await command_agent.send_to_controller_server(sync_payload)

except Exception as e:
traceback.print_exc()

raise Exception(f"Can't send message to controller server: {e}")
return {"FINISHED"}


ops_list = [
CommandCenterRefreshOperator,
CommandCenterCloseGPIOOperator,
Expand All @@ -449,6 +485,7 @@ async def async_execute(self, context: bpy.types.Context):
CommandCenterTestOperator,
CommandCenterUploadOperator,
CommandCenterWebShellOperator,
CommandCenterForceStopOperator,
]


Expand Down
1 change: 1 addition & 0 deletions editor-blender/panels/command_center/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def draw(self, context: bpy.types.Context):
row.operator("lightdance.command_center_stop", text="", icon="SNAP_FACE")
op = row.operator("screen.frame_jump", text="", icon="REW")
setattr(op, "end", False)
row.operator("lightdance.command_center_force_stop", icon="CANCEL")
column = split.column()
row = column.row()
row.prop(
Expand Down
8 changes: 2 additions & 6 deletions editor-server/src/routes/api/get_dancer_led_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,11 @@ fn filter_identical_frames(statuses: Vec<Status>) -> Vec<Status> {

// Remove executive identical frames
let mut keep_frame = vec![true; statuses.len()];
for (i, (identical, fade)) in identical_and_fade.iter().enumerate() {
if !identical && *fade {
continue;
}

for (i, (identical, _fade)) in identical_and_fade.iter().enumerate() {
// Must keep if previous frame is not the same
if i > 0 {
let prev = identical_and_fade[i - 1];
if !prev.0 || (!identical && prev.1) {
if !prev.0 || !identical {
continue;
}
} else {
Expand Down

0 comments on commit 9e33df8

Please sign in to comment.