bool Weather::callHandshake() { if (weatherConnection > 0) { if (getActiveConnection() == serialConnection) PortFD = serialConnection->getPortFD(); else if (getActiveConnection() == tcpConnection) PortFD = tcpConnection->getPortFD(); } return Handshake(); }
bool INDI::FilterWheel::callHandshake() { if (filterConnection > 0) { if (getActiveConnection() == serialConnection) PortFD = serialConnection->getPortFD(); else if (getActiveConnection() == tcpConnection) PortFD = tcpConnection->getPortFD(); } return Handshake(); }
/************************************************************************************ * * ***********************************************************************************/ bool FocusLynxF1::Disconnect() { // If we disconnect F1, the socket would be close. INDI::Focuser::Disconnect(); // Get value of PortFD, should be -1 if (getActiveConnection() == serialConnection) PortFD = serialConnection->getPortFD(); else if (getActiveConnection() == tcpConnection) PortFD = tcpConnection->getPortFD(); // Then we have to disconnect the second focuser F2 lynxDriveF2->RemoteDisconnect(); DEBUGF(INDI::Logger::DBG_SESSION, "Value of PortFD = %d", PortFD); return true; }
static void extractNodeASEvents(Node * node, Locus * locus) { Node *nodeA, *nodeB, *nodeC; Event *event; // If linear or more than 2 outgoing arcs: ignore if (countActiveConnections(node) != 2) return; // Follow the two active arcs nodeA = getTwinNode(getConnectionDestination (getActiveConnection(node))); nodeB = getTwinNode(getConnectionDestination (getSecondActiveConnection(node))); // A should be the longer of the two if (getNodeLength(nodeA) < getNodeLength(nodeB)) { nodeC = nodeA; nodeA = nodeB; nodeB = nodeC; nodeC = NULL; } // If both very short, ignore: if (getNodeLength(nodeA) < 2 * getWordLength(graph) - 1) return; if (getNodeLength(nodeB) < 2 * getWordLength(graph) - 1) { if (countActiveConnections(nodeA) != 1 || countActiveConnections(nodeB) != 1 || getConnectionDestination(getActiveConnection(nodeA)) != getConnectionDestination(getActiveConnection(nodeB))) return; nodeC = getTwinNode(getConnectionDestination (getActiveConnection(nodeA))); // Intron retention if (donorSiteAtJunction(node, nodeA) && acceptorSiteAtJunction(nodeA, nodeC)) { event = allocateEvent(); event->type = intron_retention; event->nodes[0] = node; event->nodes[1] = nodeA; event->nodes[2] = nodeB; event->nodes[3] = nodeC; event->next = locus->event; locus->event = event; } // Alternative 5' splice site else if (donorSiteAtJunction(node, nodeA)) { event = allocateEvent(); event->type = alternative_5prime_splice; event->nodes[0] = node; event->nodes[1] = nodeA; event->nodes[2] = nodeB; event->nodes[3] = nodeC; event->next = locus->event; locus->event = event; } // Alternative 3' splice site else if (acceptorSiteAtJunction(nodeA, nodeC)) { event = allocateEvent(); event->type = alternative_3prime_splice; event->nodes[0] = node; event->nodes[1] = nodeA; event->nodes[2] = nodeB; event->nodes[3] = nodeC; event->next = locus->event; locus->event = event; } // Skipped exon else { event = allocateEvent(); event->type = skipped_exon; event->nodes[0] = node; event->nodes[1] = nodeA; event->nodes[2] = nodeB; event->nodes[3] = nodeC; event->next = locus->event; locus->event = event; } } else { // Alt. poly A: if (finishesWithPAS(node) && finishesWithPAS(nodeA)) { event = allocateEvent(); event->type = alternative_polyA; event->nodes[0] = node; event->nodes[1] = nodeA; event->nodes[2] = nodeB; event->nodes[3] = NULL; event->next = locus->event; locus->event = event; } // Mutually exclusive exons if (countActiveConnections(nodeA) == 1 && countActiveConnections(nodeB) == 1 && getConnectionDestination(getActiveConnection(nodeA)) == getConnectionDestination(getActiveConnection(nodeB))) { event = allocateEvent(); event->type = mutually_exclusive_exons; event->nodes[0] = node; event->nodes[1] = nodeA; event->nodes[2] = nodeB; event->nodes[3] = getTwinNode(getConnectionDestination (getActiveConnection(nodeA))); event->next = locus->event; locus->event = event; } } }
bool MoonLiteDRO::Ack() { // For First Focuser, try to get the serial/tcp connection port FD if (m_ID == 1) { if (serialConnection == getActiveConnection()) PortFD = serialConnection->getPortFD(); else PortFD = tcpConnection->getPortFD(); } // For second focuser, try to get the port FD of the first focuser else if (m_ID == 2) { // We need to get Serial Port file descriptor from first focuser // Since we need to have only a SINGLE serial connection to the DRO and not two. PortFD = dro1->getPortFD(); if (PortFD == -1) { LOG_WARN("You must connect DRO Focuser #1 first before connecting to DRO Focuser #2."); return false; } // If we have a valid Port FD then we are good to go return true; } int nbytes_written = 0, nbytes_read = 0, rc = -1; char errstr[MAXRBUF]; char resp[5]={0}; short pos = -1; tcflush(PortFD, TCIOFLUSH); //Try to request the position of the focuser //Test for success on transmission and response //If either one fails, try again, up to 3 times, waiting 1 sec each time //If that fails, then return false. int numChecks = 0; bool success = false; while(numChecks < 3 && !success) { numChecks++; sleep(1); //wait 1 second between each test. bool transmissionSuccess = (rc = tty_write(PortFD, ":GP#", 4, &nbytes_written)) == TTY_OK; if(!transmissionSuccess) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Handshake Attempt %i, tty transmission error: %s.", numChecks, errstr); } bool responseSuccess = (rc = tty_read(PortFD, resp, 5, MOONLITEDRO_TIMEOUT, &nbytes_read)) == TTY_OK; if(!responseSuccess) { tty_error_msg(rc, errstr, MAXRBUF); LOGF_ERROR("Handshake Attempt %i, updatePosition response error: %s.", numChecks, errstr); } success = transmissionSuccess && responseSuccess; } if(!success) { LOG_INFO("Handshake failed after 3 attempts"); return false; } tcflush(PortFD, TCIOFLUSH); rc = sscanf(resp, "%hX#", &pos); return rc > 0; }