int ParseChannel(channel_t* chan, channel_easy* chanE)
{
	
	memcpy(chanE->name, chan->name, 32);
	chanE->name[15] = '\0';

	chanE->bIsDigital = getType(chan);
/*
	chanE->TOT = getTOT(chan);
	chanE->EmergencyIndex = getEmergencyIndex(chan);
	chanE->GroupListIndex = getGroupListIndex(chan);
	chanE->ScanListIndex = getScanListIndex(chan);
	chanE->ContactIndex = getContactIndex(chan);
	chanE->AutoScan = getAutoScan(chan);
*/
	readFrequency(chan, &chanE->rxFreq, 1);
	readFrequency(chan, &chanE->txFreq, 0);

	if (chanE->bIsDigital) {
		chanE->CC = 0;
		chanE->Slot = 0;
		chanE->ContactIndex = 0;

		readTone(chan, &chanE->DecTone, FALSE);
		readTone(chan, &chanE->EncTone, TRUE);
	}
	else {
		chanE->CC = getCC(chan);
		chanE->Slot = getSlot(chan);
		sprintf(chanE->DecTone.text, "N/A");
		sprintf(chanE->EncTone.text, "N/A");
	}
	return 0;
}
float ramCommunicationManager::getCC(const string &name, int ccNum) const {
    int index = 0;
    for (int i = 0; i < Instruments.size(); i++) {
        if (name == Instruments[i]->getName())
            index = i;
    }

    return getCC(index,ccNum);
}
Example #3
0
// Function: dumpProcessorRegisters
// Description: This Function outputs the contents of the YESS 
//              processor registers to standard out.
// Params: none
// Returns: none
// Modifies: none
void dumpProcessorRegisters()
{
    fregister F = getFregister();
    dregister D = getDregister();
    eregister E = getEregister();
    mregister M = getMregister();
    wregister W = getWregister();

    printf("CC - ZF: %01x SF: %01x OF: %01x\n", getCC(ZF), getCC(SF), getCC(OF)); 
    printf("F - predPC: %08x\n", F.predPC);
    printf("D - stat: %01x icode: %01x ifun: %01x rA: %01x rB: %01x valC: %08x  valP: %08x\n",
            D.stat, D.icode, D.ifun, D.rA, D.rB, D.valC, D.valP);
    printf("E - stat: %01x icode: %01x  ifun: %01x  valC: %08x valA: %08x valB: %08x\n",
            E.stat, E.icode, E.ifun, E.valC, E.valA, E.valB);
    printf("    dstE: %01x dstM: %01x srcA: %01x srcB: %01x\n",
            E.dstE, E.dstM, E.srcA, E.srcB);
    printf("M - stat: %01x icode: %01x Cnd: %01x valE: %08x valA: %08x dstE: %01x dstM: %01x\n",
            M.stat, M.icode, M.Cnd, M.valE, M.valA, M.dstE, M.dstM);
    printf("W - stat: %01x icode: %01x valE: %08x valM: %08x dstE: %01x dstM: %01x\n\n",
            W.stat, W.icode, W.valE, W.valM, W.dstE, W.dstM);
}
Example #4
0
unsigned int getCnd()
{
  if (E.icode == ICMOVXX || E.icode == IJXX)
  {
    bool zero = getCC(ZF);
    bool sign = getCC(SF);
    bool overflow = getCC(OF);

    switch (E.ifun)
    {
      case F_LE:
        return ((zero || sign) && !overflow) ||
               (overflow && !sign);

      case F_L:
        return (sign && !(zero || overflow)) ||
               (overflow && !sign);

      case F_E:
        return zero;

      case F_NE:
        return !zero;

      case F_GE:
        return (!overflow && (zero || !sign)) ||
               (overflow && !zero && sign);

      case F_G:
        return (!overflow && !sign && !zero) ||
               (overflow && sign);

      case F_NO_CND:
        return 1;
    }
  }

  return 0;
}
Example #5
0
UBool Normalizer2DataBuilder::combinesWithCCBetween(const Norm &norm,
        uint8_t lowCC, uint8_t highCC) const {
    if((highCC-lowCC)>=2) {
        int32_t length;
        const CompositionPair *pairs=norm.getCompositionPairs(length);
        for(int32_t i=0; i<length; ++i) {
            uint8_t trailCC=getCC(pairs[i].trail);
            if(lowCC<trailCC && trailCC<highCC) {
                return TRUE;
            }
        }
    }
    return FALSE;
}
Example #6
0
int main(int argc, char *argv[])
{
	if (argc != 4) {
		printf("Usage: %s nx ny steps.\n", argv[0]);
		return 1;
	}
	int i;
	le_point2 n = {atoi(argv[1]), atoi(argv[2])};
	int steps = atoi(argv[3]);
	le_task task;
	le_material mat;
	le_vec2 h = {1.0, 1.0};
	real dt = 0.3;
	le_vec2 center = {n.x / 2, n.y / 2};
	char name[1000];
	
	
	double t;
	unsigned long cc;
	
	/*
	 * Init material.
	 */
	le_init_material(2.0, 1.0, 1.5, &mat);
	
	/*
	 * Init task.
	 */
	le_init_task(&task, dt, h, mat, n, ST_SOA);
	
	/*
	 * Initial condition.
	 */
	le_set_ball(&task, center, 10.0, 1.0);
	
	cc = getCC();
	t = timer();
	for (i = 0; i < steps; i++) {
		if (save_every_step) {
			sprintf(name, "out-%06d.vtk", i);
			le_save_task(&task, name);
		}
		le_step_sse(&task);
	}
	t = timer() - t;
	cc = getCC() - cc;
	/*printf("Total time, s:\t\t%f\n", t);
	printf("Time per step, s:\t%f\n", t / steps);*/
	printf("%d %d %d %f %ld\n", n.x, n.y, steps, t, cc);
	
	/*
	 * Save last step.
	 */
	le_save_task(&task, "result.vtk");
	
	/*
	 * Free memory.
	 */
	le_free_task(&task);
	return 0;
}
Example #7
0
//  Function: computeCND()
//  Description: just returns 0
//  Params: none
//  Returns: zero
//  Modifies: none
int computeCND()
{

    int e_CND = 0;
    int sf = getCC(SF);
    int zf = getCC(ZF);
    int of = getCC(OF);
   
    if(E.icode != RRMOVL && E.icode != JXX)
    {
        return 0;
    }
    if(E.ifun == 0)
       {
           e_CND = 1;
       }

     else if(E.ifun == 1)
       {
           if((sf ^ of) || zf)
               e_CND = 1;
       }
       
     else if(E.ifun == 2)
       {
           if(sf ^ of)
           {
               e_CND = 1;
           }
       }

       else if(E.ifun == 3)
       {
           if(zf)
           {
               e_CND = 1;
           }
       }

       else if(E.ifun == 4)
       {
           if(!zf)
           {
               e_CND = 1;
           }
       }

       else if(E.ifun == 5)
       {
           //if(!(sf^of) & !zf)
           if(!(sf^of) )
           {
               e_CND = 1;
           }
       }
       
       else if(E.ifun == 6)
       {
           if(!(sf^of) && !zf)
           {
               e_CND = 1;
           }
       }
       else
       {
           e_CND = 0;
       }
       
    return e_CND;
}
Example #8
0
UBool
Normalizer2DataBuilder::decompose(UChar32 start, UChar32 end, uint32_t value) {
    if(norms[value].hasMapping()) {
        Norm &norm=norms[value];
        const UnicodeString &m=*norm.mapping;
        UnicodeString *decomposed=NULL;
        const UChar *s=m.getBuffer();
        int32_t length=m.length();
        int32_t prev, i=0;
        UChar32 c;
        while(i<length) {
            prev=i;
            U16_NEXT(s, i, length, c);
            if(start<=c && c<=end) {
                fprintf(stderr,
                        "gennorm2 error: U+%04lX maps to itself directly or indirectly\n",
                        (long)c);
                exit(U_INVALID_FORMAT_ERROR);
            }
            const Norm &cNorm=getNormRef(c);
            if(cNorm.hasMapping()) {
                if(norm.mappingType==Norm::ROUND_TRIP) {
                    if(prev==0) {
                        if(cNorm.mappingType!=Norm::ROUND_TRIP) {
                            fprintf(stderr,
                                    "gennorm2 error: "
                                    "U+%04lX's round-trip mapping's starter "
                                    "U+%04lX one-way-decomposes, "
                                    "not possible in Unicode normalization\n",
                                    (long)start, (long)c);
                            exit(U_INVALID_FORMAT_ERROR);
                        }
                        uint8_t myTrailCC=getCC(m.char32At(i));
                        UChar32 cTrailChar=cNorm.mapping->char32At(cNorm.mapping->length()-1);
                        uint8_t cTrailCC=getCC(cTrailChar);
                        if(cTrailCC>myTrailCC) {
                            fprintf(stderr,
                                    "gennorm2 error: "
                                    "U+%04lX's round-trip mapping's starter "
                                    "U+%04lX decomposes and the "
                                    "inner/earlier tccc=%hu > outer/following tccc=%hu, "
                                    "not possible in Unicode normalization\n",
                                    (long)start, (long)c,
                                    (short)cTrailCC, (short)myTrailCC);
                            exit(U_INVALID_FORMAT_ERROR);
                        }
                    } else {
                        fprintf(stderr,
                                "gennorm2 error: "
                                "U+%04lX's round-trip mapping's non-starter "
                                "U+%04lX decomposes, "
                                "not possible in Unicode normalization\n",
                                (long)start, (long)c);
                        exit(U_INVALID_FORMAT_ERROR);
                    }
                }
                if(decomposed==NULL) {
                    decomposed=new UnicodeString(m, 0, prev);
                }
                decomposed->append(*cNorm.mapping);
            } else if(Hangul::isHangul(c)) {
                UChar buffer[3];
                int32_t hangulLength=Hangul::decompose(c, buffer);
                if(norm.mappingType==Norm::ROUND_TRIP && prev!=0) {
                    fprintf(stderr,
                            "gennorm2 error: "
                            "U+%04lX's round-trip mapping's non-starter "
                            "U+%04lX decomposes, "
                            "not possible in Unicode normalization\n",
                            (long)start, (long)c);
                    exit(U_INVALID_FORMAT_ERROR);
                }
                if(decomposed==NULL) {
                    decomposed=new UnicodeString(m, 0, prev);
                }
                decomposed->append(buffer, hangulLength);
            } else if(decomposed!=NULL) {
                decomposed->append(m, prev, i-prev);
            }
        }
        if(decomposed!=NULL) {
            if(norm.rawMapping==NULL) {
                // Remember the original mapping when decomposing recursively.
                norm.rawMapping=norm.mapping;
            } else {
                delete norm.mapping;
            }
            norm.mapping=decomposed;
            // Not  norm.setMappingCP();  because the original mapping
            // is most likely to be encodable as a delta.
            return TRUE;
        }
    }
    return FALSE;
}
Example #9
0
void
Normalizer2DataBuilder::addComposition(UChar32 start, UChar32 end, uint32_t value) {
    if(norms[value].mappingType==Norm::ROUND_TRIP) {
        if(start!=end) {
            fprintf(stderr,
                    "gennorm2 error: same round-trip mapping for "
                    "more than 1 code point U+%04lX..U+%04lX\n",
                    (long)start, (long)end);
            exit(U_INVALID_FORMAT_ERROR);
        }
        if(norms[value].cc!=0) {
            fprintf(stderr,
                    "gennorm2 error: "
                    "U+%04lX has a round-trip mapping and ccc!=0, "
                    "not possible in Unicode normalization\n",
                    (long)start);
            exit(U_INVALID_FORMAT_ERROR);
        }
        // setRoundTripMapping() ensured that there are exactly two code points.
        const UnicodeString &m=*norms[value].mapping;
        UChar32 lead=m.char32At(0);
        UChar32 trail=m.char32At(m.length()-1);
        if(getCC(lead)!=0) {
            fprintf(stderr,
                    "gennorm2 error: "
                    "U+%04lX's round-trip mapping's starter U+%04lX has ccc!=0, "
                    "not possible in Unicode normalization\n",
                    (long)start, (long)lead);
            exit(U_INVALID_FORMAT_ERROR);
        }
        // Flag for trailing character.
        createNorm(trail)->combinesBack=TRUE;
        // Insert (trail, composite) pair into compositions list for the lead character.
        IcuToolErrorCode errorCode("gennorm2/addComposition()");
        Norm *leadNorm=createNorm(lead);
        UVector32 *compositions=leadNorm->compositions;
        int32_t i;
        if(compositions==NULL) {
            compositions=leadNorm->compositions=new UVector32(errorCode);
            i=0;  // "insert" the first pair at index 0
        } else {
            // Insertion sort, and check for duplicate trail characters.
            int32_t length;
            const CompositionPair *pairs=leadNorm->getCompositionPairs(length);
            for(i=0; i<length; ++i) {
                if(trail==pairs[i].trail) {
                    fprintf(stderr,
                            "gennorm2 error: same round-trip mapping for "
                            "more than 1 code point (e.g., U+%04lX) to U+%04lX + U+%04lX\n",
                            (long)start, (long)lead, (long)trail);
                    exit(U_INVALID_FORMAT_ERROR);
                }
                if(trail<pairs[i].trail) {
                    break;
                }
            }
        }
        compositions->insertElementAt(trail, 2*i, errorCode);
        compositions->insertElementAt(start, 2*i+1, errorCode);
    }
}
Example #10
0
int main(int argc, char *argv[])
{
	if (argc != 5) {
		printf("Usage: %s nx ny steps threads.\n", argv[0]);
		return 1;
	}
	int i, ti;
	le_point2 n = {atoi(argv[1]), atoi(argv[2])};
	int steps = atoi(argv[3]);
	int max_threads = atoi(argv[4]);
	le_task task;
	le_material mat;
	le_vec2 h = {1.0, 1.0};
	real dt = 0.3;
	le_vec2 center = {n.x / 2, n.y / 2};
	char name[1000];

	double t;
	unsigned long cc;
	
	/* pthread variables */
	pthread_t threads[NUM_THREADS];
	st_pthread data[NUM_THREADS];
	pthread_attr_t attr;
	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
	/* end of pthread variables */

	le_init_material(2.0, 1.0, 1.5, &mat);
	task.max_threads = max_threads;
	task.steps = steps;
	le_init_task(&task, dt, h, mat, n);
	le_set_ball(&task, center, 10.0, 1.0);

	pthread_barrier_init(&b, NULL, max_threads);
	
	cc = getCC();
	t = timer();
	
	for(ti = 0; ti < max_threads; ti++) {		
		data[ti].task = &task;
		data[ti].thread_num = ti;
		int rc = pthread_create(&(threads[ti]), &attr, le_step, (void *)(&(data[ti])));
		assert(!rc);
	}
	for(ti = 0; ti < max_threads; ti++) {
		void *st;
		int rc = pthread_join(threads[ti], &st);
		assert(!rc);;
	}
	
	t = timer() - t;
	cc = getCC() - cc;
	
	pthread_barrier_destroy(&b);
	
	printf("%d %d %d %f ", n.x, n.y, steps, t);
	
	le_save_task(&task, "result.vtk");

	le_free_task(&task);
	pthread_exit(NULL);
}