Source file: /~heha/hsn/UNI-T/dmm.zip/src/demo.cpp

#include "dmm.h"
#include <string.h>
#include <stdlib.h>
#include <math.h>

EXTERN_C void _cdecl _fltused(){};

static int myrand(int min, int max) {
 int a=max+1-min;
 int r=rand()%a;
 return r+min;
}

struct DEMO:INDATA{
 void _stdcall Handler();
};

void DEMO::Handler() {
 switch (msg) {
 
  case init:{
   baud=0;
   trto=250;
  }break;

  case tout:{
   READOUT ro[4];
   ZeroMemory(ro,sizeof(ro));
   static double arg;
   static DWORD features=(1<<F_DC)+(1<<F_AC)+63;
   for (int i=0; i<(int)lParam; i++) {
    ro[i].value=sin(arg)*10+myrand(-100,100)/100.0;	// 10V Sinus (Spitze), 1V Rauschen
    arg+=0.1;
    sprintf(ro[i].digits,lParam==2?"%+.3f":"%.3f",ro[i].value);	// Test auf "+"-Ausgabe
    ro[i].unitcode=i+1;	// Volt usw.
   }
   SetData(features&0xFFC0,ro,(int)lParam);
   --features;
   rlen=0;
   ok=true;
  }break;

 }
}

EXTERN_C bool WINAPI EnumAll(int n, ENUMINFO* ei) {
 if (++n>4) return false;
 strcpy(ei->ManufName,"h#s");
 sprintf(ei->ModelName,"Demo%d",n);
 ei->IconIndex=2;
 ei->ExtraAlloc=0;
 ei->pHandler=(void(_stdcall INDATA::*)())&DEMO::Handler;
 ei->lParam=n;	// number of readouts
 return true;
}
Detected encoding: UTF-80