示例#1
0
文件: serial.cpp 项目: zrafa/pselab
/**********************************************************************
 * 
 * Method:      SerialPort()
 *
 * Description: Default constructor for the serial port class.
 *
 * Notes:    
 *
 * Returns:     None defined.
 *
 **********************************************************************/
SerialPort::SerialPort(int            port,
                       unsigned long  baudRate,
                       unsigned int   txQueueSize,
                       unsigned int   rxQueueSize)
{
    //
    // Initialize the logical device.
    //
    switch (port)
    {
      case UART0:
        channel = 0;
        break;

      default:
        channel = -1;
        break;
    }

    //
    // Create input and output FIFO's.
    //
    pTxQueue = new CircBuf(txQueueSize);
    pRxQueue = new CircBuf(rxQueueSize);

    // 
    // Initialize the hardware device.
    // 
    scc.reset(channel);
    scc.init(channel, baudRate, pTxQueue, pRxQueue);

}   /* SerialPort() */
void solve() {
    int ans = 0;
    memset(match,-1,sizeof(match));
    for(int i = 1; i <= n; i++) {
        memset(mk,false,sizeof(mk));
        if(true == find(i))
            ans ++;
    }

    townboy.init(m);
    memset(to,-1,sizeof(to));
    for(int i = 1; i <= m; i++) {
        if(-1 == match[i])
            continue;
        to[match[i]] = i;
    }

    for(int i = 1; i <= n; i++) {
        int size = G[i].size();
        if(-1 == to[i]) {
            for(int f = 0; f < size; f++) {
                int v = G[i][f];
                for(int g = 1; g <= m; g++)
                    if(v != g)
                        townboy.add(g,v);
            }
        }
        else {
            int size = G[i].size();
            for(int f = 0 ; f < size; f++) {
                int v = G[i][f];
                if(v == to[i])
                    continue;
                townboy.add(to[i],v);
            }
        }
    }
    for(int i = 1; i <= m; i++) {
        if(-1 != match[i])
            continue;
        for(int f = 1; f <= m; f++) {
            if(i == f)
                continue;
            townboy.add(i,f);
        }
    }
    townboy.find_scc();
}