void Battery::changed() { emit monitoring( tr( "%1 : Properties changed").arg( m_path ) ); int level = percentage(); if( level < lowLevel() ) { if( ! m_hasAlreadyBeenLow ) { m_hasAlreadyBeenLow = true; emit lowBattery(this); emit monitoring( tr( "%1 : Low" ).arg( m_path ) ); } } else { m_hasAlreadyBeenLow = false; } if( state() == FullyCharged ) { if( ! m_hasAlreadyBeenFull ) { m_hasAlreadyBeenFull = true; emit full(this); emit monitoring( tr( "%1 : Full" ).arg( m_path ) ); } } else { m_hasAlreadyBeenFull = false; } //m_view->refresh(); emit changed(this); }
int main(int argc, char** argv){ //This process plays the monitoring role //Reserved for the output file FILE* outputF; //First get the name of the output file from the command line if(argc > 1){ //Get the first argument to be the output file name outputFN = argv[1]; //Get the interval for checkpoints (if it was given) if(argc > 2){ //Check if the parameter is number if(sscanf(argv[2], "%d", &cpInterval) != 1){ perror("Error: The program expected on the 2nd argument only a number!.\n"); return -1; } } } else { perror("Error: The program expected on the 1st argument to specify the output file name, nothing was given!.\n"); return -1; } //Start monitoring monitoring(); }
static void tcpip_handler(void) { /* char *str; uip_ipaddr_t tadd; printf("In tcphandler\n"); if(uip_newdata()) { str = uip_appdata; str[uip_datalen()] = '\0'; printf("DATA recv '%s'\n", str); //uip_ip6addr(&tadd, 0xaaaa, 0, 0, 0, 0x0212, 0x7402, 0x0002, 0x0202); //uip_udp_packet_sendto(client_conn, "from client ", sizeof("from client "), &tadd, UIP_HTONS(12345)); } */ uint8_t *appdata=NULL,a;int code=0; if(uip_newdata()) { appdata = (uint8_t *) uip_appdata; MAPPER_GET_PACKETDATA(code,appdata); switch(code) { case 1://helping packet printf("Helper message \n"); help(appdata); break; case 2://adding neighbor info and ranks forward_packet(appdata); break; case 3://victim packet printf("I am Victim\n"); monitoring(appdata); break; case 4://monitoring node break; case 5://Selent packet //upade_info(appdata); break; case 7://Nbr info req snd_nbr_info(); break; case 8://nbr_info process if(!attacker_set) select_attacker(appdata); break; case 9://Wormhole deactive MAPPER_GET_PACKETDATA(code,appdata); if(code==2) {printf("Attacker 2\n");attack_flag=1;attacker=2;setreg(17,0);} if(code==3) {printf("Attacker 3\n");attack_flag=1;attacker=3;dis_output(NULL);setreg(17,0);} break; } } }