| | |
| | | memset(SensorConfig, 0, sizeof(SensorConfig)); |
| | | |
| | | memset(CarStatus, 0, sizeof(CarStatus)); |
| | | CarStatus[DOOR] = DOOR_CLOSE; |
| | | |
| | | memset(&Sensor, 0, sizeof(Sensor)); |
| | | |
| | |
| | | |
| | | void SetSensorCfg(int (*sensor)[3], int sensorNum) |
| | | { |
| | | DEBUG("加入传感器配置 sensorNum %d", sensorNum); |
| | | |
| | | pthread_mutex_lock(&sonser_mutex); |
| | | |
| | | SensorNum = sensorNum; |
| | | for (int i = 0; i < sensorNum; ++i) { |
| | | DEBUG(" 配置<%d>: id %d - fun %d - lvl %d", i, sensor[i][0], sensor[i][1], sensor[i][2]); |
| | | |
| | | SensorConfig[i].gpioId = sensor[i][0]; |
| | | SensorConfig[i].funId = sensor[i][1]; |
| | | if (sensor[i][2] > 0) { |
| | | SensorConfig[i].validLvl = 1; |
| | | } else { |
| | | SensorConfig[i].validLvl = 0; |
| | | } |
| | | |
| | | int level = 0; |
| | | |
| | | if (gpioStore & BV(SensorConfig[i].gpioId)) { |
| | | level = 1; |
| | | } |
| | | |
| | | if (level == SensorConfig[i].validLvl) { |
| | | SensorChanged(SensorConfig[i].funId, 1); |
| | | } else { |
| | | SensorChanged(SensorConfig[i].funId, 0); |
| | | } |
| | | } |
| | | |
| | | pthread_mutex_unlock(&sonser_mutex); |
| | | // DEBUG("加入传感器配置 sensorNum %d", sensorNum); |
| | | // |
| | | // pthread_mutex_lock(&sonser_mutex); |
| | | // |
| | | // SensorNum = sensorNum; |
| | | // for (int i = 0; i < sensorNum; ++i) { |
| | | // DEBUG(" 配置<%d>: id %d - fun %d - lvl %d", i, sensor[i][0], sensor[i][1], sensor[i][2]); |
| | | // |
| | | // SensorConfig[i].gpioId = sensor[i][0]; |
| | | // SensorConfig[i].funId = sensor[i][1]; |
| | | // if (sensor[i][2] > 0) { |
| | | // SensorConfig[i].validLvl = 1; |
| | | // } else { |
| | | // SensorConfig[i].validLvl = 0; |
| | | // } |
| | | // |
| | | // int level = 0; |
| | | // |
| | | // if (gpioStore & BV(SensorConfig[i].gpioId)) { |
| | | // level = 1; |
| | | // } |
| | | // |
| | | // if (level == SensorConfig[i].validLvl) { |
| | | // SensorChanged(SensorConfig[i].funId, 1); |
| | | // } else { |
| | | // SensorChanged(SensorConfig[i].funId, 0); |
| | | // } |
| | | // } |
| | | // |
| | | // pthread_mutex_unlock(&sonser_mutex); |
| | | } |
| | | |
| | | void UpdateSensor(uint16_t gpio, uint16_t speed, uint16_t rpm) |
| | |
| | | if (s->handBreak != Sensor.handBreak && s->handBreak != '#') { |
| | | SensorChanged(SENSOR_HANDBREAK, BX(s->handBreak)); |
| | | } |
| | | if (s->lock != Sensor.lock && s->lock != '#') { |
| | | SensorChanged(SENSOR_DOOR, BX(s->lock)); |
| | | if (s->door != Sensor.door && s->door != '#') { |
| | | SensorChanged(SENSOR_DOOR, BX(s->door)); |
| | | } |
| | | if (s->surround1 != Sensor.surround1 && s->surround1 != '#') { |
| | | SensorChanged(SENSOR_SURROUND_CAR_1, BX(s->surround1)); |