티스토리 뷰
BilientSevices/MeasurementSystem[BMS]
[BMS] Command Processor for Instrument
bizmaker 2020. 6. 11. 23:47void h_TreatSerial(){
if(!RxString_Serial.startsWith("VI")) 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);
String ValueString = RxString_Serial.substring(Index2+1);
int CommandValue = -1;
char Char1 = ValueString.charAt(0);
if((isDigit(Char1)) || (Char1 == '-')) CommandValue = (ValueString).toInt();
if(VICName.equals(String(DEVICENAME))){
StartTime_LastRequest = millis();
switch(CommandType0){
case 'D': // Data Request ?
{
if(!IsRegistered) return;
if(FixedChannel >= 0){
h_SendData(FixedChannel);
return;
}
switch(CommandType1){
case '?':
h_SendData(-1);
break;
case '0':
case '1':
case '2':
case '3':
h_SendData(int(CommandType1)-0x30);
break;
}
}
break;
case 'A':
if(CommandType1 == 'D'){
if(CommandValue == DeviceAddress) IsRegistered = true;
}
if(CommandType1 == 'N'){
DEVICENAME = ValueString;
}
break;
case 'C': // Clear ...
if(CommandType1 == 'P') h_InitializeDeviceParameters(CommandValue-1);
if(CommandType1 == 'V') h_InitializeDeviceValues(CommandValue-1);
if(CommandType1 == 'A') h_InitializeDeviceAddress();
if(CommandType1 == 'C') b_SetFixedChannel(CommandValue);
break;
case 'M': // Monitoring
{
int ChannelNo = atoi(CommandType1);
if(ChannelNo < 0) return;
if(ChannelNo >= CHANNELNUMBER) return;
if(CommandValue == 0) MeasuredValues[ChannelNo].IsMonitored = false;
if(CommandValue == 1) MeasuredValues[ChannelNo].IsMonitored = true;
}
break;
case 'P': // Port control
{
int PortNo = 0;
PortNo = (int)(String(CommandType1).toInt());
if(CommandValue == 1) digitalWrite(PortNo, HIGH);
if(CommandValue == 0) digitalWrite(PortNo, LOW);
}
break;
}
}else if(VICName.equals(String(COMMONDEVICENAME))){
switch(CommandType0){
case 'C': // Request initialization
if(CommandType1 == 'P') h_InitializeDeviceParameters(CommandValue-1);
if(CommandType1 == 'V') h_InitializeDeviceValues(CommandValue-1);
if(IsRegistered) break;
if(CommandType1 == 'A') h_InitializeDeviceAddress();
break;
case 'A': // Checking Address
if(CommandType1 == '?') h_ChecknResponse(CommandValue);
break;
}
}
}
반응형
'BilientSevices > MeasurementSystem[BMS]' 카테고리의 다른 글
[BMS] Command Process for Repeater (0) | 2020.06.12 |
---|---|
Data Display Test - Completed (0) | 2020.06.12 |
[BMS] Command Process for Actuator (0) | 2020.06.10 |
[BMS] Command Processor for WiFi Device (0) | 2020.06.10 |
[BMS] Display of Measured Data (0) | 2020.06.08 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 절연형
- 치매방지
- Innovation&Hurdles
- 전압전류모니터링
- badp
- 치매
- Innovations&Hurdles
- arduino
- 혁신과허들
- Video
- 심심풀이치매방지기
- DYOV
- bilient
- Hurdles
- 허들
- 심심풀이
- 둎
- image
- 배프
- 전압
- ServantClock
- Innovations
- BSC
- 혁신
- Decorator
- 티스토리챌린지
- 오블완
- 아두이노
- 빌리언트
- 전류
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함