티스토리 뷰
BilientSevices/MeasurementSystem[BMS]
[BMS] Command Process for Actuator
bizmaker 2020. 6. 10. 23:46void h_TreatSerialCommand(){
if(!RxString_Serial.startsWith("CD")) return;
int Index1 = RxString_Serial.indexOf("/");
if(Index1 < 0) return;
int Index2 = RxString_Serial.indexOf(":");
if(Index1 >= Index2) return;
String VICName = RxString_Serial.substring(0, Index1);
char CommandType0 = RxString_Serial.charAt(Index1+1);
char CommandType1 = RxString_Serial.charAt(Index1+2);
int CommandValue = (RxString_Serial.substring(Index2+1)).toInt();
if(VICName.equals(String(DEVICENAME))){
StartTime_LastRequest = millis();
switch(CommandType0){
case 'P': // Port control
{
int PortValue = 0;
int PortNo = 0;
if(CommandType1 == 'R'){ // Port control for RELAY
PortNo = PIN_RELAY;
}else if(CommandType1 == 'O'){ // Port control for RELAY
PortNo = PIN_DIGITALOUT;
} else{
PortNo = (int)(String(CommandType1).toInt());
if(PortNo == 0) return;
}
if(CommandValue == 1) digitalWrite(PortNo, HIGH);
if(CommandValue == 0) digitalWrite(PortNo, LOW);
}
break;
case 'A':
if(CommandType1 == 'D'){
if(CommandValue == DeviceAddress) IsRegistered = true;
}
break;
case 'Q': // Request
if(CommandType1 == 'D') h_SendDeviceStatus();
break;
case 'C': // Command
if(CommandType1 == 'I') h_InitializeDeviceParameters(); // Initialize
if(CommandType1 == 'C') h_SetChargeCondition(CommandValue);
if(CommandType1 == 'D') h_SetDischargeCondition(CommandValue);
if(CommandType1 == 'A') AlarmTime_Minute = CommandValue; // Alarm
break;
}
}else if(VICName.equals(String(COMMONDEVICENAME))){
switch(CommandType0){
case 'C': // Request initialization
if(CommandType1 == 'P') h_InitializeDeviceParameters();
if(CommandType1 == 'A') h_InitializeDeviceAddress();
break;
case 'A': // Checking Address
if(CommandType1 == '?') h_ChecknResponse(CommandValue);
break;
}
}
}
반응형
'BilientSevices > MeasurementSystem[BMS]' 카테고리의 다른 글
Data Display Test - Completed (0) | 2020.06.12 |
---|---|
[BMS] Command Processor for Instrument (0) | 2020.06.11 |
[BMS] Command Processor for WiFi Device (0) | 2020.06.10 |
[BMS] Display of Measured Data (0) | 2020.06.08 |
[BMS] Images of Web Pages (2) | 2020.06.08 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Decorator
- 배프
- 치매방지
- 허들
- 아두이노
- 전류
- 혁신과허들
- bilient
- badp
- 티스토리챌린지
- 둎
- arduino
- ServantClock
- 혁신
- Hurdles
- DYOV
- BSC
- Innovations
- 전압전류모니터링
- 빌리언트
- image
- Video
- 심심풀이
- 절연형
- 전압
- Innovations&Hurdles
- 치매
- 오블완
- Innovation&Hurdles
- 심심풀이치매방지기
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함