Exemplo n.º 1
0
void Pattern::paternComp(OSCMessage *_mes){
    for (uint8_t i=0 ; i<patternNum ; i++) {
		String str_addr = String(addr[i]);
		if(str_addr.endsWith("^")) {
			String to_match = str_addr.substring(0, str_addr.length() - 1);
			if(String(_mes->_oscAddress).startsWith(to_match)){
				_mes->parseAddressArgs(addr[i]);					
				execFunc(i, _mes);  
			} 
		}
        else if ( strcmp( addr[i] , _mes->_oscAddress ) == 0 ) execFunc( i , _mes );
	}
}
Exemplo n.º 2
0
int eventCanvas(XEvent ev){
  int i,j;
  int selected=getSelectedNumber();//現在選択されているレイヤー
  int back_num;
  switch(ev.type){
  case ButtonPress:
    //左クリックの時
    if( ev.xbutton.button == 1 ){
      // キャンバス上
      if ( ev.xany.window == canvas ){
	if(layer[selected].writable!=0){//書き込み設定の確認
	  execFunc(ev,layer,selected);//描画関数の実行
	}
	return(0);
      }
      for(i=0;i<layer_num;i++){	  
	// レイヤー上  
	if ( ev.xany.window == layer[i].win ){
	  if(layer[selected].writable!=0){//書き込み設定の確認
	    execFunc(ev,layer,selected);//描画関数の実行
	  }
	  return(0);
	}
      }
    }
    // ホイールクリックの時
    if( ev.xbutton.button == 2 ){
      back_num = backHistory(layer); // 元に戻る
      return(0);
    }
    
    break;
    
  case Expose:
    if ( ev.xany.window == canvas ){
      remapCanvas();// レイヤー再描画
      return(0);
    }
    for(i=0;i<layer_num;i++){	    
      if ( ev.xany.window == layer[i].win ){
	remapCanvas();// レイヤー再描画
	return(0);
      }
    }
    break;
  default:
    break;
  }
  return(1);
}
Exemplo n.º 3
0
/*
 * set the controller into the quiet mode for tune
 * action depends on type of controller (BrdType)
 *
 *     Author:  Frits Vosman 12/27/04
 */
cntlrTuneQuiet(TUNE_MSG *msge)
{
   DPRINT( 1," -- CNTLR_CMD_TUNE_QUIET --\n");
   switch(BrdType)
   {
      case MASTER_BRD_TYPE_ID:
         DPRINT(-1,"cntlrTuneQuiet: Master, should never get here");
         break;
      case RF_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneQuiet: RF Tune Off");
         /* TuneOFF(); */
         execFunc("TuneOFF",NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL);
         break;
      case PFG_BRD_TYPE_ID:
      case LPFG_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneQuiet: PFG ignores");
         break;
      case GRAD_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneQuiet: Grad ignores");
         break;
      case LOCK_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneQuiet: Lock ignores");
         break;
      case DDR_BRD_TYPE_ID:
         *pDDR_SoftwareGates &= ~0x8;
         *pDDR_FIFOOutputSelect = 1;
         DPRINT(1,"cntlrTuneQuiet: DDR RG On");
         break;
      default:
         DPRINT(-1,"cntlrTuneQuiet: Unknown cntlr, ignored");
         break;
   }
}
Exemplo n.º 4
0
/*
 * set the controller into the quiet mode for tune
 * action depends on type of controller (BrdType)
 *
 *     Author:  Frits Vosman 12/27/04
 */
cntlrTuneEnable(TUNE_MSG *msge)
{
   int activeChannel;
   activeChannel = msge->channel - 1;
   DPRINT1( 1," -- CNTLR_CMD_TUNE_ENABLE --  chan: %d\n",activeChannel);
   switch(BrdType)
   {
      case MASTER_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneEnable: Master, should not get here");
         break;
      case RF_BRD_TYPE_ID:
         if (BrdNum ==  activeChannel)
         {
            DPRINT3(-1,"cntlrTuneEnable: RF chan=%d, activate=%d, yes, attn=%d",
                                              BrdNum, activeChannel,msge->arg2);
            /* TuneON(frequency,power); */
            /* TuneON(msge->arg2*5); */
            execFunc("TuneON",(void*)(msge->arg2*5), NULL, NULL, NULL, NULL, NULL,NULL,NULL);
         }
         else
         {
            DPRINT2(1,"cntlrTuneEnable: RF chan=%d, activate=%d, no",
                                              BrdNum, activeChannel);
         }
         break;
      case LPFG_BRD_TYPE_ID:
      case PFG_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneEnable: PFG ignores");
         break;
      case GRAD_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneEnable: Grad ignores");
         break;
      case LOCK_BRD_TYPE_ID:
         DPRINT(1,"cntlrTuneEnable: Lock ignores");
         break;
      case DDR_BRD_TYPE_ID:
         *pDDR_FIFOOutputSelect = 0;
         *pDDR_SoftwareGates |= 0x8;
         DPRINT(1,"cntlrTuneEnable: DDR RG Off");
         break;
      default:
         DPRINT(-1,"cntlrTuneEnable: Unknown cntlr, ignored");
         break;
   }
}
Exemplo n.º 5
0
void Pattern::paternComp(OSCMessage *_mes){
/*
	Serial.print("got message, adress:_");
    Serial.print(_mes->_oscAddress );
		Serial.println("_");
		*/
    for (uint8_t i=0 ; i<patternNum ; i++) {
        if ( strcmp( addr[i] , _mes->_oscAddress ) == 0 ) execFunc( i , _mes );
    }
	
	for (uint8_t i=0 ; i<sinkNum ; i++) {
	/*
		Serial.print("sending message to sink: _");
		Serial.print(sinks[i]-> getAdress());
		Serial.print("_: ");
		//Serial.println("triggering sink");
		*/
		sinks[i]->digestMessage(_mes);

    }
}
Exemplo n.º 6
0
int vswrite(char *filepath, char *buffer, uint32_t size )
{
    char *filename;
    int result;

    if (strncmp(ICAT_DEV_PREFIX,filepath,sizeof(ICAT_DEV_PREFIX)-1) == 0)
    {
        char md5sig[36],prefix[36];
        char tmpname[36],tmpmd5[36];
        int rfType,index,prefixlen,preindex,inuse,maxNumFiles;
        int maxSize;
        uint32_t tmplen;
        char *colonptr;

        index = 0;
        rfType = execFunc("getRfType", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        if ( rfType != 1 )
        {
            printf("icat not available on this controller\n");
            return -1;
        }
        colonptr = strstr(filepath,":");
        prefixlen = (int) (colonptr - filepath);
        strncpy(prefix,filepath,prefixlen);
        prefix[prefixlen]=0;
        index = execFunc("extractIndex",prefix, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        filename = colonptr + 1;
        maxNumFiles = execFunc("getISFMaxNumFiles", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        maxNumFiles = (maxNumFiles == -1) ? 5 : maxNumFiles;
        // note: index for new FFS layout will be -1 since it's not specified.
        if (index < (maxNumFiles - 1))   // really only useful for old ISF FFS layout
        {
            maxSize = execFunc("getISFFileMaxSize", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
            if (size > maxSize)
            {
                printf("file: '%s', size: %ld, exceeds max: %ld for icat file\n",filename,size,maxSize);
                return -1;
            }
        }
        calcMd5(buffer, size, md5sig);
        // check if the given index already has an file entry
        // inuse = execFunc("readConfigTableHeader",index, tmpname, tmpmd5, &tmplen,NULL, NULL, NULL, NULL);

        // make sure this file name is unique, or over writting a present file
        preindex = execFunc("getConfigTableByName",filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        // printf("vswrite-icat: preindex: %d\n",preindex);
        // printf("vswrite-icat: preindex: %d, inuse: %d\n",preindex,inuse);
        // if ((preindex != -1) || (inuse != -1))// name was found
        if (preindex != -1) // name was found
        {
            /*
            if ( (preindex != index) && (preindex != -1) ) // name exist but not for this index
            {
                printf("file: '%s', is not unique, this name is already used by index: %d\n",filename,preindex);
                printf("Copy aborted. \n");
                return(-1);
            }
            else  // over-writting
            */
            {
                char answer[32];
                int led_id, chars;
                led_id = ledOpen(fileno(stdin),fileno(stdout),10);
                /*
                if (inuse != -1) // the given index is already in use
                {
                    printf("Overwite file '%s' ? (y or n) ? ",tmpname);
                }
                else
                {
                    printf("Overwite file? (y or n) ? ");
                }
                */
                printf("Overwite file? (y or n) ? ");

                chars = ledRead(led_id,answer,sizeof(answer));
                // printf("answer: %d -  '%s'\n",chars,answer);
                if (answer[0] == 'y')
                {
                    // int writeIsfFile(char *name, char *md5, UINT32 len, char *buffer, int overwrite)
                    result = execFunc("writeIsfFile", filename, md5sig, size, buffer, 1 , NULL, NULL, NULL);
                    // result = execFunc("writeConfigTable", index, filename, md5sig, size, buffer, NULL, NULL, NULL);
                    // printf("icat:file: result: %d, '%s', index: %d, md5: '%s', size: %ld, buff: 0x%lx\n", result, filename,index,md5sig,size,buffer);
                }
                else
                {
                    printf("Copy aborted. \n");
                    return(-1);
                }
            }
        }
        else
        {
            result = execFunc("writeIsfFile", filename, md5sig, size, buffer, 0 , NULL, NULL, NULL);
            // result = execFunc("writeConfigTable", index, filename, md5sig, size, buffer, NULL, NULL, NULL);
            // printf("icat:file: result: %d, '%s', index: %d, md5: '%s', size: %ld, buff: 0x%lx\n", result, filename,index,md5sig,size,buffer);
        }
        if (result == -2)
            printf("file: '%s', size: %ld, exceeds max: %ld for icat file\n",filename,size,maxSize);
        else if (result == -3)
            printf("No space left for file of %ld bytes\n",size);
    }
    else if (strncmp(FLASH_DEV_PREFIX,filepath,sizeof(FLASH_DEV_PREFIX)-1) == 0)
    {
        FFSHANDLE fileHdl;
        unsigned int cnt;
        uint32_t errorcode;
        uint32_t bufCnt;

        filename = filepath+sizeof(FLASH_DEV_PREFIX)-1;

        // printf("ffs:filename: '%s'\n",filename);
        /*  Check if file already exist on flash */
        if ((fileHdl = vfOpenFile(filename)) != 0)
        {
            char answer[32];
            int led_id, chars;
            led_id = ledOpen(fileno(stdin),fileno(stdout),10);
            printf("Overwite file? (y or n) ? ");
            chars = ledRead(led_id,answer,sizeof(answer));
            // printf("answer: %d -  '%s'\n",chars,answer);
            if (answer[0] == 'y')
            {
                /*  Close and delete file */
                sysFlashRW();
                vfAbortFile(fileHdl);
                sysFlashRO();    /* Flash to Read Only, via EBC  */
            }
            else /* option == 0 */
            {
                /*  Close file */
                vfCloseFile(fileHdl);
                printf("Copy aborted. \n");
                return(-1);
            }
            ledClose(led_id);
        }
        /* make flash writable, other wise an exception is thrown */
        sysFlashRW();

        /*  Create the file from scratch */
        fileHdl = vfCreateFile(filename, -1, -1, -1);
        if (fileHdl == 0)
        {
            errorcode = vfGetLastError();
            if (errorcode)
                vfFfsResult(filename);
            sysFlashRO();    /* Set Flash to Read Only, via EBC  */
            return(-1);
        }
        // unsigned long vfWriteFile(FFSHANDLE, unsigned char *, unsigned long, unsigned long *);
        errorcode = vfWriteFile(fileHdl, buffer, size, &bufCnt);
        if (errorcode != 0)
        {
            errorcode = vfGetLastError();
            if (errorcode)
                vfFfsResult(filename);
            /*  Close and delete file */
            vfAbortFile(fileHdl);
            sysFlashRO();    /* Flash to Read Only, via EBC  */
            return(-1);
        }
        if ( (bufCnt != size) )
        {
            printf("Incomplete write to flash, only %ld bytes of %ld bytes written.\n",
                   (unsigned long) bufCnt,size);
            /*  Close and delete file */
            vfAbortFile(fileHdl);
            sysFlashRO();    /* Flash to Read Only, via EBC  */
            return(-1);
        }
        vfCloseFile(fileHdl);
        sysFlashRO();    /* Set Flash to Read Only, via EBC  */
        result = 0;

        // printf("ffs:file: result: %d, '%s', size: %ld, buffer: 0x%lx\n",result, filename,size,buffer);
    }
    else
    {
        int fd,bytes;
        if (strncmp(NFS_DEV_PREFIX,filepath,sizeof(NFS_DEV_PREFIX)-1) == 0)
            filename = filepath+sizeof(NFS_DEV_PREFIX)-1;
        else
            filename = filepath;

        // printf("rsh:file: '%s'\n",filename);

        /* First check to see if the file system is mounted and the file     */
        /* can be opened successfully.                                       */
        fd = open(filename, O_CREAT | O_RDWR, 0644);
        if (fd < 0)
        {
            printf("rsh: '%s' could not be created\n",filename);
            return(-1);
        }
        bytes = write(fd,buffer,size);
        if (bytes != bytes)
        {
            printf("Incomplete write to host, only %ld bytes of %ld bytes written.\n",
                   (unsigned long) bytes,(long) size);
            close(fd);
            /*  Close and delete file */
            unlink(filename);
            return(-1);
        }
        close(fd);
        // printf("rsh:file: '%s', size: %ld, buffer: 0x%lx\n",filename,bytes,buffer);
        result = 0;
    }
    return result;
}
Exemplo n.º 7
0
char *vsload(char *filepath, uint32_t *size, uint32_t *dataOffset )
{

    char *filename;
    char *buffer;

    *dataOffset = 0L;
    // printf("vsload: file: '%s' \n",filepath);
    if (strncmp(ICAT_DEV_PREFIX,filepath,sizeof(ICAT_DEV_PREFIX)-1) == 0)
    {
        char md5sig[36];
        int result;
        int rfType,index;
        char *colonptr;

        *dataOffset = 0L;

        rfType = execFunc("getRfType", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        if ( rfType != 1 )
        {
            printf("icat not available on this controller\n");
            *size = 0;
            return NULL;
        }

        colonptr = strstr(filepath,":");
        filename = colonptr + 1;
        // buffer = readIsfFile(filename,size,dataOffset);
        buffer = execFunc("readIsfFile", filename, size, dataOffset,NULL,NULL,NULL,NULL,NULL);
        // printf("icat- file: '%s', size: %ld, dataOffset: %ld, buffer: 0x%lx\n",filename, *size, *dataOffset, buffer);
        if (buffer == NULL)
        {
            printf("icat: '%s', could not be open\n",filename);
            return NULL;
        }
    }
    else if (strncmp(FLASH_DEV_PREFIX,filepath,sizeof(FLASH_DEV_PREFIX)-1) == 0)
    {
        FFSHANDLE fileHdl;
        unsigned int cnt;
        filename = filepath+sizeof(FLASH_DEV_PREFIX)-1;

        if ((fileHdl = vfOpenFile(filename)) == NULL)
        {
            printf("ffs: '%s', could not be open\n",filename);
            *size = 0;
            return NULL;
        }

        *size = vfFilesize(fileHdl);
        if ((buffer = (char *) malloc(*size)) == NULL)
        {
            vfCloseFile(fileHdl);
            *size = 0;
            return NULL;
        }

        vfReadFile(fileHdl,0,buffer,*size,&cnt);
        // printf("ffs:file: '%s', size: %ld, dataOffset: %ld, buffer: 0x%lx\n",filename, *size, dataOffset, buffer);
        if (cnt != *size)
        {
            printf("Incomplete read, only %ld bytes of %ld bytes read.\n",
                   cnt,*size);
            free(buffer);
            vfCloseFile(fileHdl);
            *size = 0;
            return 0;
        }

        vfCloseFile(fileHdl);
    }
    else
    {
        int fd;
        struct stat fileStats;
        unsigned long fileSizeBytes,bytes;

        if (strncmp(NFS_DEV_PREFIX,filepath,sizeof(NFS_DEV_PREFIX)-1) == 0)
            filename = filepath+sizeof(NFS_DEV_PREFIX)-1;
        else
            filename = filepath;

        *size = 0;

        /* First check to see if the file system is mounted and the file     */
        /* can be opened successfully.                                       */
        fd = open(filename, O_RDONLY, 0444);
        if (fd < 0)
        {
            printf("rsh: '%s', could not be open\n",filename);
            return(NULL);
        }

        if (fstat(fd,&fileStats) != OK)
        {
            printf("failed to obtain status infomation on file: '%s'\n",filename);
            close(fd);
            return(NULL);
        }

        /* make sure it's a regular file */
        if ( ! S_ISREG(fileStats.st_mode) )
        {
            printf("Not a regular file.\n");
            close(fd);
            return(NULL);
        }

        *size = fileStats.st_size;


        if ((buffer = malloc(*size+1)) == NULL)
        {
            printf("Memory allocation failed\n");
            *size = 0;
            close(fd);
            return NULL;
        }

        if ( (bytes = read(fd, buffer,*size)) < *size)
        {
            printf("Incomplete read, only %ld bytes of %ld bytes read.\n",
                   bytes,*size);
            *size = 0;
            free(buffer);
            close(fd);
            return NULL;
        }
        // printf("rsh:file: '%s', size: %ld, dataOffset: %ld, buffer: 0x%lx\n",filename, *size, *dataOffset, buffer);
        buffer[*size] = '\0';
        close(fd);
    }
    return buffer;
}
Exemplo n.º 8
0
void Pattern::paternComp(OSCMessage *_mes){
    
    for (uint8_t i=0 ; i<patternNum ; i++) {
        if ( strcmp( addr[i] , _mes->_oscAddress ) == 0 ) execFunc( i , _mes );
    }
}