//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool dynContact::read(ConnectionReader& connection){ // auto-convert text mode interaction connection.convertTextMode(); // represent a dynContact as a list of 4 elements that are: // - a list of 3 int, i.e. contactId, bodyPart, linkNumber // - a list of 3 double, i.e. the CoP // - a list of 3 double, i.e. the force // - a list of 3 double, i.e. the moment if(connection.expectInt()!= BOTTLE_TAG_LIST || connection.expectInt()!=4) return false; // - a list of 3 int, i.e. contactId, bodyPart, linkNumber if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_INT || connection.expectInt()!=3) return false; contactId = connection.expectInt(); bodyPart = (BodyPart)connection.expectInt(); linkNumber = connection.expectInt(); // - a list of 3 double, i.e. the CoP if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3) return false; for(int i=0;i<3;i++) CoP[i] = connection.expectDouble(); // - a list of 3 double, i.e. the force if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3) return false; for(int i=0;i<3;i++) F[i] = connection.expectDouble(); setForce(F); // - a list of 3 double, i.e. the moment if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3) return false; for(int i=0;i<3;i++) Mu[i] = connection.expectDouble(); return !connection.isError(); }
bool Stamp::read(ConnectionReader& connection) { connection.convertTextMode(); int header = connection.expectInt(); if (header!=BOTTLE_TAG_LIST) { return false; } int len = connection.expectInt(); if (len!=2) { return false; } int code; code = connection.expectInt(); if (code!=BOTTLE_TAG_INT) { return false; } sequenceNumber = connection.expectInt(); code = connection.expectInt(); if (code!=BOTTLE_TAG_DOUBLE) { return false; } timeStamp = connection.expectDouble(); if (connection.isError()) { sequenceNumber = -1; timeStamp = 0; return false; } return true; }