int NOKSUNG_Sensor::FrameMake(unsigned char cmd_flag, unsigned char order, unsigned char function1, unsigned char function2, unsigned char function3, unsigned char function4) { int result = 0; unsigned short crc = 0; if(cmd_flag == POLLING_CMD) { buf[0] = order; buf[1] = 0x03; buf[2] = 0x02; buf[3] = 0x80; buf[4] = 0x00; buf[5] = 0x01; buf[6] = 0x00; buf[7] = 0x00; crc = (NOKSUNG_UartRS485::Instance())->CRC_Make(buf, NOKSUNG_PROTOCOL_SEND_LENGTH - 2); buf[8] = ((unsigned char *)(&crc))[1]; buf[9] = ((unsigned char *)(&crc))[0]; result = FrameSend(buf); } //녹성 센서는 제어 command가 없다. if(cmd_flag == CONTROL_CMD) { } return result; }
int CMX_Gas::FrameMake(unsigned char cmd_flag, unsigned char order, unsigned char function1, unsigned char function2, unsigned char function3, unsigned char function4) { int result = 0; current_order = order; if(cmd_flag == POLLING_CMD) { buf[0] = GAS_STATUS_COMMAND; buf[1] = order; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; result = FrameSend(buf); } if(cmd_flag == CONTROL_CMD) { switch(function1) { case GAS_CLOSE: { buf[0] = GAS_CTRL_COMMAND; buf[1] = order; buf[2] = 0x80; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } default: break; } result = FrameSend(buf); } return result; }
int HAMUN_Curtain::FrameMake(unsigned char cmd_flag, unsigned char order, unsigned char function1, unsigned char function2, unsigned char function3, unsigned char function4) { int result = 0; if(cmd_flag == POLLING_CMD) { } if(cmd_flag == CONTROL_CMD) { switch(function1) { case CURTAIN_ACTION_EVENT: { buf[0] = CURTAIN_CTRL_COMMAND; buf[1] = 0x32; buf[2] = order + 0x30; if(function2 == CURTAIN_CLOSE) buf[3] = 0x01; else if(function2 == CURTAIN_OPEN) buf[3] = 0x02; else if(function2 == CURTAIN_STOP) buf[3] = 0x10; buf[4] = 0x00; buf[5] = 0x00; buf[6] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5]; } default: break; } result = FrameSend(buf); } return result; }
/** * FrameSchedulerData - scheduler operation to process all incoming data * frames. * * @return Status message from callee (currently not being used for frame * use). */ unsigned char FrameSchedulerData(void) { // Pass the payload (without frame header and footer) up to the next layer. if (gFrameScheduler.FrameComplete != NULL) { #if defined( PROTOCOL_GATEWAY ) bool dataRequest = (gFrameScheduler.frame.header.control & FRAME_CONTROL_DATA_REQ) >> 1; #endif unsigned char statusMessage = 0; gFrameScheduler.frame.header.control &= ~FRAME_CONTROL_DATA_REQ; #if defined( PROTOCOL_ENDPOINT ) statusMessage = gFrameScheduler.FrameComplete(gFrameScheduler.frame.payload, gFrameScheduler.length); #elif defined( PROTOCOL_GATEWAY ) statusMessage = gFrameScheduler.FrameComplete(dataRequest, gFrameScheduler.frame.payload, gFrameScheduler.length); #endif #if defined( PROTOCOL_GATEWAY ) // Send data back to the requesting node, if required. if (dataRequest && (gFrameScheduler.dataResponse.length > 0)) { // Send a data response. PhyEnable(); FrameSend(eFrameTypeData, dataRequest, gFrameScheduler.dataResponse.payload, gFrameScheduler.dataResponse.length); } #endif // Return user callback status message. return statusMessage; }
int CMX_Bundlelight::FrameMake(unsigned char cmd_flag, unsigned char order, unsigned char function1, unsigned char function2, unsigned char function3, unsigned char function4) { int result = 0; int gas_open = FALSE; D_Item gas1_item; D_Item gas2_item; enum DEVICE_PROTOCOL dProtocol; if(cmd_flag == POLLING_CMD) { //일괄소등 가스 밸브 상태 확인은 가스 밸브 1번 아이디만 확인 한다. buf[0] = BUNDLELIGHT_STATUS_COMMAND; buf[1] = order; if(get_device_index(GAS) != -1) { get_device_item(GAS, 1, &gas1_item); if(gas1_item.gasItem.action == GAS_OPEN) gas_open = TRUE; if(get_current_supported_cnt(GAS) > 1) { get_device_item(GAS, 2, &gas2_item); if(gas2_item.gasItem.action == GAS_OPEN) gas_open = TRUE; } if(gas_open == TRUE) buf[2] = 0x01; else buf[2] = 0x00; } else buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; result = FrameSend(buf); } if(cmd_flag == CONTROL_CMD) { //이전 현장에 설치된 제품과 제어 command 구분 필요 (function 기능이 없으면 이전 현장) if(bundlelightStatus[order - 1].supported_function._none == SUPPORTED) { buf[0] = OLD_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; switch(function1) { case BUNDLELIGHT_POWER_EVENT: { if(function2 == BUNDLELIGHT_POWER_ON) buf[2] = 0x01; else if(function2 == BUNDLELIGHT_POWER_OFF) buf[2] = 0x00; } break; default: break; } buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else { switch(function1) { case BUNDLELIGHT_POWER_EVENT: { if(function2 == BUNDLELIGHT_POWER_ON) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x01; buf[3] = 0x01; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function2 == BUNDLELIGHT_POWER_OFF) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; if(bundlelightStatus[order - 1].readyPower == BUNDLELIGHT_READYPOWER_ON) buf[2] = 0x02; else buf[2] = 0x00; buf[3] = 0x01; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function2 == BUNDLELIGHT_POWER_ALLON) { buf[0] = BUNDLELIGHT_GROUP_POWER_COMMAND; buf[1] = 0xFF; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function2 == BUNDLELIGHT_POWER_ALLOFF) { buf[0] = BUNDLELIGHT_GROUP_POWER_COMMAND; buf[1] = 0x00; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } } break; case BUNDLELIGHT_READYPOWER_EVENT: { if(function2 == BUNDLELIGHT_READYPOWER_ON) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x02; buf[3] = 0x02; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function2 == BUNDLELIGHT_READYPOWER_OFF) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; if(bundlelightStatus[order - 1].power == BUNDLELIGHT_POWER_ON) buf[2] = 0x01; else buf[2] = 0x00; buf[3] = 0x02; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function2 == BUNDLELIGHT_READYPOWER_ALLON) { buf[0] = BUNDLELIGHT_GROUP_READYPOWER_COMMAND; buf[1] = 0xFF; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function2 == BUNDLELIGHT_READYPOWER_ALLOFF) { buf[0] = BUNDLELIGHT_GROUP_READYPOWER_COMMAND; buf[1] = 0x00; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } } break; case BUNDLELIGHT_OUT_EVENT: { if(function2 == BUNDLELIGHT_OUT_REQUEST_SUCCESS) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x04; buf[3] = 0x03; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].out = BUNDLELIGHT_OUT_NONE; } else if(function2 == BUNDLELIGHT_OUT_REQUEST_FAIL) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x08; buf[3] = 0x04; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].out = BUNDLELIGHT_OUT_REQUEST_FAIL; } else if(function2 == BUNDLELIGHT_OUT_SET) { buf[0] = BUNDLELIGHT_OUTMODE_COMMAND; buf[1] = 0x00; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].out = BUNDLELIGHT_OUT_SET; } else if(function2 == BUNDLELIGHT_OUT_CANCEL) { buf[0] = BUNDLELIGHT_OUTMODE_COMMAND; buf[1] = 0x01; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].out = BUNDLELIGHT_OUT_CANCEL; } } break; case BUNDLELIGHT_GASCLOSE_EVENT: { if(function2 == BUNDLELIGHT_GASCLOSE_REQUEST_SUCCESS) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x10; buf[3] = 0x05; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].gasClose = BUNDLELIGHT_GASCLOSE_NONE; } else if(function2 == BUNDLELIGHT_GASCLOSE_REQUEST_FAIL) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x20; buf[3] = 0x06; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].gasClose = BUNDLELIGHT_GASCLOSE_REQUEST_FAIL; } } break; case BUNDLELIGHT_ELEVATORCALL_EVENT: { if(function2 == BUNDLELIGHT_ELEVATORCALL_REQUEST_SUCCESS) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x40; buf[3] = 0x07; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].elevatorCall = BUNDLELIGHT_ELEVATORCALL_NONE; } else if(function2 == BUNDLELIGHT_ELEVATORCALL_REQUEST_FAIL) { buf[0] = NEW_BUNDLELIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x80; buf[3] = 0x08; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; bundlelightStatus[order -1].elevatorCall = BUNDLELIGHT_ELEVATORCALL_REQUEST_FAIL; } } break; default: break; } } result = FrameSend(buf); } return result; }
int CMX_Light::FrameMake(unsigned char cmd_flag, unsigned char order, unsigned char function1, unsigned char function2, unsigned char function3, unsigned char function4) { int result = 0; if(cmd_flag == POLLING_CMD) { buf[0] = LIGHT_STATUS_COMMAND; buf[1] = order; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; result = FrameSend(buf); } if(cmd_flag == CONTROL_CMD) { switch(function1) { case LIGHT_MODE_BINARY: { if(function2 == LIGHT_POWER_EVENT) { if(function3 == LIGHT_POWER_ON) { buf[0] = LIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x01; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function3 == LIGHT_POWER_OFF) { buf[0] = LIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function3 == LIGHT_POWER_ALLON) { buf[0] = LIGHT_GROUP_CTRL_COMMAND; buf[1] = 0xFF; buf[2] = 0xFF; buf[3] = 0xFF; buf[4] = 0xFF; buf[5] = 0xFF; buf[6] = 0x08; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function3 == LIGHT_POWER_ALLOFF) { buf[0] = LIGHT_GROUP_CTRL_COMMAND; buf[1] = 0x00; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } } break; } case LIGHT_MODE_DIMMABLE: { if(function2 == LIGHT_POWER_EVENT) { if(function3 == LIGHT_POWER_ON) { buf[0] = LIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x01; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x08; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function3 == LIGHT_POWER_OFF) { buf[0] = LIGHT_CTRL_COMMAND; buf[1] = order; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function3 == LIGHT_POWER_ALLON) { buf[0] = LIGHT_GROUP_CTRL_COMMAND; buf[1] = 0xFF; buf[2] = 0xFF; buf[3] = 0xFF; buf[4] = 0xFF; buf[5] = 0xFF; buf[6] = 0x08; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } else if(function3 == LIGHT_POWER_ALLOFF) { buf[0] = LIGHT_GROUP_CTRL_COMMAND; buf[1] = 0x00; buf[2] = 0x00; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = 0x00; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } } else if(function2 == LIGHT_DIMMING_EVENT) { buf[0] = LIGHT_CTRL_COMMAND; buf[1] = order; if(function3 == 0x00) buf[2] = 0x00; else buf[2] = 0x01; buf[3] = 0x00; buf[4] = 0x00; buf[5] = 0x00; buf[6] = function3; buf[7] = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6]; } break; } default: break; } result = FrameSend(buf); } return result; }