Skip to content

Commit

Permalink
Host: MacOS Dummy Support (#2884)
Browse files Browse the repository at this point in the history
* Support for MacOS
  • Loading branch information
thomasjbhayes authored Nov 24, 2024
1 parent b6d542a commit d58c769
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public HostImpl() {
// Initialize correct Operating System handler
if (System.getProperty("os.name").startsWith("Windows")) {
this.operatingSystem = new OperatingSystemWindows();
} else if (System.getProperty("os.name").startsWith("Mac")) {
this.operatingSystem = new OperatingSystemMac();
} else {
this.operatingSystem = new OperatingSystemDebianSystemd(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package io.openems.edge.core.host;

import java.net.Inet4Address;
import java.util.Collections;
import java.util.List;
import java.util.TreeMap;
import java.util.concurrent.CompletableFuture;

import io.openems.common.exceptions.NotImplementedException;
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.common.jsonrpc.base.JsonrpcResponseSuccess;
import io.openems.edge.common.user.User;
import io.openems.edge.core.host.jsonrpc.ExecuteSystemCommandRequest;
import io.openems.edge.core.host.jsonrpc.ExecuteSystemCommandResponse;
import io.openems.edge.core.host.jsonrpc.ExecuteSystemRestartRequest;
import io.openems.edge.core.host.jsonrpc.SetNetworkConfigRequest;

public class OperatingSystemMac implements OperatingSystem {

@Override
public NetworkConfiguration getNetworkConfiguration() throws OpenemsNamedException {
return new NetworkConfiguration(new TreeMap<>());
}

@Override
public void handleSetNetworkConfigRequest(User user, NetworkConfiguration oldNetworkConfiguration,
SetNetworkConfigRequest request) throws OpenemsNamedException {
throw new NotImplementedException("SetNetworkConfigRequest is not implemented for Mac");

}

@Override
public String getUsbConfiguration() throws OpenemsNamedException {
// not implemented
return "";
}

@Override
public CompletableFuture<ExecuteSystemCommandResponse> handleExecuteSystemCommandRequest(
ExecuteSystemCommandRequest request) throws OpenemsNamedException {
throw new NotImplementedException("ExecuteSystemCommandRequest is not implemented for Mac");
}

@Override
public CompletableFuture<? extends JsonrpcResponseSuccess> handleExecuteSystemRestartRequest(
ExecuteSystemRestartRequest request) throws NotImplementedException {
throw new NotImplementedException("ExecuteSystemRestartRequest is not implemented for Mac");
}

@Override
public List<Inet4Address> getSystemIPs() throws OpenemsNamedException {
return Collections.emptyList();
}

@Override
public CompletableFuture<String> getOperatingSystemVersion() {
return CompletableFuture.completedFuture(System.getProperty("os.name"));
}

}

0 comments on commit d58c769

Please sign in to comment.