Skip to content

Commit

Permalink
set controller model on xScanner to xLights import
Browse files Browse the repository at this point in the history
  • Loading branch information
computergeek1507 committed Jun 18, 2023
1 parent 414c71e commit 394ee12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion xScanner/xScannerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ wxTreeListItem xScannerFrame::GetIPItem(const std::string& ip, bool create)
return wxTreeListItem();
}

wxString xScannerFrame::GetItemUnderParent(wxTreeListItem& parent, const std::string& label) const
{
for (auto a = _tree->GetFirstChild(parent); a.IsOk(); a = _tree->GetNextSibling(a)) {
if (_tree->GetItemText(a, 0) == label) {
return _tree->GetItemText(a, 1);
}
}
return wxString();
}

wxTreeListItem xScannerFrame::AddItemUnderParent(wxTreeListItem& parent, const std::string& label, const std::string& value)
{
// only add if there isnt something here already
Expand Down Expand Up @@ -792,7 +802,15 @@ void xScannerFrame::AddtoxLights(wxTreeListItem& item)
if (name.empty()) {
name = ip;
}
std::string const cmd = "{\"cmd\":\"addEthernetController\", \"ip\":\"" + ip + "\", \"name\":\"" + name + "\"}";

auto controllertype = GetItemUnderParent(item, "Vendor/Model/Variant");
auto typeList = wxSplit(controllertype, ':');
auto vendor = typeList.size() > 0 ? typeList[0] : wxString();
auto model = typeList.size() > 1 ? typeList[1] : wxString();
auto variant = typeList.size() > 3 ? typeList[2] : wxString();

std::string const cmd = "{\"cmd\":\"addEthernetController\", \"ip\":\"" + ip + "\", \"name\":\"" + name +
"\", \"vendor\":\"" + vendor + "\", \"model\":\"" + model + "\", \"variant\":\"" + variant + "\"}";
auto const stat = Automation(false, "127.0.0.1", 0, "", cmd, {}, "");
if (stat != 0) {
wxMessageBox("Unable to Add Controller to xLights.\nVerify xLights is Running and xFade Port A or B is set in File->Preferences->Output Tab", "Error", 5L, this);
Expand Down
1 change: 1 addition & 0 deletions xScanner/xScannerMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class xScannerFrame : public xlFrame
std::string GetIPSubnet(const std::string& ip);
wxTreeListItem GetSubnetItem(const std::string& subnet);
wxTreeListItem GetIPItem(const std::string& ip, bool create = true);
wxString GetItemUnderParent(wxTreeListItem& parent, const std::string& label) const;
wxTreeListItem AddItemUnderParent(wxTreeListItem& parent, const std::string& label, const std::string& value);
void AddItemUnderParentIfNotBlank(wxTreeListItem& item, const std::string& label, const std::string& value);
std::list<std::string> GetStartsWith(std::list<std::pair<std::string, std::string>>& res, const std::string& prefix);
Expand Down

0 comments on commit 394ee12

Please sign in to comment.