Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…troller into main
  • Loading branch information
heterodain committed Oct 24, 2021
2 parents c9ade84 + 15a8aca commit 59b9ec9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,30 @@ public synchronized void changeLoadSwith(PvController info, SerialConnection con
log.debug("Coil={}", res.getCoil());
}

/**
* データ
*/
@Getter
@Setter
@ToString
public static class RealtimeData {
public Double pvPower;
public Double battVolt;
public Double loadPower;
public Double battSOC;
public STAGE stage;

/** 発電電力(W) */
private Double pvPower;
/** バッテリー電圧(V) */
private Double battVolt;
/** 負荷電力(W) */
private Double loadPower;
/** バッテリー残量(%) */
private Double battSOC;
/** 充電ステージ */
private STAGE stage;

/**
* データの平均値取得
*
* @param datas データ
* @return 平均値
*/
public static RealtimeData summary(List<RealtimeData> datas) {
var summary = new RealtimeData();
summary.setPvPower(datas.stream().mapToDouble(RealtimeData::getPvPower).average().orElse(0D));
Expand All @@ -138,6 +152,9 @@ public static RealtimeData summary(List<RealtimeData> datas) {
}
}

/**
* 充電ステージ
*/
@AllArgsConstructor
@Getter
public static enum STAGE {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public boolean setRigPowerMode(Nicehash config, String time, POWER_MODE mode) th
}
}

/**
* 認証用リクエストヘッダ構築
*/
private Map<String, String> createAuthHeader(Nicehash config, String time, String method, URI uri, String body)
throws Exception {
var nonce = UUID.randomUUID().toString();
Expand Down Expand Up @@ -158,18 +161,30 @@ private Map<String, String> createAuthHeader(Nicehash config, String time, Strin
return headers;
}

/**
* パワーモード
*/
public static enum POWER_MODE {
UNKNOWN, MIXED, HIGH, MEDIUM, LOW;
}

/**
* リグのステータス
*/
public static enum MINER_STATUS {
BENCHMARKING, MINING, STOPPED, OFFLINE, ERROR, PENDING, DISABLED, TRANSFERRED, UNKNOWN;
}

/**
* GPUのステータス
*/
public static enum DEVICE_STATUS {
UNKNOWN, DISABLED, INACTIVE, MINING, BENCHMARKING, ERROR, PENDING, OFFLINE;
}

/**
* リグの情報
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public static class RigStatus {
Expand All @@ -180,6 +195,9 @@ public static class RigStatus {
private POWER_MODE rigPowerMode;
}

/**
* GPUの情報
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public static class Device {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void realtime() {
threeSecDatas.add(data);
}
} catch (Exception e) {
log.warn("PVコントローラーへのアクセスに失敗しました。", e);
log.error("PVコントローラーへのアクセスに失敗しました。", e);
}
}

Expand Down Expand Up @@ -243,7 +243,7 @@ public void powerControl() {
}

} catch (Exception e) {
log.warn("電源制御に失敗しました。", e);
log.error("電源制御に失敗しました。", e);
}
}

Expand Down Expand Up @@ -278,7 +278,7 @@ public void sendAmbient() throws Exception {

ambientService.send(serviceConfig.getAmbient(), ZonedDateTime.now(), sendDatas);
} catch (Exception e) {
log.warn("Ambientへのデータ送信に失敗しました。", e);
log.error("Ambientへのデータ送信に失敗しました。", e);
}
}

Expand Down Expand Up @@ -355,7 +355,7 @@ public void fanControl() {
log.info("冷却ファンを停止します。");
fanPowerSw.low();
} catch (Exception e) {
log.warn("ファン制御に失敗しました。", e);
log.error("ファン制御に失敗しました。", e);
}
}
}
Expand All @@ -377,10 +377,10 @@ public void destroy() {
initialized = false;
}

private GpioPinDigitalOutput initOutputGPIO(Pin pin, String name, PinState initial) {
private GpioPinDigitalOutput initOutputGPIO(Pin pin, String name, PinState initial) throws InterruptedException {
while (true) {
Thread.sleep(3000);
try {
Thread.sleep(3000);
var result = gpio.provisionDigitalOutputPin(pin, name, initial);
result.setShutdownOptions(true, initial);
return result;
Expand All @@ -391,10 +391,11 @@ private GpioPinDigitalOutput initOutputGPIO(Pin pin, String name, PinState initi
}
}

private GpioPinDigitalInput initInputGPIO(Pin pin, String name, PinPullResistance pull) {
private GpioPinDigitalInput initInputGPIO(Pin pin, String name, PinPullResistance pull)
throws InterruptedException {
while (true) {
Thread.sleep(3000);
try {
Thread.sleep(3000);
return gpio.provisionDigitalInputPin(pin, name, pull);
} catch (Exception e) {
log.warn("", e);
Expand Down

0 comments on commit 59b9ec9

Please sign in to comment.