Allow Cura front-end to set plugins (port & address)

This can currently be done by setting the environment variables:
- SIMPLIFY_ENABLE: default disabled, setting this to any value will enable the plugin
- SIMPLIFY_ADDRESS: defaults to localhost
- SIMPLIFY_PORT: defaults to 33700
- POSTPROCESS_ENABLE: default disabled, setting this to any value will enable the plugin
- POSTPROCESS_ADDRESS: defaults to localhost
- POSTPROCESS_PORT: defaults to 33701

Hacky for now

Contributes to CURA-10475
This commit is contained in:
Jelle Spijker 2023-05-19 13:33:05 +02:00
parent e3123e80ca
commit cccfebcc8e
No known key found for this signature in database
GPG Key ID: 034D1C0527888B65
2 changed files with 30 additions and 0 deletions

View File

@ -8,12 +8,25 @@ message ObjectList
repeated Setting settings = 2; // meshgroup settings (for one-at-a-time printing)
}
enum SlotID {
SIMPLIFY = 0;
POSTPROCESS = 1;
}
message EnginePlugin
{
SlotID id = 1;
optional string address = 2;
optional uint32 port = 3;
}
message Slice
{
repeated ObjectList object_lists = 1; // The meshgroups to be printed one after another
SettingList global_settings = 2; // The global settings used for the whole print job
repeated Extruder extruders = 3; // The settings sent to each extruder object
repeated SettingExtruder limit_to_extruder = 4; // From which stack the setting would inherit if not defined per object
repeated EnginePlugin engine_plugins = 5;
}
message Extruder

View File

@ -1,5 +1,6 @@
# Copyright (c) 2021-2022 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import os
import numpy
from string import Formatter
@ -301,6 +302,22 @@ class StartSliceJob(Job):
for extruder_stack in global_stack.extruderList:
self._buildExtruderMessage(extruder_stack)
# EnginePlugins
# TODO: don't hardcode them
# Ports: are chosen based on https://stackoverflow.com/questions/10476987/best-tcp-port-number-range-for-internal-applications
plugins = {
0: {"address": os.environ.get("SIMPLIFY_ADDRESS", "localhost"), "port": os.environ.get("SIMPLIFY_PORT", 33700)} if os.environ.get("SIMPLIFY_ENABLE") is not None else None,
1: {"address": os.environ.get("POSTPROCESS_ADDRESS", "localhost"), "port": os.environ.get("POSTPROCESS_PORT", 33701)} if os.environ.get("POSTPROCESS_ENABLE") is not None else None,
}
for plugin, connection in plugins.items():
plugin_message = self._slice_message.addRepeatedMessage("engine_plugins")
plugin_message.id = plugin
if connection:
plugin_message.address = connection["address"]
plugin_message.port = connection["port"]
for group in filtered_object_groups:
group_message = self._slice_message.addRepeatedMessage("object_lists")
parent = group[0].getParent()