Commit aa972388 authored by TropOS's avatar TropOS
Browse files

Criado script de instalacao

parent 46ff601d
File deleted
/***********************************************************************************************
* MODULE: common_defs.h
* PURPOSE: common definitions
* WRITTEN BY: NDA
* COPYRIGHT: CAEN S.p.A. all rights reserved
* USAGE: compiled with gcc ?!?!
************************************************************************************************/
#ifndef __COMMON_DEFS_DEF_H
#define __COMMON_DEFS_DEF_H
////////////////////////////////////////////
// File includes
////////////////////////////////////////////
#include <stdio.h>
#include "keyb.h"
////////////////////////////////////////////
// Global defines
////////////////////////////////////////////
//
// Data tyes
typedef int BOOL;
#define TRUE -1
#define FALSE 0
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned long long UINT64;
typedef char INT8;
typedef short INT16;
typedef int INT32;
typedef long long INT64;
typedef const char* PCSTR;
//
// Debugging macros
#define TRACE( format) printf( format)
#define TRACE1( format, p1) printf( format, p1)
#define TRACE2( format, p1, p2) printf( format, p1, p2)
#define TRACE3( format, p1, p2, p3) printf( format, p1, p2, p3)
#define TRACE4( format, p1, p2, p3, p4) printf( format, p1, p2, p3, p4)
#define TRACE5( format, p1, p2, p3, p4, p5) printf( format, p1, p2, p3, p4, p5)
//
// Helper functions
//#ifdef LINUX
#define stricmp( str1, str2) strcasecmp( str1, str2)
#define strnicmp( str1, str2, n) strncasecmp( str1, str2, n)
//#endif
////////////////////////////////////////////
// Global variables declaration
////////////////////////////////////////////
////////////////////////////////////////////
// Global methods declaration
////////////////////////////////////////////
#endif
/***********************************************************************************************
* MODULE: common_defs.h
* PURPOSE: common definitions
* WRITTEN BY: NDA
* COPYRIGHT: CAEN S.p.A. all rights reserved
* USAGE: compiled with gcc ?!?!
************************************************************************************************/
#ifndef __COMMON_DEFS_DEF_H
#define __COMMON_DEFS_DEF_H
////////////////////////////////////////////
// File includes
////////////////////////////////////////////
#include <stdio.h>
#include "keyb.h"
////////////////////////////////////////////
// Global defines
////////////////////////////////////////////
//
// Data tyes
typedef int BOOL;
#define TRUE -1
#define FALSE 0
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned long long UINT64;
typedef char INT8;
typedef short INT16;
typedef int INT32;
typedef long long INT64;
typedef const char* PCSTR;
//
// Debugging macros
#define TRACE( format) printf( format)
#define TRACE1( format, p1) printf( format, p1)
#define TRACE2( format, p1, p2) printf( format, p1, p2)
#define TRACE3( format, p1, p2, p3) printf( format, p1, p2, p3)
#define TRACE4( format, p1, p2, p3, p4) printf( format, p1, p2, p3, p4)
#define TRACE5( format, p1, p2, p3, p4, p5) printf( format, p1, p2, p3, p4, p5)
//
// Helper functions
//#ifdef LINUX
#define stricmp( str1, str2) strcasecmp( str1, str2)
#define strnicmp( str1, str2, n) strncasecmp( str1, str2, n)
//#endif
////////////////////////////////////////////
// Global variables declaration
////////////////////////////////////////////
////////////////////////////////////////////
// Global methods declaration
////////////////////////////////////////////
#endif
#ifdef LINUX
/*****************************************************************************/
/* GETCH */
/*****************************************************************************/
int getch(void);
/*****************************************************************************/
/* KBHIT */
/*****************************************************************************/
int kbhit();
#else
#include <conio.h>
#include <ctype.h>
// getch and kbhit was declared deprecated in Microsoft Visual C++. The ISO C++
// conformant name with '_' preceding the name is suggested.
#define getch _getch
#define kbhit _kbhit*/
#endif
#ifdef LINUX
/*****************************************************************************/
/* GETCH */
/*****************************************************************************/
int getch(void);
/*****************************************************************************/
/* KBHIT */
/*****************************************************************************/
int kbhit();
#else/*
#include <conio.h>
#include <ctype.h>
// getch and kbhit was declared deprecated in Microsoft Visual C++. The ISO C++
// conformant name with '_' preceding the name is suggested.
#define getch _getch
#define kbhit _kbhit*/
#endif
/***********************************************************************************************
* MODULE: user_settings.h
* PURPOSE: user settng definitions
* WRITTEN BY: NDA
* COPYRIGHT: CAEN S.p.A. all rights reserved
* USAGE: compiled with gcc ?!?!
************************************************************************************************/
#ifndef __USER_SETTINGS_DEF_H
#define __USER_SETTINGS_DEF_H
////////////////////////////////////////////
// File includes
////////////////////////////////////////////
#include "common_defs.h"
#include "../N957/N957oslib.h"
#include "../N957/N957types.h"
////////////////////////////////////////////
// Global defines
////////////////////////////////////////////
#define MAX_FILENAME_LENGHT 255 /* maximum filename length */
typedef struct
{
char* m_log_filename; // output filename
char* m_config_filename; // Configuration filename
char* m_gnu_plot_path; // gnuplot path
long m_max_num_samples; // The maximum number of samples to acquire
N957_UINT16 m_bldim; // block dimension: maximum number of samples per call to retrive
BOOL m_debug; // debugging features enabled
N957ControlModes m_mode; // acqusition mode
int32_t m_N957_handle; // Board handle
int m_bd_num; // N957 board number
N957_BYTE m_lld; // LLD Threshold
BOOL m_log_to_file; // Write Data to output file
// int m_gnu_plot_refresh; // Gnu Plot refresh rate (msec)
// float m_gnu_plot_x_scale; // Gnu Plot X convertsion factor
} user_setting_data;
////////////////////////////////////////////
// Global variables declaration
////////////////////////////////////////////
////////////////////////////////////////////
// Global methods declaration
////////////////////////////////////////////
/***********************************************************************************************
* METHOD: user_settings_open
* PURPOSE: init user setting module
* PARAMETERS: <in> user_setting_data* p_data: data buffer pointer
* RETURN: TRUE: module init ok
* USAGE: call before any other methods
************************************************************************************************/
BOOL user_settings_open( user_setting_data* p_data);
/***********************************************************************************************
* METHOD: user_settings_close
* PURPOSE: closes user setting module (frees allocated resources)
* PARAMETERS: <in> user_setting_data* p_data: data buffer pointer
* RETURN: TRUE: module init ok
* USAGE: call before any other methods
************************************************************************************************/
BOOL user_settings_close( user_setting_data* p_data);
/***********************************************************************************************
* METHOD: user_parse_input_param
* PURPOSE: scan user input parameters
* PARAMETERS: <in> user_setting_data* p_data: data buffer pointer
* <in> int argc: number of input parameters
* <in> char* argv[]: string parameters list
* RETURN: TRUE: input parameter parsing ok
* USAGE:
************************************************************************************************/
//BOOL user_settings_parse_input_param( user_setting_data* p_data, int argc, char* argv[]);
BOOL parse_config_file( user_setting_data* p_data);
#endif
/***********************************************************************************************
* MODULE: user_settings.h
* PURPOSE: user settng definitions
* WRITTEN BY: NDA
* COPYRIGHT: CAEN S.p.A. all rights reserved
* USAGE: compiled with gcc ?!?!
************************************************************************************************/
#ifndef __USER_SETTINGS_DEF_H
#define __USER_SETTINGS_DEF_H
////////////////////////////////////////////
// File includes
////////////////////////////////////////////
#include "common_defs.h"
#include "../N957/N957oslib.h"
#include "../N957/N957types.h"
////////////////////////////////////////////
// Global defines
////////////////////////////////////////////
#define MAX_FILENAME_LENGHT 255 /* maximum filename length */
typedef struct
{
char* m_log_filename; // output filename
char* m_config_filename; // Configuration filename
char* m_gnu_plot_path; // gnuplot path
long m_max_num_samples; // The maximum number of samples to acquire
N957_UINT16 m_bldim; // block dimension: maximum number of samples per call to retrive
BOOL m_debug; // debugging features enabled
N957ControlModes m_mode; // acqusition mode
int32_t m_N957_handle; // Board handle
int m_bd_num; // N957 board number
N957_BYTE m_lld; // LLD Threshold
BOOL m_log_to_file; // Write Data to output file
// int m_gnu_plot_refresh; // Gnu Plot refresh rate (msec)
// float m_gnu_plot_x_scale; // Gnu Plot X convertsion factor
} user_setting_data;
////////////////////////////////////////////
// Global variables declaration
////////////////////////////////////////////
////////////////////////////////////////////
// Global methods declaration
////////////////////////////////////////////
/***********************************************************************************************
* METHOD: user_settings_open
* PURPOSE: init user setting module
* PARAMETERS: <in> user_setting_data* p_data: data buffer pointer
* RETURN: TRUE: module init ok
* USAGE: call before any other methods
************************************************************************************************/
BOOL user_settings_open( user_setting_data* p_data);
/***********************************************************************************************
* METHOD: user_settings_close
* PURPOSE: closes user setting module (frees allocated resources)
* PARAMETERS: <in> user_setting_data* p_data: data buffer pointer
* RETURN: TRUE: module init ok
* USAGE: call before any other methods
************************************************************************************************/
BOOL user_settings_close( user_setting_data* p_data);
/***********************************************************************************************
* METHOD: user_parse_input_param
* PURPOSE: scan user input parameters
* PARAMETERS: <in> user_setting_data* p_data: data buffer pointer
* <in> int argc: number of input parameters
* <in> char* argv[]: string parameters list
* RETURN: TRUE: input parameter parsing ok
* USAGE:
************************************************************************************************/
BOOL user_settings_parse_input_param( user_setting_data* p_data, int argc, char* argv[]);
#endif
# The objective of this file is to make an installation script which generates and correctly places the program N957Run.
# The objective of this file is to make an installation script which generates and correctly places the program N957Run.
cd ./install/
make
mv ./N957Run ../python/N957Run
# -*- coding: iso-8859-15 -*-
import numpy as np
import Tkinter as tk
import matplotlib.pyplot as plt
#########################################################################
#Classe que adiciona parâmetros necessários para os plots dos espectros#
#########################################################################
class Grafico:
def __init__(self, Nmr):
self.Nmr_serial= Nmr #Nmr_serial do módulo da CAEN
self.limupdtx=False # Update automático no eixo x?
self.limupdty=False # Update automático no eixo y?
self.limtrans=False # Usado no botão direito
self.Checkbutton_Plot= tk.IntVar()
#self.limupdt=True
#self.limctrl=False# Usado para a antiga função do botão direito
#self.x0=0
#self.y0=0
#self.x1=512
#self.y1=0
self.pressx=0. #Variável que guarda a posição x do click do botão direito (ZOOM)
self.pressy=0. #Variável que guarda a posição y do click do botão direito (ZOOM)
#self.dx=0.
#self.dy=0.
self.fig= plt.figure()
self.title=None # poderia tirar direto do grafico
self.subplot= self.fig.add_subplot(111, axisbg='#555555') # cria os eixos do gráfico
self.Data=None
self.Canvas=None
self.Frame=None # O Frame que esse gráfico se encontra
#self.background=None
self.x_bounds=(0,0)
self.Cursor=dict(x=256,line=self.subplot.axvline(x=256,color='red'))
#for i in range(0, 8):
# self.Grid = self.subplot.axvline(x=64*i, linestyle = 'dashed', color = 'black')
# self.Grid = self.subplot.axhline(y=32*i, linestyle = 'dashed', color = 'black')
def draw_Cursor(self,Pos):
self.Cursor['x']=(Pos)
self.Cursor['line'].remove()
self.Cursor['line']=self.subplot.axvline(x= self.Cursor['x'],color='red')
self.fig.canvas.draw()
import Tkinter as tk
import pexpect
import time
import numpy as np
from array import *
##############################################################################
##############################################################################
#Classe que faz o Pipe com o programa em C
class Modulo:
def __init__(self, Nmr_modulo):
self.child = pexpect.spawn('./N957Run '+ Nmr_modulo)
#self.Controle['Nmr_serial']=Serial
self.Data=array('L',[0]*8192)
self.Controle=dict(pause=1,Nmr_serial=0,Nmr_canais=512, ON=0)
self.Livetime = dict(ADC_Conversion=0 , Time=0. , DeadTime=0.)
def start(self):
self.child.send('s')
msg=(self.child.readline().strip("\r\n"))
print msg
return msg
def set_fator(self, canais): # Define o fator para conversao do numero de canais
self.Controle['Nmr_canais']=canais
if int(canais) == 8192: # 8192 pontos
self.child.send('a')
elif int(canais) == 4096: # 4096 pontos
self.child.send('b')
elif int(canais) == 2048: # 2048 pontos
self.child.send('c')
elif int(canais) == 1024: # 1024 pontos
self.child.send('d')
elif int(canais) == 512: # 512 pontos
self.child.send('e')
elif int(canais) == 256: # 256 pontos
self.child.send('f')
elif int(canais) == 128: # 128 pontos
self.child.send('g')
elif int(canais) == 64: # 64 pontos
self.child.send('h')
def load(self):
self.child.send('y')
def LLDT(self, lldt):
self.child.send('j')
self.child.send(chr(int(lldt)/10))
self.child.send(chr(int(lldt)%10))
def Read_Data(self):
msg=(self.child.readline().strip("\r\n"))
if msg == 'OK':
self.Data = eval(self.child.readline().strip("\r\n"))
self.Livetime['ADC_Conversion'] = int(self.child.readline().strip("\r\n"))
self.Livetime['Time'] = float(self.child.readline().strip("\r\n"))
self.Livetime['DeadTime'] = (self.Livetime['Time'] - float(self.child.readline().strip("\r\n")))*100/self.Livetime['Time']
return msg
def dump(self): # Sinal para programa coletor enviar os dados
self.child.send('i')
def reset(self):
self.child.send('r')
for k in range(int(self.Controle['Nmr_canais'])):
self.Data[k] = 0
def pause(self):
self.child.send('p')
def exit(self):
self.child.send('q')
time.sleep(0.1)
self.child.close(force=True)
def set_AutoGate(self):
self.child.send('m')
def set_ExternalGate(self):
self.child.send('n')
MCA = 175
#MCB = 174
#MCC = 174
#MCD = xxx
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment