System* MolecularFileDialog::readPDBFile(String filename, String system_name) { setStatusbarText((String)tr("reading PDB file..."), true); System* system = new System(); try { PDBFile pdb_file(filename); if(read_all_pdb_models_) { pdb_file.selectAllModels(); } pdb_file >> *system; pdb_file.close(); } catch(Exception::GeneralException& e) { Log.error() << e << std::endl; setStatusbarText((String)tr("Reading of PDB file failed, see logs!"), true); delete system; return 0; } if (!finish_(filename, system_name, system)) return 0; return system; }
int modentry(int boot, Module m, void *ptr) { switch (boot) { case 0: return setup_(m); break; case 1: return boot_(m); break; case 2: return cleanup_(m); break; case 3: return finish_(m); break; case 4: return features_(m, (char ***)ptr); break; case 5: return enables_(m, (int **)ptr); break; default: zerr("bad call to modentry"); return 1; break; } }
// ------------------------------------------------------------------------------------------------------ // Master Transmit - blocking routine with timeout, transmits Tx buffer to slave. i2c_stop parameter can be used // to indicate if command should end with a STOP(I2C_STOP) or not (I2C_NOSTOP). // return: 0=success, 1=data too long, 2=recv addr NACK, 3=recv data NACK, 4=other error // parameters: // i2c_stop = I2C_NOSTOP, I2C_STOP // timeout = timeout in microseconds // uint8_t i2c_t3::endTransmission(i2c_stop sendStop, uint32_t timeout) { sendTransmission_(i2c, sendStop); // wait for completion or timeout finish_(i2c, timeout); return getError(); }
// ------------------------------------------------------------------------------------------------------ // Master Receive - blocking routine with timeout, requests length bytes from slave at address. Receive data will // be placed in the Rx buffer. i2c_stop parameter can be used to indicate if command should end // with a STOP (I2C_STOP) or not (I2C_NOSTOP). // return: #bytes received = success, 0=fail (0 length request, NAK, timeout, or bus error) // parameters: // address = target 7bit slave address // length = number of bytes requested // i2c_stop = I2C_NOSTOP, I2C_STOP // timeout = timeout in microseconds // size_t i2c_t3::requestFrom_(struct i2cStruct* i2c, uint8_t addr, size_t len, i2c_stop sendStop, uint32_t timeout) { // exit immediately if request for 0 bytes if(len == 0) return 0; sendRequest_(i2c, addr, len, sendStop); // wait for completion or timeout if(finish_(i2c, timeout)) return i2c->rxBufferLength; else return 0; // NAK, timeout or bus error }
System* MolecularFileDialog::readHINFile(String filename, String system_name) { bool has_periodic_boundary = false; SimpleBox3 bounding_box; setStatusbarText((String)tr("reading HIN file..."), true); System* system = new System(); try { HINFile hin_file(filename); hin_file >> *system; has_periodic_boundary = hin_file.hasPeriodicBoundary(); bounding_box = hin_file.getPeriodicBoundary(); hin_file.close(); } catch(Exception::GeneralException& e) { Log.error() << e << std::endl; setStatusbarText((String)tr("Reading of HIN file failed, see logs!"), true); delete system; return 0; } // generating bounding box if exists if (has_periodic_boundary) { /* Box3* simple_box = new Box3; Vector3 first, second; bounding_box.get(first.x, first.y, first.z, second.x, second.y, second.z); Log.info() << "> creating bounding box (" << first << ", " << second << ")" << std::endl; simple_box->setVertex1(first); simple_box->setVertex2(second); simple_box->setColor("ff0000a0"); simple_box->setName("BoundingBox"); simple_box->setProperty(BALL::VIEW::GeometricObject::PROPERTY__OBJECT_TRANSPARENT); */ } if (!finish_(filename, system_name, system)) return 0; return system; }
System* MolecularFileDialog::readXYZFile(String filename, String system_name) { setStatusbarText((String)tr("reading XYZ file..."), true); System* system = new System(); try { XYZFile sd_file(filename); sd_file >> *system; sd_file.close(); } catch(Exception::GeneralException& e) { setStatusbarText((String)tr("Reading of XYZ file failed, see logs!"), true); delete system; return 0; } if (!finish_(filename, system_name, system)) return 0; return system; }
System* MolecularFileDialog::readMOL2File(String filename, String system_name) { setStatusbarText((String)tr("reading MOL2 file..."), true); System* system = new System(); try { MOL2File mol2_file(filename); mol2_file >> *system; mol2_file.close(); } catch(Exception::GeneralException& e) { setStatusbarText(tr("Reading of MOL2 file failed, see logs!"), true); Log.error() << e << std::endl; delete system; return 0; } if (!finish_(filename, system_name, system)) return 0; return system; }