Пример #1
0
  static void mdlOutputs(SimStruct *S, int_T tid)
  {
    int i, exttrig = 0;

    RTnetwork *nwsys = (RTnetwork*)ssGetUserData(S);
    nwsys->time = ssGetT(S);
    real_T* output_0 = ssGetOutputPortRealSignal(S,0);
    real_T* output_1 = ssGetOutputPortRealSignal(S,1);

    for (i=0; i < nwsys->nbrOfNodes; i++) {
      // mexPrintf("input %d: %f\n", i+1, input);
      if (fabs(nwsys->inputs[i]-nwsys->oldinputs[i]) > 0.1) {
	// mexPrintf("event at input %d\n", i);
	nwsys->oldinputs[i] = nwsys->inputs[i];
	exttrig = 1;
      }
    }
    
    if (exttrig == 1) {
      // Triggered on external events
      nwsys->nextHit = runNetwork(nwsys);
    } else {
      // Triggered on internal events
      if (nwsys->time >= nwsys->nextHit) {
	nwsys->nextHit = runNetwork(nwsys);
      }
    }

    for (i=0; i<nwsys->nbrOfNodes; i++) {
      output_0[i] = nwsys->outputs[i];
      output_1[i] = nwsys->sendschedule[i];
    }
  } 
Пример #2
0
int main( int argc, char ** argv) {
    Magick::InitializeMagick(*argv);
    readNetwork("base");
    int failed = 0, all = 0;
    for (int i = 1; i < argc; i++) {
        Magick::Image img(argv[i]);
        prepareImage(img);
        char res = runNetwork(img);
        char et = tolower(findChar(argv[i]));
        //printf("%c-%c\n", res, et);
        if (res != et) failed++;
        all++;
    }
    printf("%d/%d=%.2lf", failed, all, ((double)failed)/all);
}