bool PtidesPlatformDirector_TransferOutputs1(struct PtidesPlatformDirector* director, struct PtidesPort* port) { bool result = false; #ifdef _debugging fprintf(stderr, "%s:%d: PtidesPlatformDirector_TransferOutputs(%p) %s start\n", __FILE__, __LINE__, director, ((struct Director *) director)->getFullName((struct Director *)director)); #endif for (int i = 0; i < port->getWidthInside(port); i++) { while (port->hasTokenInside(port, i)) { Token* t = port->getInside(port, i); struct PtidesPort* associatedPort = port->_associatedPort; if (associatedPort->isNetworkTransmitterPort(associatedPort)) { struct PtidesDirector* ptidesDirector = (struct PtidesDirector*) associatedPort->container->getDirector(associatedPort->container); Time timestamps[2]; associatedPort->_getTimeStampForToken(associatedPort, t, timestamps); Time timestamp = timestamps[0]; //Time sourceTimestamp = timestamps[1]; Token* record = Record_new(timestamp, ptidesDirector->getMicrostep(ptidesDirector), t); port->send(port, i, record); } else { port->send(port, i, t); } } result = true; } #ifdef _debugging fprintf(stderr, "%s:%d: PtidesPlatformDirector_TransferOutputs(%p) %s end\n", __FILE__, __LINE__, director, ((struct Director *) director)->getFullName((struct Director *)director)); #endif return result; }
Record *parse_line(char *line, const RecordDef *def, int def_idx) { char *tok; int col_idx = 0; char **values = calloc(def->size, sizeof(char *)); check_mem(values); for (tok = strtok(line, ","); tok && *tok; tok = strtok(NULL, ",\n")) { values[col_idx] = strdup(tok); col_idx += 1; } return Record_new(def_idx, values, def->size); error: if (values) free(values); return NULL; }