Exemplo n.º 1
0
/* 本地设备监测API */
void local_device_update()
{
    UINT8 i, val;
    static UINT32 __last_entry_time = 0;
    /* 对暂停命令的处理 */
    if(__device_pause_second > 0 && local_time_diff_ms(__last_entry_time) >= 1000){
	__device_pause_second--;
	__last_entry_time = local_ms_get();
	DBG_PRINT("pause left %d seconds\n", __device_pause_second);
    }
    for(i=0; i<__local_ctrl_num; i++){
	switch(__local_ctrl[i].devType){
#ifdef INCLUDE_KTANK_LED
	  case KFISH_LED_LIGHT:
	    dualLedProcess(&__local_ctrl[0].ctrl.led, &__local_ctrl[1].ctrl.led);
	    break;
#endif
#ifdef INCLUDE_KTANK_SWITCH
	  case KFISH_SWITCH:
	    if(get_pause_value(i, &val) > 0){ /* 暂停状态,使用暂停的配置 */
		switch_set(i, val);
		__local_ctrl[i].ctrl.swi.isOn = val;
	    }else{
		switch_set(i, __local_ctrl[i].ctrl.swi.onoff[i]);
		__local_ctrl[i].ctrl.swi.isOn = __local_ctrl[i].ctrl.swi.onoff[i];
	    }
	    break;
#endif
	  default:
	    DBG_PRINT("err!!%d\n", __LINE__);
	    break;
	    
	}
    }
}
Exemplo n.º 2
0
void switch_server() {
    server_tid = MyTid();

    switches_init();

    // Find the location server.
    tid_t location_server_tid = -2;
    do {
        location_server_tid = WhoIs("LocationServer");
        dlog("Location Server Tid %d\n", location_server_tid);
    } while (location_server_tid < 0);

    tid_t tid;
    SwitchServerMessage msg, reply;
    while (1) {
        Receive(&tid, (char *) &msg, sizeof(msg));
        switch (msg.type) {
        case SET_SWITCH:
            reply.type = SET_SWITCH_RESPONSE;
            Reply(tid, (char *) &reply, sizeof(reply));
            switch_set(msg.switch_no, msg.direction, location_server_tid);
            break;
        default:
            break;
        }
    }
}
Exemplo n.º 3
0
void Cube::hundred(char face) {
    int* before;
    int after[8];
    std::string str = "|";

    before = switch_get(face);

    // corners
    after[0] = before[2];
    after[1] = before[3];
    after[2] = before[0];
    after[3] = before[1];

    // edges
    after[4] = before[6];
    after[5] = before[7];
    after[6] = before[4];
    after[7] = before[5];

    switch_set(face, after);

    last = str_to_last(face + str);
    delete[] before;
}
Exemplo n.º 4
0
void Cube::counter(char face) {
    int* before;
    int after[8];
    std::string str = "+";

    before = switch_get(face);

    // corners
    after[0] = rotate_cubie(before[1], face);
    after[1] = rotate_cubie(before[2], face);
    after[2] = rotate_cubie(before[3], face);
    after[3] = rotate_cubie(before[0], face);

    // edges
    after[4] = rotate_cubie(before[5], face);
    after[5] = rotate_cubie(before[6], face);
    after[6] = rotate_cubie(before[7], face);
    after[7] = rotate_cubie(before[4], face);

    switch_set(face, after);

    last = str_to_last(face + str);
    delete[] before;
}