/** *Sends a message through Xbee API to a particular address *Address: XBee address to send data to *txData: data to send to desired XBee */ void sendMessage(long long xbeeAddr, char* txData){ //Calculate message length and checksum unsigned int messageLength=strlen(txData)+TX_FRAME_LENGTH_WO_TXDATA; volatile unsigned char checksum; checksum=getChecksum(TX_REQUEST,GET_FRAME_ID,&xbeeAddr,RESERVED_BYTES,MAX_BROADCAST_RAD,USE_TO_PARAM,txData); //Send Delimiter sendByte(START_DELIMITER); //Send message length sendInt(messageLength); //Send Frame type and GetFrameID sendByte(TX_REQUEST); sendByte(GET_FRAME_ID); //Send destination address sendXbeeAddr(&xbeeAddr); //Send the rest of Xbee header bytes sendInt(RESERVED_BYTES); sendByte(MAX_BROADCAST_RAD); sendByte(USE_TO_PARAM); //Send actual data sendByteArray(txData); //Send checksum sendByte(checksum); //Toggle an LED //P4OUT ^= BIT7; } //sendMessage()
byte set_pwm(byte osc, float ds, byte resol) // osc#, duty cycle, resolution { // Sets PWM on SQR1 / SQR2. The frequency is decided by the resolution in bits. byte res[1]; u16 ocxrs, ocx; if( (ds > 100) || (resol < 6) || (resol > 16) ) return INVARG; ocxrs = pow(2.0, resol); ocx = (u16)(0.01 * ds * ocxrs + 0.5); if(osc == 0) sendByte(SETPWM1); else sendByte(SETPWM2); sendInt(ocxrs-1); // ocxrs sendInt(ocx); //ocx *res = COMERR; sread(1, res); if(*res != 'D') { fprintf(stderr, "SETPWM error\n"); return *res; } return 0; }
byte capture2_hr(int ch1, int ch2, int ns, int tg, float* data) // Returns four vectors, T1, V1, T2, V2 , starting at pointer *data { byte res[MAXBUF]; u16 k, *ip = (u16*)res; sendByte(CAPTURE2_HR); sendByte(ch1); sendByte(ch2); sendInt(ns); sendInt(tg); sread(1, res); // response byte if(*res != 'D') return COMERR; sread(1, res); // Read & ingnore this byte, due to word alignment of uC k = sread(4*ns, res); // Read 2*2*ns data bytes, each data 2 bytes if(k != 4*ns) { fprintf(stderr, "CAPTURE:Expected %d bytes. Got %d only\n", 4*ns, k); return INVSIZE; } for(k=0; k < ns; ++k) // Fill the inter-leaved data as T1, V1, T2, V2 { data[k] = 0.001 * k * tg; // Fill T1, microseconds to milliseconds data[k + 2*ns] = 0.001 * k * tg + tgap; // Fill T2, with offset data[k + ns] = *ip++ * m12[ch1] + c[ch1]; // Fill V1 data[k + 3*ns] = *ip++ * m12[ch2] + c[ch2]; // Fill V2 } return 0; }
byte capture2(int ch1, int ch2, int ns, int tg, float* data) // Returns 4 vectors(of size 'ns'), T1, V1,T2,V2 starting at pointer *data { byte res[MAXBUF], *bp=res; u16 k; sendByte(CAPTURE2); sendByte(ch1); sendByte(ch2); sendInt(ns); sendInt(tg); *res = COMERR; // fill response with error, call should correct it. sread(1, res); // response byte if(*res != 'D') { fprintf(stderr,"Invalid argument list\n"); return *res; } sread(1, res); // Read & ingnore this byte, due to word alignment of uC k = sread(2*ns, res); // Read '2*ns' data bytes, comes inter leaved, like, a1, b1, a2, b2 ... if(k != 2*ns) { fprintf(stderr, "CAPTURE:Expected %d bytes. Got %d only\n", 2*ns, k); return INVSIZE; } for(k=0; k < ns; ++k) // Fill the inter-leaved data as T1, V1, T2, V2 { data[k] = 0.001 * k * tg; // Fill T1, microseconds to milliseconds data[k + 2*ns] = 0.001 * k * tg + tgap; // Fill T2, with offset data[k + ns] = *bp++ * m8[ch1] + c[ch1]; // Fill V1 data[k + 3*ns] = *bp++ * m8[ch2] + c[ch2]; // Fill V2 } return 0; }
//----------------------- Capture with 12 bit resolution, each item is 2byte in size ----------------- byte capture_hr(int ch, int ns, int tg, float* data) // Returns two vectors(of size 'ns'), T1, V1 starting at pointer *data { byte res[MAXBUF]; u16 k, *ip = (u16*)res; sendByte(CAPTURE_HR); sendByte(ch); sendInt(ns); sendInt(tg); sread(1, res); // response byte if(*res != 'D') return COMERR; sread(1, res); // Read & ingnore this byte, due to word alignment of uC k = sread(2*ns, res); // Read 2*ns data bytes if(k != 2*ns) { fprintf(stderr, "CAPTURE_HR:Expected %d bytes. Got %d only\n", 2*ns, k); return INVSIZE; } for(k=0; k < ns; ++k) *data++ = 0.001 * k * tg; // Fill Time, microseconds to milliseconds ip = (u16*)res; for(k=0; k < ns; ++k) *data++ = *ip++ * m12[ch] + c[ch]; // Fill voltage return 0; }
int sendWorkerDetails(int sock, struct workerNode *ptr){ //Send Worker Found if(sendInt(sock , 1) < 0){ puts("Send Query result Failed"); return -1; } puts("Worker present status sent"); //Send the IP and Port if(send(sock, ptr->ip, sizeof(int)*4, 0) < 0){ puts("Send IP Failed"); return -1; } puts("IP sent"); //Wait for ACK if(waitForAck(sock) < 0){ puts("ACK not received"); return -1; } //Send Port number if(sendInt(sock, ptr->port) < 0){ puts("Send Port Failed"); return -1; } puts("Port Sent"); return 1; }
void JVMLinkClient::setVar(const JVMLinkObject& obj) { sendInt(SETVAR_CMD); sendMessage(obj.name); sendInt((int) obj.type); if (obj.type == ARRAY_TYPE) { sendInt((int) obj.insideType); sendInt(obj.length); if (obj.insideType == STRING_TYPE) { std::string* s = (std::string*) obj.data; for (int i=0; i<obj.length; i++) { sendMessage(s[i]); } } else { int sent = 0; int total = obj.size * obj.length; char* buf = (char*) obj.data; while (sent < total) { sent += send(conn, buf + sent, total - sent, 0); } } } else { if (obj.type == STRING_TYPE) sendMessage(*(std::string*) obj.data); else send(conn, (char*) obj.data, obj.size, 0); } }
/*------------ capture functions (8bit data)-------------------- Accepts channel numbers (ch, ch2 etc), Number of samples "ns",and Time interval between two samples "tg". The return value consists of arrays of Time & Voltage, starting at location 'data'. The first 'ns' floats are the Time, followed by another 'ns' floats of voltage. This repeats for each channel captured. */ byte capture(int ch, int ns, int tg, float* data) // Returns 2 vectors(of size 'ns'), T1, V1 starting at pointer *data { byte res[MAXBUF], *bp=res; u16 k; // Arguments : channel number , number of samples and timegap. data out is Time (ns*float), Voltage(ns*float) if( (ch < 0) || (ch > 12) || (tg < 4) || (ns > 1800)) { fprintf(stderr,"ch= %d ns = %d tg = %d\n", ch, ns, tg); return INVARG; } sendByte(CAPTURE); sendByte(ch); sendInt(ns); sendInt(tg); *res = COMERR; // fill response with error, call should correct it. sread(1, res); // get response if(*res != 'D') { fprintf(stderr,"Invalid argument list\n"); return *res; } sread(1, res); // Read & ingnore this byte, due to word alignment of uC k = sread(ns, res); // Read 'ns' data bytes if(k != ns) { fprintf(stderr, "CAPTURE:Expected %d bytes. Got %d only\n", ns, k); return INVSIZE; } for(k=0; k < ns; ++k) *data++ = 0.001 * k * tg; // Fill Time, microseconds to milliseconds for(k=0; k < ns; ++k) *data++ = *bp++ * m8[ch] + c[ch]; // Fill voltage return 0; }
int informDirectoryServerMaybeAbsent(){ // Initialize variables int sock; struct sockaddr_in server; // Create socket sock = socket(AF_INET , SOCK_STREAM , 0); if (sock == -1) { puts("Could not create socket"); return -1; } puts("Socket created"); //Connect to Directory Register and get ip and port for service char iptemp[100]; hostname_to_ip(ServerDirectoryIP, iptemp); server.sin_addr.s_addr = inet_addr(iptemp); server.sin_family = AF_INET; server.sin_port = htons(ServerDirectoryPort); //Connect to Directory Service puts("Trying to connect to Directory Service"); int connected = 1; while(connected == 1){ connected = connect(sock , (struct sockaddr *)&server , sizeof(server)); } if(connected == 0){ //Connected to Directory Service puts("Connected"); }else{ puts("Server Directory Connection failed"); return -1; } //Let Directory know you are the client if(sendInt(sock, 0) < 0){ puts("Send connector type client failed"); close(sock); return -1; } // Tell the directory there is problem connecting to the server if(sendInt(sock, 0) < 1){ puts("Send connector type client failed"); close(sock); return -1; } //Close connection to Directory Service close(sock); return 1; }
byte set_sqrs(float freq, float diff, float *fset) // Freq in Hertz, phase difference in % of T { // Sets the output frequency of both SQR1 & SQR2. 'fset' returns actual value set. // The second argument is the phase difference between them in percentage. static float mtvals[4] = {0.125e-6, 8*0.125e-6, 64*0.125e-6, 256*0.125e-6}; // Possible Timer period values float per; byte k, res[1], TCKPS = 0; // TCKPS, TG & OCRS are uC registers u16 TG, OCRS = 0; if(freq == 0) // Disable both Square waves { set_sqr1(0, fset); set_sqr2(0, fset); return 0; } else if(freq < 0) // Disable both Square waves { set_sqr1(-1, fset); set_sqr2(-1, fset); return 0; } if( (diff < 0) || (diff >= 100.0) ) { fprintf(stderr,"Invalid phase difference\n"); return INVARG; } per = 1.0/freq; // period T requested for(k=0; k < 4; ++k) // Find the optimum scaling, OCR value if(per < mtvals[k]*50000) { TCKPS = k; OCRS = per/mtvals[k]; OCRS = (int)(OCRS+0.5); freq = 1./(mtvals[k]*OCRS); break; } if( (TCKPS < 4) && (OCRS == 0) ) { fprintf(stderr,"Invalid Freqency\n"); return INVARG; } TG = (int)(diff*OCRS/100.0 +0.5); if(TG == 0) TG = 1; // Need to examine this //print 'TCKPS ', TCKPS, 'ocrs ', OCRS, TG sendByte(SETSQRS); sendByte(TCKPS); // prescaling for timer sendInt(OCRS); // OCRS value sendInt(TG) ; // time difference *res = COMERR; sread(1, res); if(*res != 'D') return *res; *fset = freq; return 0; }
void informServerOfWorkerDeregister(){ //Send Lookup Request int ip[4]; int port; int socks; // Get a new server if(getServerFromDirectory(&ip[0], &port) < 0){ puts("No Server Found to let it know that worker has been deregistered"); return; }else{ puts("Server Found to let it know that worker has been deregistered"); } socks = connectToServer(ip, port); if(socks < 0){ puts("Worker Directory failed to connect to the server"); return; } printf("Connected to Server\n"); // Inform server that you are the worker directory if(sendInt(socks, 4) < 0){ puts("Send Connector type to server failed"); } // The reason of connecting if because some worker de registered, the server will start running rebuild now. close(socks); }
void AMDDaemonClient::closeConnection(){ if(soketidServer>=0){ sendInt(EXIT_CLIENT); close(soketidServer); soketidServer=-1; } }
byte measure_cv(int ch, int ctime, float i, float* v) // Using the CTMU of PIC, charges a capacitor connected to IN1, IN2 or SEN, for 'ctime' microseconds // and then mesures the voltage across it. // The value of current can be set to .55uA, 5.5 uA, 55uA or 550 uA { byte res[2], irange; int iv; if(i > 500) // 550 uA range irange = 0; else if(i > 50) // 55 uA irange = 3; else if(i > 5) // 5.5 uA irange = 2; else // 0.55 uA irange = 1; if( (ch != 3) && ( ch !=4) ) { fprintf(stderr, "Current to be set only on IN1 or IN2. %d\n",ch); return INVARG; } sendByte(MEASURECV); sendByte(ch); sendByte(irange); sendInt(ctime); *res = COMERR; sread(1, res); if (*res != 'D') return *res; if(sread(2,res) != 2) return COMERR; iv = res[0] | (res[1] << 8); *v = m12[ch] * iv + c[ch]; return 0; }
void onCommandRateLimit() { if (isChannelCorrect(gParameters[0])) { int channel = convertToInt(gParameters[0]); int rateLimit = convertToInt(gParameters[1]); if (isReadCommand(gParameters[1])) { sendInt(outputRateLimits[channel]); sendAck(); } else if (isIntWithinRange(rateLimit, OUTPUT_RATE_LIMIT_MIN, OUTPUT_RATE_LIMIT_MAX)) { outputRateLimits[channel] = rateLimit; sendAck(); } else { sendIntRangeError(OUTPUT_RATE_LIMIT_MIN, OUTPUT_RATE_LIMIT_MAX, DEGREES_UNIT); } } else { sendChannelError(); } }
void JVMLinkClient::sendMessage(const std::string& message) { int sent = 0; const char* buf = message.c_str(); int total = message.length(); sendInt(total); while (sent < total) sent += send(conn, buf + sent, total - sent, 0); }
void onCommandLoopInterval() { int loopInterval = convertToInt(gParameters[0]); if (isReadCommand(gParameters[0])) { sendInt(pidLoopInterval); sendAck(); } else if (isIntWithinRange(loopInterval, PID_INTERVAL_MS_MIN, PID_INTERVAL_MS_MAX)) { if (!isPidEnabled) { pidLoopInterval = loopInterval; sendAck(); } else { Serial.println(F("Cannot change loop interval while PID control is on.")); sendNack(); } } else { sendIntRangeError(PID_INTERVAL_MS_MIN, PID_INTERVAL_MS_MAX, MILLISECONDS_UNIT); } }
int sendAllWorkersToServer(int sock){ // Scan through the link list and send send one worker at a time struct workerNode *ptr = head; if(ptr == NULL){ if(sendInt(sock, 0) < 0){ puts("Sending no worker present status failed"); return -1; }else{ puts("No Worker Found In List"); return 1; } } while(ptr != NULL){ // Send worker IP, Convert IP to string char address[50]; sprintf(address, "%d.%d.%d.%d", ptr->ip[0], ptr->ip[1], ptr->ip[2], ptr->ip[3]); // Worker found, make sure it is still alive by pinging it if(workerStatus(address, ptr->port) < 0){ // Worker not present, de-register it and look for another one scanListWorkerDR(ptr->ip, ptr->port); }else{ if(sendWorkerDetails(sock, ptr) < 0){ puts("Failed to send worker details"); return -1; } } // Next Worker ptr = ptr->next; } // Inform the server, there are no more workers if(sendInt(sock, 0) < 0){ puts("Sending no worker present status failed"); return -1; } return 1; }
int connectToServer(int ip[], int port){ int sock; struct sockaddr_in server; //Convert ip to string char address[50]; sprintf(address, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); //Trim the char array printf("The address we have is %s \n",address); //Create socket sock = socket(AF_INET , SOCK_STREAM , 0); if (sock == -1) { puts("Could not create socket"); return -1; } puts("Socket created"); //Now setup Server connection server.sin_addr.s_addr = inet_addr(address); //server.sin_addr.s_addr = inet_addr("127.0.0.1"); server.sin_family = AF_INET; server.sin_port = htons(port); printf("Port it is trying to connect to is %d \n",port); //Connect to Remote Server puts("Trying to connect to Remote Server"); int connected = 1; while(connected == 1){ connected = connect(sock , (struct sockaddr *)&server , sizeof(server)); } if(connected == 0){ //Connected to Remote Server puts("Connected"); // Inform the server you are the client if(sendInt(sock, 1) < 0){ puts("Sending connector type to server failed"); return -1; } return sock; }else{ printf("Connection Failed : Return Value %d\n",connected); // Let the directory know that the server is not available informDirectoryServerMaybeAbsent(); return -1; } }
void JVMLinkClient::exec(const std::string& command) { debug("exec: " << command); sendInt(EXEC_CMD); sendMessage(command); int status = readInt(); if (status != 0) { std::string vMessage = *readString(); JVMException vJVMException(vMessage); throw vJVMException; } }
byte capture4(int ch1, int ch2, int ch3, int ch4, int ns, int tg, float* data) // Returns 8 vectors(of size 'ns'), T1, V1,T2,V2,T3,V3,T4,V4 starting at pointer *data { byte ch12, ch34, res[MAXBUF], *bp=res; u16 k; sendByte(CAPTURE4); ch12 = (ch2 << 4) | ch1; // ch1 & ch2 packed into one byte ch34 = (ch4 << 4) | ch3; // ch3 & ch4 packed into one byte sendByte(ch12); sendByte(ch34); sendInt(ns); sendInt(tg); *res = COMERR; // fill response with error, call should correct it. sread(1, res); // response byte if(*res != 'D') { fprintf(stderr,"Invalid argument list\n"); return *res; } sread(1, res); // Read & ingnore this byte, due to word alignment of uC k = sread(4*ns, res); // Read '2*ns' data bytes if(k != 4*ns) { fprintf(stderr, "CAPTURE:Expected %d bytes. Got %d only\n", 4*ns, k); return INVSIZE; } for(k=0; k < ns; ++k) // Fill the inter-leaved data as T1, V1, T2, V2 { data[k] = 0.001 * k * tg; // Fill T1, microseconds to milliseconds data[k + 2*ns] = 0.001 * k * tg + tgap; // Fill T2, with 1*offset data[k + 4*ns] = 0.001 * k * tg + 2*tgap; // Fill T3, with 2*offset data[k + 6*ns] = 0.001 * k * tg + 3*tgap; // Fill T4, with 3*offset data[k + ns] = *bp++ * m8[ch1] + c[ch1]; // Fill V1 data[k + 3*ns] = *bp++ * m8[ch2] + c[ch2]; // Fill V2 data[k + 5*ns] = *bp++ * m8[ch3] + c[ch3]; // Fill V3 data[k + 7*ns] = *bp++ * m8[ch4] + c[ch4]; // Fill V3 } return 0; }
byte write_dac(int iv) // Returns zero on success { byte res[1]; if(iv < 0) iv = 0; // Keep within limits else if (iv > 4095) iv = 4095; sendByte(SETDAC); sendInt(iv); *res = COMERR; // Assume an error sread(1, res); if(*res != 'D') return *res; return 0; }
byte set_pulsewidth(u16 width) { // Sets the 'pulse_width' parameter for pulse2rtime() command. // Also used by usound_time() and the elable_pulse_high/low() functions byte res[1]; if( (width < 1) || (width > 500) ) return INVARG; sendByte(SETPULWIDTH); sendInt(width); *res = COMERR; sread(1,res); if(*res != 'D') return *res; return 0; }
// This command is complex because it only allows setting of frequency for channel 1 // This is because only the tilt motor can be controlled by frequency void onCommandFrequencyOutput() { if (isChannelCorrect(gParameters[0])) { uint8_t channel = convertToInt(gParameters[0]); uint16_t frequency = convertToUint(gParameters[1]); if (channel == TILT_CHANNEL) { if (isReadCommand(gParameters[1])) { sendInt(currentFrequency); sendAck(); } else { if (!isSafetyOn) { if (isIntWithinRange(frequency, MOTOR_MIN_FREQUENCY, MOTOR_MAX_FREQUENCY)) { setFrequency(frequency); sendAck(); } else { sendIntRangeError(MOTOR_MIN_FREQUENCY, MOTOR_MAX_FREQUENCY, HERTZ_UNIT); } } else { Serial.println(F("Cannot change frequency output while safety is on.")); sendNack(); } } } else { Serial.println(F("Changing or reading of frequency only applies to channel 1")); sendNack(); } } else { sendChannelError(); } }
int workerStatus(char ip_addr[], int port){ int sock = -1; struct sockaddr_in server; //Create socket while(sock < 0) { sock = socket(AF_INET , SOCK_STREAM , 0); } puts("Socket created"); //Now setup Worker connection server.sin_addr.s_addr = inet_addr(ip_addr); server.sin_family = AF_INET; server.sin_port = htons(port); //Connect to Worker puts("Trying to connect to Worker"); int connected = 1; while(connected == 1){ connected = connect(sock , (struct sockaddr *)&server , sizeof(server)); } if(connected == 0){ //Connected to Worker puts("Connected"); // Inform the Worker it was a ping request if(sendInt(sock, 3) < 0){ puts("Ping request failed"); return -1; } // Connection verified, close it close(sock); return 1; }else{ // Worker is not available printf("Error when connecting! %s\n",strerror(errno)); puts("Failed to connect"); return -1; } }
//---------------- Square Wave Generation & Measuring the Frequency ------------------ byte set_osc(byte osc, float freq, float* fset) { // Sets the output frequency of the SQR1 (osc=0) or SQR2. The actual value set is returned in fset. static float mtvals[4] = {0.125e-6, 8*0.125e-6, 64*0.125e-6, 256*0.125e-6}; // Possible Timer period values float per; byte k, res[1], TCKPS = 0; // TCKPS & OCRS are uC registers u16 OCRS = 0; if(freq < 0) // Disable Timer and Set Output LOW TCKPS = 254; else if(freq == 0) // Disable Timer and Set Output HIGH TCKPS = 255; else // Set the frequency { per = 1.0/freq; // T requested for(k=0; k < 4; ++k) // Find the optimum scaling, OCR value if(per < mtvals[k]*50000) { TCKPS = k; OCRS = per/mtvals[k]; OCRS = (int)(OCRS+0.5); freq = 1.0/(mtvals[k]*OCRS); break; } if( (TCKPS < 4) && (OCRS == 0) ) return INVARG; if(osc == 0) sendByte(SETSQR1); else sendByte(SETSQR2); sendByte(TCKPS); // prescaling for timer sendInt(OCRS); // OCRS value *res = COMERR; sread(1, res); if(*res != 'D') return *res; *fset = freq; } return 0; }
JVMLinkObject* JVMLinkClient::getVar(const std::string& name) { debug("getVar: requesting " << name); JVMLinkObject* obj = new JVMLinkObject(name); sendInt(GETVAR_CMD); sendMessage(name); obj->type = (Type) readInt(); if (obj->type == ARRAY_TYPE) { obj->insideType = (Type) readInt(); obj->length = readInt(); if (obj->insideType == STRING_TYPE) { std::string* s = new std::string[obj->length]; for (int i=0; i<obj->length; i++) s[i] = *readString(); obj->data = s; } else { obj->size = readInt(); obj->data = readMessage(obj->size * obj->length); } debug("getVar: got array: length=" << obj->length << ", type=" << obj->insideType); } else if (obj->type == STRING_TYPE) { obj->data = readString(); obj->size = 0; debug("getVar: got string: length=" << len << ", value=" << buf); } else if (obj->type == NULL_TYPE) { obj->data = NULL; obj->size = 0; debug("getVar: got NULL value"); } else { int size = readInt(); obj->data = readMessage(size); obj->size = size; obj->insideType = NULL_TYPE; debug("getVar: got object: type=" << obj->type << ", size=" << obj->size); } return obj; }
void onCommandOutput() { if (isChannelCorrect(gParameters[0])) { int channel = convertToInt(gParameters[0]); int output = convertToInt(gParameters[1]); if (isReadCommand(gParameters[1])) { sendInt(currentOutputs[channel]); sendAck(); } else if (!isPidEnabled) { if (isIntWithinRange(output, PID_OUTPUT_MIN, PID_OUTPUT_MAX)) { const Direction direction = directions[channel]; applyMotorOutputs(channel, direction, output); sendAck(); } else { sendIntRangeError(PID_OUTPUT_MIN, PID_OUTPUT_MAX, PERCENTAGE_UNIT); } } else { Serial.println(F("Cannot change percentage output while PID control is on.")); sendNack(); } } else { sendChannelError(); } }
int runWorkerLookup(int sock){ //Look for the worker with least load //Find the worker and send the IP and Port to the tiny google server struct workerNode *ptr = lockerForWorkerLookup(); if(ptr == NULL){ //Send Worker not Found if(sendInt(sock, 0) < 0){ puts("Send Query result Failed"); return -1; } puts("No Worker Found"); return -1; }else{ //Convert ip to string char address[50]; sprintf(address, "%d.%d.%d.%d", ptr->ip[0], ptr->ip[1], ptr->ip[2], ptr->ip[3]); // Worker found, make sure it is still alive by pinging it if(workerStatus(address, ptr->port) < 0){ // Worker not present, deregister it and look for another one locker(1, ptr->ip, ptr->port, 0); runWorkerLookup(sock); } if(sendWorkerDetails(sock, ptr) < 0){ puts("Failed to send worker details"); return -1; } } //Successful puts("Server got Worker"); return 1; }
int config_setting::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: sendChar((*reinterpret_cast< QChar(*)>(_a[1]))); break; case 1: sendInt((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: on_cb_alarm_id_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: on_cb_alarm_volume_currentIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: update_now_string((*reinterpret_cast< QString(*)>(_a[1]))); break; case 5: on_pushButton_minus_released(); break; case 6: on_pushButton_minus_pressed(); break; case 7: on_pushButton_colon_released(); break; case 8: on_pushButton_colon_pressed(); break; case 9: on_pushButton_del_released(); break; case 10: on_pushButton_del_pressed(); break; case 11: on_pushButton_ac_released(); break; case 12: on_pushButton_ac_pressed(); break; case 13: on_pushButton_9_released(); break; case 14: on_pushButton_9_pressed(); break; case 15: on_pushButton_8_released(); break; case 16: on_pushButton_8_pressed(); break; case 17: on_pushButton_7_released(); break; case 18: on_pushButton_7_pressed(); break; case 19: on_pushButton_6_released(); break; case 20: on_pushButton_6_pressed(); break; case 21: on_pushButton_5_released(); break; case 22: on_pushButton_5_pressed(); break; case 23: on_pushButton_4_released(); break; case 24: on_pushButton_4_pressed(); break; case 25: on_pushButton_3_released(); break; case 26: on_pushButton_3_pressed(); break; case 27: on_pushButton_2_released(); break; case 28: on_pushButton_2_pressed(); break; case 29: on_pushButton_1_released(); break; case 30: on_pushButton_1_pressed(); break; case 31: on_pushButton_0_released(); break; case 32: on_pushButton_0_pressed(); break; case 33: on_pushButton_minus_clicked(); break; case 34: on_pushButton_colon_clicked(); break; case 35: on_pushButton_del_clicked(); break; case 36: on_pushButton_ac_clicked(); break; case 37: on_pushButton_9_clicked(); break; case 38: on_pushButton_8_clicked(); break; case 39: on_pushButton_7_clicked(); break; case 40: on_pushButton_6_clicked(); break; case 41: on_pushButton_5_clicked(); break; case 42: on_pushButton_4_clicked(); break; case 43: on_pushButton_3_clicked(); break; case 44: on_pushButton_2_clicked(); break; case 45: on_pushButton_1_clicked(); break; case 46: on_pushButton_0_clicked(); break; case 47: on_button_read_default_settings_clicked(); break; case 48: on_button_modify_settings_clicked(); break; case 49: on_button_return_clicked(); break; default: ; } _id -= 50; } return _id; }
void JVMLinkClient::shutJava() { debug("Terminating JVMLink server"); sendInt(EXIT_CMD); }