asdf
This commit is contained in:
@@ -8,7 +8,7 @@ set(SOURCES
|
||||
output/OutputRequestHandlerFactory.cpp
|
||||
FlippRServer.cpp
|
||||
input/InputSocketHandlerFactory.cpp
|
||||
output/ItemVarHolder.h)
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSolenoid(const st
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("solenoids", this->output_driver->get_solenoids());
|
||||
response.set("solenoids", getItemArray(this->output_driver->get_solenoids()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseLamp(const std::s
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("lamps", this->output_driver->get_lamps());
|
||||
response.set("lamps", getItemArray(this->output_driver->get_lamps()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSound(const std::
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("sounds", this->output_driver->get_sounds());
|
||||
response.set("sounds", getItemArray(this->output_driver->get_sounds()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseFlipper(const std
|
||||
if(item_name == "")
|
||||
{
|
||||
Poco::JSON::Object response;
|
||||
response.set("flippers", this->output_driver->get_flippers());
|
||||
response.set("flippers", getItemArray(this->output_driver->get_flippers()) );
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -297,6 +297,19 @@ std::vector<std::string> OutputRequestHandler::getPathSegments(Poco::URI uri)
|
||||
return path_segments;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Poco::JSON::Array getItemArray(const std::vector<std::shared_ptr<T>> & items)
|
||||
{
|
||||
Poco::JSON::Array array;
|
||||
for ( auto & item : items )
|
||||
{
|
||||
Poco::JSON::Object var;
|
||||
var.set("name", item->get_name());
|
||||
array.add(var);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
Poco::JSON::Array getItemArray(const std::vector<std::shared_ptr<T>> & items);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
20
cli/main.py
20
cli/main.py
@@ -4,29 +4,29 @@ import argparse as ap
|
||||
from FlippR_Networking import Networking
|
||||
import keyboard
|
||||
|
||||
networking = "Not initialized"
|
||||
networking = Networking("/run/user/1000/S.flippR_driver.out", "/run/user/1000/S.flippR_driver.in")
|
||||
|
||||
def create_menu():
|
||||
menu = CursesMenu("FlippR")
|
||||
|
||||
solenoids = networking.getSolenoids()
|
||||
solenoids = networking.getSolenoids()["solenoids"]
|
||||
sol_menu = create_submenu("Solenoids", solenoids, networking.triggerSolenoid)
|
||||
sol_menu_item = SubmenuItem("Solenoids", sol_menu, menu)
|
||||
menu.append_item(sol_menu_item)
|
||||
|
||||
sounds = networking.getSounds()
|
||||
sounds = networking.getSounds()["sounds"]
|
||||
sound_menu = create_submenu("Sounds", sounds, networking.playSound)
|
||||
sound_menu_item = SubmenuItem("Sounds", sound_menu, menu)
|
||||
menu.append_item(sound_menu_item)
|
||||
|
||||
displays = networking.getDisplays()
|
||||
display_menu = create_displays_submenu(displays)
|
||||
display_menu_item = SubmenuItem("Displays", display_menu, menu)
|
||||
menu.append_item(display_menu_item)
|
||||
# displays = networking.getDisplays()
|
||||
# display_menu = create_displays_submenu(displays)
|
||||
# display_menu_item = SubmenuItem("Displays", display_menu, menu)
|
||||
# menu.append_item(display_menu_item)
|
||||
|
||||
lamps = networking.getLamps()
|
||||
lamps = networking.getLamps()["lamps"]
|
||||
lamp_menu = create_lamps_submenu(lamps)
|
||||
lamp_menu_item = SubmenuItem("Lamps", display_menu, menu)
|
||||
lamp_menu_item = SubmenuItem("Lamps", lamp_menu, menu)
|
||||
menu.append_item(lamp_menu_item)
|
||||
|
||||
input_item = FunctionItem("Print Input", print_input)
|
||||
@@ -85,7 +85,7 @@ def main():
|
||||
argparser.add_argument("input_socket", help="path to the input socket")
|
||||
args = argparser.parse_args()
|
||||
global networking
|
||||
networking = Networking(args.output_socket, args.input_socket)
|
||||
#networking = Networking(args.output_socket, args.input_socket)
|
||||
print(networking)
|
||||
create_menu()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user