int K213ControlPanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2) { gpibioPtr dev = callbackData; k213Ptr quadsrc = dev->device; int menubar, port; if ((event == EVENT_KEYPRESS && eventData1 == VAL_ESC_VKEY) || (event == EVENT_RIGHT_DOUBLE_CLICK)) { devPanel_Remove (panel); for (port = 0; port < 4; port++) { HidePanel (quadsrc->port[port].panel); } DiscardPanel (panel); dev->iPanel = 0; SetMenuBarAttribute (acquire_GetMenuBar(), dev->menuitem_id, ATTR_DIMMED, FALSE); } if (event == EVENT_GOT_FOCUS && panel == dev->iPanel) { menubar = GetPanelMenuBar (panel); SetPanelAttribute (panel, ATTR_DIMMED, (dev->status != DEV_REMOTE)); SetMenuBarAttribute (menubar, K213MENUS_FILE_SAVE, ATTR_DIMMED, (dev->status != DEV_REMOTE)); SetMenuBarAttribute (menubar, K213MENUS_FILE_LOAD, ATTR_DIMMED, (dev->status != DEV_REMOTE)); if (!util_TakingData()) k213_UpdateControls (panel, dev); } return 0; }
int K2400ControlPanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2) { gpibioPtr dev = callbackData; k2400Ptr smu = dev->device; int menubar; if ((event == EVENT_KEYPRESS && eventData1 == VAL_ESC_VKEY) || event == EVENT_RIGHT_DOUBLE_CLICK) { devPanel_Remove (panel); DiscardPanel (panel); dev->iPanel = 0; SetMenuBarAttribute (acquire_GetMenuBar(), dev->menuitem_id, ATTR_DIMMED, FALSE); } if (event == EVENT_GOT_FOCUS) { menubar = GetPanelMenuBar (panel); SetPanelAttribute (panel, ATTR_DIMMED, (dev->status != DEV_REMOTE)); SetMenuBarAttribute (menubar, K2400MENUS_FILE_SAVE, ATTR_DIMMED, (dev->status != DEV_REMOTE)); SetMenuBarAttribute (menubar, K2400MENUS_FILE_LOAD, ATTR_DIMMED, (dev->status != DEV_REMOTE)); SetMenuBarAttribute (menubar, K2400MENUS_SOURCE, ATTR_DIMMED, (dev->status != DEV_REMOTE)); SetMenuBarAttribute (menubar, K2400MENUS_MEASURE, ATTR_DIMMED, (dev->status != DEV_REMOTE)); if (!util_TakingData()) k2400_UpdateControls (panel, dev); } return 0; }
void DimAction(int flag) { SetCtrlAttribute (panelHandle, PANEL_OUTPUT, ATTR_DIMMED, flag); SetCtrlAttribute (panelHandle, PANEL_TAB, ATTR_DIMMED, flag); /* SetCtrlAttribute (bbucommonHandle, BBUCOMMON_DOWNLOAD, ATTR_DIMMED, flag); SetCtrlAttribute (bbucommonHandle, BBUCOMMON_UPLOAD, ATTR_DIMMED, flag); SetCtrlAttribute (bbucommonHandle, BBUCOMMON_CONFIGCMD, ATTR_DIMMED, flag); SetCtrlAttribute (bbucommonHandle, BBUCOMMON_SENDCMD, ATTR_DIMMED, flag); SetCtrlAttribute (bbucommonHandle, BBUCOMMON_ENABLEPORT, ATTR_DIMMED, flag); SetCtrlAttribute (bbucommonHandle, BBUCOMMON_UPDATEALLPUT, ATTR_DIMMED, flag); SetCtrlAttribute (rrucommonHandle, RRUCOMMON_ENABLEOPT, ATTR_DIMMED, flag); SetCtrlAttribute (rrucommonHandle, RRUCOMMON_ENABLEVSWR, ATTR_DIMMED, flag); SetCtrlAttribute (rrucommonHandle, RRUCOMMON_GETRRULOG, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_UPDATENAME, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_UPDATEVENDOR, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_CHECKSFP, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_SEARCHFILE, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_RECORDUPTIME, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_CHECKUPTIME, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_FETCHLOGS, ATTR_DIMMED, flag); SetCtrlAttribute (customizingHandle, CUSTOM_ANALYZEFILTER, ATTR_DIMMED, flag); */ SetMenuBarAttribute (menubarHandle, MENUBAR_CONFIG, ATTR_DIMMED, flag); SetMenuBarAttribute (menubarHandle, MENUBAR_HELP, ATTR_DIMMED, flag); }
static void k213_Operate (int menubar, int menuItem, void *callbackData, int panel) { int p, m, port, width, height; gpibioPtr dev = callbackData; k213Ptr quadsrc = dev->device; char label[256]; SetMenuBarAttribute (menubar, menuItem, ATTR_DIMMED, TRUE); p = dev->iPanel? dev->iPanel: LoadPanel (utilG.p, "k213u.uir", K213); dev->iPanel = p; Fmt (label, "Keithley 213 : %s", dev->label); SetPanelAttribute (p, ATTR_TITLE, label); m = LoadMenuBar (p, "k213u.uir", K213MENUS); SetPanelMenuBar (p, m); SetPanelAttribute (p, ATTR_CALLBACK_DATA, dev); SetMenuBarAttribute (m, K213MENUS_FILE_SAVE, ATTR_CALLBACK_DATA, dev); SetMenuBarAttribute (m, K213MENUS_FILE_LOAD, ATTR_CALLBACK_DATA, dev); SetMenuBarAttribute (m, K213MENUS_FILE_GPIB, ATTR_CALLBACK_DATA, dev); for (port = 0; port < 4; port++) { quadsrc->port[port].panel = LoadPanel (p, "k213u.uir", K213PORT); GetPanelAttribute (quadsrc->port[port].panel, ATTR_WIDTH, &width); GetPanelAttribute (quadsrc->port[port].panel, ATTR_HEIGHT, &height); SetPanelPos (quadsrc->port[port].panel, 17+2, (port*(width+4))+2); Fmt (label, "port %i", port+1); SetCtrlVal (quadsrc->port[port].panel, K213PORT_TITLE, label); SetCtrlAttribute (quadsrc->port[port].panel, K213PORT_DISPLAY, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (quadsrc->port[port].panel, K213PORT_AUTORANGE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (quadsrc->port[port].panel, K213PORT_RANGE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (quadsrc->port[port].panel, K213PORT_SETUP, ATTR_CALLBACK_DATA, dev); SetPanelAttribute(quadsrc->port[port].panel, ATTR_CALLBACK_DATA, dev); DisplayPanel (quadsrc->port[port].panel); } SetPanelAttribute (p, ATTR_WIDTH, (width+4)*port); SetPanelAttribute (p, ATTR_HEIGHT, height+4+17); SetPanelPos (p, VAL_AUTO_CENTER, VAL_AUTO_CENTER); k213_UpdateControls (p, dev); devPanel_Add (p, dev, k213_UpdateReadings); DisplayPanel (p); }
void das1602Operate (int menubar, int menuItem, void *callbackData, int panel) { MCCdevPtr dev = callbackData; das1602Ptr das = dev->device; acqchanPtr acqchan; int i, x = 0, m; if(!das->panel) { das->panel = LoadPanel(utilG.p, "DAS-1602u.uir", DAS_CTRL); das->menu = LoadMenuBar(das->panel, "DAS-1602u.uir", DASMENU); SetPanelMenuBar(das->panel, das->menu); for(i = 0; i < 8; i ++) { SetMenuBarAttribute (das->menu, das->Achannels[i]->menuitem_id, ATTR_CALLBACK_DATA, das->Achannels[i]); SetMenuBarAttribute (das->menu, das->Achannels[i]->menuitem_id, ATTR_ITEM_NAME, das->Achannels[i]->port.analogueIOport.IO.acqchan->channel->label); SetMenuBarAttribute (das->menu, das->Achannels[i]->menuitem_id, ATTR_CHECKED, das->Achannels[i]->port.analogueIOport.IO.acqchan->acquire); } SetMenuBarAttribute (das->menu, DASMENU_SOURCE_DAC1, ATTR_CALLBACK_DATA, das->Achannels[8]->port.analogueIOport.IO.source); SetMenuBarAttribute (das->menu, DASMENU_SOURCE_DAC2, ATTR_CALLBACK_DATA, das->Achannels[9]->port.analogueIOport.IO.source); SetMenuBarAttribute (das->menu, DASMENU_SOURCE_DAC1, ATTR_ITEM_NAME, das->Achannels[8]->port.analogueIOport.IO.source->acqchan->channel->label); SetMenuBarAttribute (das->menu, DASMENU_SOURCE_DAC2, ATTR_ITEM_NAME, das->Achannels[9]->port.analogueIOport.IO.source->acqchan->channel->label); SetCtrlAttribute (das->panel, DAS_CTRL_RANGE, ATTR_DIMMED, 1); SetCtrlAttribute (das->panel, DAS_CTRL_ACQ, ATTR_DIMMED, 1); SetCtrlAttribute (das->panel, DAS_CTRL_INPUT, ATTR_CALLBACK_DATA, das->Achannels[0]); SetPanelAttribute (das->panel, ATTR_CALLBACK_DATA, das); } SetMenuBarAttribute(menubar, menuItem, ATTR_DIMMED, 1); devPanel_Add (das->panel, dev, das1602_UpdateReadings); DisplayPanel(das->panel); }
int das1602_MeasureControlCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { acqchanPtr acqchan = callbackData; switch (control) { case MEASURE_RANGE: if (event == EVENT_COMMIT) { portPtr port = acqchan->upLvl; GetCtrlVal (panel, control, &port->port.analogueIOport.range); } break; case MEASURE_LABEL: if (event == EVENT_COMMIT) { portPtr port = acqchan->upLvl; MCCdevPtr dev = acqchan->dev; das1602Ptr das = dev->device; GetCtrlVal(panel, control, acqchan->channel->label); acqchanlist_ReplaceChannel(acqchan); SetPanelAttribute(panel, ATTR_TITLE, acqchan->channel->label); SetMenuBarAttribute (das->menu, port->menuitem_id, ATTR_ITEM_NAME, acqchan->channel->label); } break; case MEASURE_COEFF: if (event == EVENT_COMMIT) GetCtrlVal(panel, control, &acqchan->coeff); break; case MEASURE_ACQ: if (event == EVENT_COMMIT && utilG.acq.status != ACQ_BUSY) { portPtr port = acqchan->upLvl; MCCdevPtr dev = acqchan->dev; das1602Ptr das = dev->device; GetCtrlVal(panel, control, &acqchan->acquire); if (acqchan->acquire) acqchanlist_AddChannel(acqchan); else acqchanlist_RemoveChannel(acqchan); SetMenuBarAttribute (das->menu, port->menuitem_id, ATTR_CHECKED, acqchan->acquire); } else if(event == EVENT_COMMIT && utilG.acq.status == ACQ_BUSY) SetCtrlVal (panel, control, acqchan->acquire); break; } return 0; }
//--------------------------------------------------------- // инициализация ЦАП //--------------------------------------------------------- void InitDac(int Pnl) { // запретим работу АЦП if(!ENABLE_ADC_PLX(&bi[0], 0)) { DefaultCtrl(Pnl, P(BOX)); SetCtrlVal(Pnl, P(BOX), " Не выполнена функция ENABLE_ADC_PLX()!"); SetMenuBarAttribute(B(ADC), ATTR_MENU_BAR_ENABLED, DISABLE); return; } // запретим работу ЦАП if(!ENABLE_DAC_STREAM_PLX(&bi[0], 0)) { DefaultCtrl(Pnl, P(BOX)); SetCtrlVal(Pnl, P(BOX), " Не выполнена функция ENABLE_DAC_STREAM_PLX()!"); SetMenuBarAttribute(B(DAC), ATTR_MENU_BAR_ENABLED, DISABLE); SetCtrlAttribute(Pnl, P(START), ATTR_CTRL_ENABLED, DISABLE); return; } // отконфигурируем FIFO буфер ЦАП if(!DAC_FIFO_CONFIG_PLX(&bi[0], 1024)) { DefaultCtrl(Pnl, P(BOX)); SetCtrlVal(Pnl, P(BOX), " Не выполнена функция DAC_FIFO_CONFIG_PLX()!"); SetMenuBarAttribute(B(DAC), ATTR_MENU_BAR_ENABLED, DISABLE); SetCtrlAttribute(Pnl, P(START), ATTR_CTRL_ENABLED, DISABLE); return; } DacFifoBaseAddress=GET_DM_WORD_PLX(&bi[0], L_DAC_FIFO_BASE_ADDRESS_PLX); DacFifoLength=GET_DM_WORD_PLX(&bi[0], L_DAC_FIFO_LENGTH_PLX); // установим частоту работы ЦАП if(!SET_DAC_RATE_PLX(&bi[0], &DAC_Rate)) { DefaultCtrl(Pnl, P(BOX)); SetCtrlVal(Pnl, P(BOX), " Не выполнена функция SET_DAC_RATE_PLX()!"); SetMenuBarAttribute(B(DAC), ATTR_MENU_BAR_ENABLED, DISABLE); SetCtrlAttribute(Pnl, P(START), ATTR_CTRL_ENABLED, DISABLE); return; } else SetCtrlVal(Pnl, P(DAC_RATE), DAC_Rate); }
void acquire_UpdatePanel(void) { int menuBar; if (expG.UpdatePanel) expG.UpdatePanel(); menuBar = GetPanelMenuBar (acqG.p.setup); SetMenuBarAttribute (menuBar, ACQMENUS_EXP_GENERAL, ATTR_DIMMED, util_TakingData()); SetMenuBarAttribute (menuBar, ACQMENUS_EXP_SOURCE, ATTR_DIMMED, util_TakingData()); SetMenuBarAttribute (menuBar, ACQMENUS_EXP_BEGIN, ATTR_DIMMED, util_TakingData()); SetMenuBarAttribute (menuBar, ACQMENUS_EXP_PAUSE, ATTR_DIMMED, !(utilG.acq.status == ACQ_BUSY)); SetMenuBarAttribute (menuBar, ACQMENUS_EXP_CONTINUE, ATTR_DIMMED, !(utilG.acq.status == ACQ_PAUSED)); SetMenuBarAttribute (menuBar, ACQMENUS_EXP_END, ATTR_DIMMED, !util_TakingData()); SetMenuBarAttribute (menuBar, ACQMENUS_EXP_INFO, ATTR_DIMMED, !util_TakingData()); acqchanlist_Dimmed (util_TakingData()); switch (utilG.acq.status) { case ACQ_BUSY: SetCtrlVal (acqG.p.setup, ACQSETUP_STATUS, "BUSY"); break; case ACQ_STOPPED: SetCtrlVal (acqG.p.setup, ACQSETUP_STATUS, "STOPPED"); break; case ACQ_DONE: SetCtrlVal (acqG.p.setup, ACQSETUP_STATUS, "DONE"); break; case ACQ_PAUSED: SetCtrlVal (acqG.p.setup, ACQSETUP_STATUS, "PAUSED"); break; } }
int das1602_ControlCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { portPtr port = callbackData; switch (control) { case DAS_CTRL_RANGE: if(event == EVENT_COMMIT && port) GetCtrlVal(panel, control, &port->port.analogueIOport.range); break; case DAS_CTRL_INPUT: if(event == EVENT_COMMIT && port) { int i; MCCdevPtr dev = port->port.analogueIOport.IO.acqchan->dev; das1602Ptr das = dev->device; GetCtrlVal(panel, control, &i); port->control = 0; if(i != -1) { das->Achannels[i]->control = control; SetCtrlAttribute (panel, control, ATTR_CALLBACK_DATA, das->Achannels[i]); SetCtrlAttribute (panel, DAS_CTRL_RANGE, ATTR_CALLBACK_DATA, das->Achannels[i]); SetCtrlAttribute (panel, DAS_CTRL_ACQ, ATTR_CALLBACK_DATA, das->Achannels[i]); SetCtrlIndex (panel, DAS_CTRL_RANGE, das1602_IndexFromRange(das->Achannels[i]->port.analogueIOport.range)); SetCtrlVal (panel, DAS_CTRL_ACQ, das->Achannels[i]->port.analogueIOport.IO.acqchan->acquire); } SetCtrlAttribute (panel, DAS_CTRL_RANGE, ATTR_DIMMED, (i == -1)); SetCtrlAttribute (panel, DAS_CTRL_ACQ, ATTR_DIMMED, (i == -1)); if(i == -1)SetCtrlVal (panel, DAS_CTRL_ACQ, 0); } break; case DAS_CTRL_ACQ: if(event == EVENT_COMMIT && port && utilG.acq.status != ACQ_BUSY) { int i; MCCdevPtr dev = port->port.analogueIOport.IO.acqchan->dev; das1602Ptr das = dev->device; GetCtrlIndex (panel, DAS_CTRL_INPUT, &i); if(i) { GetCtrlVal (panel, control, &port->port.analogueIOport.IO.acqchan->acquire); if (port->port.analogueIOport.IO.acqchan->acquire) acqchanlist_AddChannel(port->port.analogueIOport.IO.acqchan); else acqchanlist_RemoveChannel(port->port.analogueIOport.IO.acqchan); SetMenuBarAttribute (das->menu, port->menuitem_id, ATTR_CHECKED, port->port.analogueIOport.IO.acqchan->acquire); } else if(event == EVENT_COMMIT && utilG.acq.status == ACQ_BUSY) SetCtrlVal (panel, control, port->port.analogueIOport.IO.acqchan->acquire); } break; } if(event == EVENT_COMMIT && port) das1602_UpdateMeasurePanel (port); return 0; }
static void k2400_UpdateReadings (int panel, void *dev) { gpibioPtr my_dev = dev; k2400Ptr smu = my_dev->device; acqchanPtr acqchan = smu->source->acqchan; short statusbyte; char rsp[256]; int control, dim, bg, mode, m; if (smu->operate) { if (utilG.acq.status == ACQ_BUSY) Delay(.05); if (!util_TakingData() || !(smu->source->acqchan->acquire || smu->measure->acquire)) { gpibio_GetStatusByte (dev, &statusbyte); if (statusbyte & K2400_SRE_READINGDONE) { //k2400_In (dev, rsp); //Scan (rsp, "%s>%f,%f", &smu->source->acqchan->reading, // &smu->measure->reading); } //if (statusbyte & K2400_SRE_READYFORTRIGGER) //k2400_Out (dev, "H0X", .02); } time(&present); if(difftime(present, past) >= delay) { k2400_GetReadings(acqchan); time(&past); } //if (expG.acqstatus != utilG.acq.status) { m = GetPanelMenuBar (panel); dim = (util_TakingData() && smu->source->inlist && (utilG.exp == EXP_SOURCE)); if (dim) { mode = VAL_INDICATOR; bg = VAL_PANEL_GRAY;} else { mode = VAL_HOT; bg = VAL_WHITE;} SetCtrlAttribute (panel, K2400_SOURCE, ATTR_CTRL_MODE, mode); SetCtrlAttribute (panel, K2400_SOURCE, ATTR_TEXT_BGCOLOR, bg); SetInputMode (panel, K2400_OPERATE, !dim); SetInputMode (panel, K2400_SELECT, !dim); SetInputMode (panel, K2400_SENSE, !dim); SetMenuBarAttribute (m, K2400MENUS_FILE_LOAD, ATTR_DIMMED, dim); } k2400_CheckforProblems (my_dev); SetCtrlVal (panel, K2400_OVERLIMIT, smu->overLimit); control = GetActiveCtrl (panel); if (util_TakingData() || (control != K2400_SOURCE)) SetCtrlVal (panel, K2400_SOURCE, smu->source->acqchan->reading); SetCtrlVal (panel, K2400_MEASURE, smu->measure->reading); } }
void acquire_UpdatePanelExp (void) { int bTop, cTop, height, bottom; /* Floating experiment */ SetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_POINTS, ATTR_VISIBLE, utilG.exp == EXP_FLOAT); SetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_DELAY, ATTR_VISIBLE, utilG.exp == EXP_FLOAT); SetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_TIME, ATTR_VISIBLE, utilG.exp == EXP_FLOAT); SetMenuBarAttribute (acquire_GetMenuBar(), ACQMENUS_EXP_GENERAL, ATTR_CHECKED, utilG.exp == EXP_FLOAT); /* Source experiment */ SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_LIST, ATTR_VISIBLE, utilG.exp == EXP_SOURCE); SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_MOVEUP, ATTR_VISIBLE, utilG.exp == EXP_SOURCE); SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_MOVEDOWN, ATTR_VISIBLE, utilG.exp == EXP_SOURCE); SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_REMOVE, ATTR_VISIBLE, utilG.exp == EXP_SOURCE); SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_POINTS, ATTR_VISIBLE, utilG.exp == EXP_SOURCE); SetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_TIME, ATTR_VISIBLE, utilG.exp == EXP_SOURCE); SetMenuBarAttribute (acquire_GetMenuBar(), ACQMENUS_EXP_SOURCE, ATTR_CHECKED, utilG.exp == EXP_SOURCE); switch (utilG.exp) { case EXP_FLOAT: GetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_DELAY, ATTR_TOP, &cTop); GetCtrlAttribute (acqG.p.setup, ACQSETUP_GEN_DELAY, ATTR_HEIGHT, &height); SetCtrlVal (acqG.p.setup, ACQSETUP_EXPTITLE, "Floating Experiment"); break; case EXP_SOURCE: GetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_POINTS, ATTR_TOP, &cTop); GetCtrlAttribute (acqG.p.setup, ACQSETUP_SRC_POINTS, ATTR_HEIGHT, &height); SetCtrlVal (acqG.p.setup, ACQSETUP_EXPTITLE, "source control experiment"); break; } GetCtrlAttribute (acqG.p.setup, ACQSETUP_BOX_1, ATTR_TOP, &bTop); SetCtrlAttribute (acqG.p.setup, ACQSETUP_BOX_1, ATTR_HEIGHT, cTop+height+10-bTop); SetPanelAttribute (acqG.p.setup, ATTR_HEIGHT, cTop+height+36); }
int SR844ControlPanelCallback(int panel, int event, void *callbackData, int eventData1, int eventData2) { gpibioPtr dev; sr844Ptr lia; if (((event == EVENT_KEYPRESS) && (eventData1 == VAL_ESC_VKEY)) || (event == EVENT_RIGHT_DOUBLE_CLICK)) { dev = callbackData; lia = dev->device; devPanel_Remove (panel); DiscardPanel (panel); dev->iPanel = 0; SetMenuBarAttribute (acquire_GetMenuBar(), dev->menuitem_id, ATTR_DIMMED, FALSE); } return 0; }
int das1602_PanelCallback (int panel, int event, void *callbackData, int eventData1, int eventData2) { das1602Ptr das = callbackData; if((event == EVENT_KEYPRESS && eventData1 == VAL_ESC_VKEY) || event == EVENT_RIGHT_DOUBLE_CLICK) { MCCdevPtr dev = das->Achannels[0]->port.analogueIOport.IO.acqchan->dev; int i; for (i = 0; i < 8; i ++) if(das->Achannels[i]->measPanel) HidePanel(das->Achannels[i]->measPanel); devPanel_Remove(panel); HidePanel(panel); SetMenuBarAttribute (acquire_GetMenuBar(), dev->menuitem_id, ATTR_DIMMED, FALSE); } return 0; }
/* 系统辅助函数-刷新控制项Dimmed状态 */ void refreshDimmedStat(void){ int i=0; //chooseDataSrcFlag =1, dimmed; =0, enabled. int Ctrls[2]={0}; //Object control int menuCtrls[5]={0}; //Menu control Ctrls[0] = MainPanel_ControlBtn; menuCtrls[0] = GetPanelMenuBar(panelHdl); menuCtrls[1] = MENUBAR_Menu_Control; menuCtrls[2] = MENUBAR_Menu3_View; for(i=0; i<sizeof(Ctrls)/sizeof(int); i++){ if(Ctrls[i] <=0) continue; SetCtrlAttribute(panelHdl, Ctrls[i], ATTR_DIMMED, chooseDataSrcFlag); } for(i=1; i<sizeof(menuCtrls)/sizeof(int); i++){ if(menuCtrls[i] <=0 ) continue; SetMenuBarAttribute(menuCtrls[0], menuCtrls[i], ATTR_DIMMED, chooseDataSrcFlag); } }
void usb1208ls_Load (MCCdevPtr dev) { int i; usb1208lsPtr pmd = dev->device; for ( i = 0; i < 4; i++) { port_Load (dev, pmd->aiPorts[i]); SetMenuBarAttribute (pmd->menu, pmd->aiPorts[i]->menuitem_id, ATTR_CHECKED, pmd->aiPorts[i]->port.analogueIOport.IO.acqchan->acquire); } for ( i = 0; i < 3; i ++) { port_Load (dev, pmd->aoPorts[i]); pmd->aoPorts[i]->port.analogueIOport.IO.source->acqchan->reading = pmd->aoPorts[i]->port.analogueIOport.IO.source->biaslevel; usb1208ls_SetLevel(pmd->aoPorts[i]->port.analogueIOport.IO.source); } port_Load (dev, pmd->diPort); port_Load (dev, pmd->doPort); }
static void OperateK236 (int menubar, int menuItem, void *callbackData, int panel) { int p, m; gpibioPtr dev = callbackData; k236Ptr smu = dev->device; char label[256]; SetMenuBarAttribute (menubar, menuItem, ATTR_DIMMED, TRUE); p = dev->iPanel? dev->iPanel:LoadPanel (utilG.p, "k236u.uir", K236); dev->iPanel = p; SetPanelPos (p, VAL_AUTO_CENTER, VAL_AUTO_CENTER); Fmt (label, "Keithley 236 Source Measure Unit: %s", dev->label); SetPanelAttribute (p, ATTR_TITLE, label); m = LoadMenuBar (p, "k236u.uir", K236MENUS); SetPanelMenuBar (p, m); SetMenuBarAttribute (m, K236MENUS_FILE_SAVE, ATTR_CALLBACK_DATA, dev); SetMenuBarAttribute (m, K236MENUS_FILE_LOAD, ATTR_CALLBACK_DATA, dev); SetMenuBarAttribute (m, K236MENUS_FILE_GPIB, ATTR_CALLBACK_DATA, dev); SetMenuBarAttribute (m, K236MENUS_SOURCE, ATTR_CALLBACK_DATA, smu->source); SetMenuBarAttribute (m, K236MENUS_MEASURE, ATTR_CALLBACK_DATA, smu->measure); SetPanelAttribute (p, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_SOURCE, ATTR_CALLBACK_DATA, smu->source); SetCtrlAttribute (p, K236_SOURCE_I_RANGE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_SOURCE_V_RANGE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_DELAY, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_IDENTIFY, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_OPERATE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_SELECT, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_SENSE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_MEAS_I_RANGE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_MEAS_V_RANGE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_LEVEL, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_FILTER, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_INTTIME, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, K236_SUPPRESS, ATTR_CALLBACK_DATA, dev); k236_UpdateControls (p, dev); devPanel_Add (p, dev, k236_UpdateReadings); DisplayPanel (p); }
static void k213_UpdateReadings (int panel, void *dev) { gpibioPtr my_dev = dev; k213Ptr quadsrc = my_dev->device; unsigned short statusbyte; char rsp[256]; int control, dim, bg, mode, m, active_panel, port; for (port = 0; port < 4; port++) { if (!util_TakingData() || !quadsrc->port[port].src->acqchan->acquire) k213_GetPortLevel (port+1, dev); } if (expG.acqstatus != utilG.acq.status) { m = GetPanelMenuBar (panel); for (port = 0; port < 4; port++) { dim = (util_TakingData() && quadsrc->port[port].src->inlist && (utilG.exp == EXP_SOURCE)); if (dim) { mode = VAL_INDICATOR; bg = VAL_PANEL_GRAY;} else { mode = VAL_HOT; bg = VAL_WHITE;} SetCtrlAttribute (quadsrc->port[port].panel, K213PORT_DISPLAY, ATTR_CTRL_MODE, mode); SetCtrlAttribute (quadsrc->port[port].panel, K213PORT_DISPLAY, ATTR_TEXT_BGCOLOR, bg); SetInputMode (quadsrc->port[port].panel, K213PORT_AUTORANGE, !dim); SetInputMode (quadsrc->port[port].panel, K213PORT_RANGE, !dim); } SetMenuBarAttribute (m, K213MENUS_FILE_LOAD, ATTR_DIMMED, dim); } k213_CheckforProblems (my_dev); active_panel = GetActivePanel(); control = GetActiveCtrl (active_panel); for (port = 0; port < 4; port++) { if (util_TakingData() || (control != K213PORT_DISPLAY)) SetCtrlVal (quadsrc->port[port].panel, K213PORT_DISPLAY, quadsrc->port[port].src->acqchan->reading); } }
void OperateSR844 (int menubar, int menuItem, void *callbackData, int panel) { int p, m; gpibioPtr dev = callbackData; sr844Ptr lia = dev->device; char label[256]; SetMenuBarAttribute (menubar, menuItem, ATTR_DIMMED, TRUE); p = dev->iPanel? dev->iPanel: LoadPanel (utilG.p, "sr844u.uir", SR844_CTRL); dev->iPanel = p; SetPanelPos (p, VAL_AUTO_CENTER, VAL_AUTO_CENTER); Fmt (label, "stanford research systems sr844 dsp lock-in amplifier: %s", dev->label); SetPanelAttribute (p, ATTR_TITLE, label); m = LoadMenuBar (p, "sr844u.uir", SR844MENU); SetPanelMenuBar (p, m); SetMenuBarAttribute (m, SR844MENU_SOURCES_DAC1, ATTR_CALLBACK_DATA, lia->sources[0]); SetMenuBarAttribute (m, SR844MENU_SOURCES_DAC2, ATTR_CALLBACK_DATA, lia->sources[1]); SetMenuBarAttribute (m, SR844MENU_SOURCES_FREQ, ATTR_CALLBACK_DATA, lia->sources[2]); SetMenuBarAttribute (m, SR844MENU_MEASURE_LIA, ATTR_CALLBACK_DATA, lia); SetMenuBarAttribute (m, SR844MENU_MEASURE_ADCS, ATTR_CALLBACK_DATA, dev); SetPanelAttribute (p, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, SR844_CTRL_REF, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, SR844_CTRL_TC, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, SR844_CTRL_SENS, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, SR844_CTRL_AUTOSENSE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, SR844_CTRL_FILTSLOPE, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (p, SR844_CTRL_1MO50O, ATTR_CALLBACK_DATA, dev); SetCtrlVal(p, SR844_CTRL_GPIBADDR, dev->paddr); sr844_UpdateControls (p, dev); ///*/ devPanel_Add (p, dev, sr844_UpdateReadings);//*/ DisplayPanel (p); }
void usb1208lsOperate (int menubar, int menuItem, void *callbackData, int panel) { MCCdevPtr dev = callbackData; usb1208lsPtr pmd = dev->device; acqchanPtr acqchan; int i, x = 0, m; if(!pmd->panel) { pmd->panel = LoadPanel(utilG.p, "USB-1208LSu.uir", USB1208LS); pmd->menu = LoadMenuBar(pmd->panel, "USB-1208LSu.uir", USBMENU); SetPanelMenuBar(pmd->panel, pmd->menu); for(i = 0; i < 4; i ++) { SetMenuBarAttribute (pmd->menu, pmd->aiPorts[i]->menuitem_id, ATTR_CALLBACK_DATA, pmd->aiPorts[i]); SetMenuBarAttribute (pmd->menu, pmd->aiPorts[i]->menuitem_id, ATTR_ITEM_NAME, pmd->aiPorts[i]->port.analogueIOport.IO.acqchan->channel->label); SetMenuBarAttribute (pmd->menu, pmd->aiPorts[i]->menuitem_id, ATTR_CHECKED, pmd->aiPorts[i]->port.analogueIOport.IO.acqchan->acquire); } SetMenuBarAttribute (pmd->menu, USBMENU_SOURCE_DAC1, ATTR_CALLBACK_DATA, pmd->aoPorts[0]->port.analogueIOport.IO.source); SetMenuBarAttribute (pmd->menu, USBMENU_SOURCE_DAC2, ATTR_CALLBACK_DATA, pmd->aoPorts[1]->port.analogueIOport.IO.source); SetMenuBarAttribute (pmd->menu, USBMENU_SOURCE_DAC3, ATTR_CALLBACK_DATA, pmd->aoPorts[2]->port.analogueIOport.IO.source); SetMenuBarAttribute (pmd->menu, USBMENU_SOURCE_DAC4, ATTR_CALLBACK_DATA, pmd->doPort); SetMenuBarAttribute (pmd->menu, USBMENU_SOURCE_DAC1, ATTR_ITEM_NAME, pmd->aoPorts[0]->port.analogueIOport.IO.source->acqchan->channel->label); SetMenuBarAttribute (pmd->menu, USBMENU_SOURCE_DAC2, ATTR_ITEM_NAME, pmd->aoPorts[1]->port.analogueIOport.IO.source->acqchan->channel->label); SetMenuBarAttribute (pmd->menu, USBMENU_SOURCE_DAC3, ATTR_ITEM_NAME, pmd->aoPorts[2]->port.analogueIOport.IO.source->acqchan->channel->label); SetMenuBarAttribute (pmd->menu, USBMENU_FILE_SAVE, ATTR_CALLBACK_DATA, dev); SetMenuBarAttribute (pmd->menu, USBMENU_FILE_LOAD, ATTR_CALLBACK_DATA, dev); SetCtrlAttribute (pmd->panel, USB1208LS_RANGE, ATTR_DIMMED, 1); SetCtrlAttribute (pmd->panel, USB1208LS_ACQ, ATTR_DIMMED, 1); /*SetCtrlAttribute (pmd->panel, USB1208LS_DIGITAL_OUT_0, ATTR_CALLBACK_DATA, pmd->doPort); SetCtrlAttribute (pmd->panel, USB1208LS_DIGITAL_OUT_1, ATTR_CALLBACK_DATA, pmd->doPort); SetCtrlAttribute (pmd->panel, USB1208LS_DIGITAL_OUT_2, ATTR_CALLBACK_DATA, pmd->doPort); SetCtrlAttribute (pmd->panel, USB1208LS_DIGITAL_OUT_3, ATTR_CALLBACK_DATA, pmd->doPort); SetCtrlAttribute (pmd->panel, USB1208LS_DIGITAL_OUT_4, ATTR_CALLBACK_DATA, pmd->doPort); SetCtrlAttribute (pmd->panel, USB1208LS_DIGITAL_OUT_5, ATTR_CALLBACK_DATA, pmd->doPort);*/ SetCtrlAttribute (pmd->panel, USB1208LS_INPUT, ATTR_CALLBACK_DATA, pmd->aiPorts[0]); SetPanelAttribute (pmd->panel, ATTR_CALLBACK_DATA, pmd); } SetMenuBarAttribute(menubar, menuItem, ATTR_DIMMED, 1); devPanel_Add (pmd->panel, dev, usb1208ls_UpdateReadings); DisplayPanel(pmd->panel); }
int usb1208ls_ControlCallback (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { portPtr port = callbackData; switch (control) { case USB1208LS_RANGE: if(event == EVENT_COMMIT && port) GetCtrlVal(panel, control, &port->port.analogueIOport.range); break; case USB1208LS_INPUT: if(event == EVENT_COMMIT && port) { int i; MCCdevPtr dev = port->port.analogueIOport.IO.acqchan->dev; usb1208lsPtr pmd = dev->device; GetCtrlVal(panel, control, &i); port->control = 0; if(i != -1) { pmd->aiPorts[i]->control = control; SetCtrlAttribute (panel, control, ATTR_CALLBACK_DATA, pmd->aiPorts[i]); SetCtrlAttribute (panel, USB1208LS_RANGE, ATTR_CALLBACK_DATA, pmd->aiPorts[i]); SetCtrlAttribute (panel, USB1208LS_ACQ, ATTR_CALLBACK_DATA, pmd->aiPorts[i]); SetCtrlAttribute (panel, USB1208LS_AVERAGE, ATTR_CALLBACK_DATA, pmd->aiPorts[i]); SetCtrlVal (panel, USB1208LS_AVERAGE, pmd->aiPorts[i]->averaging); SetCtrlIndex (panel, USB1208LS_RANGE, usb1208ls_IndexFromRange(pmd->aiPorts[i]->port.analogueIOport.range)); SetCtrlVal (panel, USB1208LS_ACQ, pmd->aiPorts[i]->port.analogueIOport.IO.acqchan->acquire); } SetCtrlAttribute (panel, USB1208LS_RANGE, ATTR_DIMMED, (i == -1)); SetCtrlAttribute (panel, USB1208LS_ACQ, ATTR_DIMMED, (i == -1)); if(i == -1)SetCtrlVal (panel, USB1208LS_ACQ, 0); } break; case USB1208LS_ACQ: if(event == EVENT_COMMIT && port && utilG.acq.status != ACQ_BUSY) { int i; MCCdevPtr dev = port->port.analogueIOport.IO.acqchan->dev; usb1208lsPtr pmd = dev->device; GetCtrlIndex (panel, USB1208LS_INPUT, &i); if(i) { GetCtrlVal (panel, control, &port->port.analogueIOport.IO.acqchan->acquire); if (port->port.analogueIOport.IO.acqchan->acquire) acqchanlist_AddChannel(port->port.analogueIOport.IO.acqchan); else acqchanlist_RemoveChannel(port->port.analogueIOport.IO.acqchan); SetMenuBarAttribute (pmd->menu, port->menuitem_id, ATTR_CHECKED, port->port.analogueIOport.IO.acqchan->acquire); } } else if(event == EVENT_COMMIT && utilG.acq.status == ACQ_BUSY) SetCtrlVal (panel, control, port->port.analogueIOport.IO.acqchan->acquire); break; /*case USB1208LS_DIGITAL_OUT_0: case USB1208LS_DIGITAL_OUT_1: case USB1208LS_DIGITAL_OUT_2: case USB1208LS_DIGITAL_OUT_3: case USB1208LS_DIGITAL_OUT_4: case USB1208LS_DIGITAL_OUT_5: if(event == EVENT_COMMIT && port) { MCCdevPtr dev = port->port.digitalIOport.IO.source->acqchan->dev; usb1208lsPtr pmd = dev->device; GetCtrlVal (panel, USB1208LS_DIGITAL_OUT_0, &pmd->bits[0]); GetCtrlVal (panel, USB1208LS_DIGITAL_OUT_1, &pmd->bits[1]); GetCtrlVal (panel, USB1208LS_DIGITAL_OUT_2, &pmd->bits[2]); GetCtrlVal (panel, USB1208LS_DIGITAL_OUT_3, &pmd->bits[3]); GetCtrlVal (panel, USB1208LS_DIGITAL_OUT_4, &pmd->bits[4]); GetCtrlVal (panel, USB1208LS_DIGITAL_OUT_5, &pmd->bits[5]); pmd->bits[1] *= 2; pmd->bits[2] *= 4; pmd->bits[3] *= 8; pmd->bits[4] *= 16; pmd->bits[5] *= 32; port->port.digitalIOport.IO.source->biaslevel = pmd->bits[0] + pmd->bits[1] + pmd->bits[2] + pmd->bits[3] + pmd->bits[4] + pmd->bits[5]; port->port.digitalIOport.IO.source->SetLevel(port->port.digitalIOport.IO.source); } break;*/ case USB1208LS_AVERAGE: if(event == EVENT_COMMIT && port) GetCtrlVal (panel, control, &port->averaging); break; } if (event == EVENT_COMMIT && port) usb1208ls_UpdateMeasurePanel(port); return 0; }
//--------------------------------------------------------- // работа с ЦАП //--------------------------------------------------------- int DacPanel(void) { int Pnl; int i, j, key, hnd, cnt; static int SignalType=0; char *UirName="demo.uir"; char *SignalTypeName[]= { {"Постоянный"}, {"Синус"}, {"Меандр"}, {"Пила"}, {"Треугольный"} }; // Загрузим панель Pnl=LoadPanel(UirName, DACPARAM); InitDac(Pnl); // покажем название платы в заголовке панели ShowNameInTitle(Pnl); SetCtrlVal(Pnl, P(BOX), "В данном примере программа по клавише 'СТАРТ ЦАП' \nзапускает ЦАП с заданными параметрами."); SetCtrlVal(Pnl, P(DAC_NUMBER), DAC_Number); SetCtrlVal(Pnl, P(DAC_RATE), DAC_Rate); SetCtrlVal(Pnl, P(SIGNAL_TYPE), SignalType); SetCtrlVal(Pnl, P(AMPLITUDE), Amplitude); { double FREQ=DAC_Rate/(double)DacFifoLength; if(Frequency/FREQ < 0.5) Frequency=FREQ; else Frequency=FREQ*(int)((Frequency/FREQ)+0.5); } SetCtrlVal(Pnl, P(FREQUENCY), Frequency); // Отобразим панель на экpане дисплея DisplayPanel(Pnl); KeyFlag=0; for(key=0; !key;) { if(KeyFlag) { KeyFlag=0; if(KeyCode == 0x1B) { *KeybPtr1 = *KeybPtr2; if(ConfirmPopup("Вы желаете выйти?")) { UnloadPanel(Pnl); return EXIT; } KeyFlag=0; } } GetUserEvent(0, &hnd, &cnt); // Выбpан пункт меню if(hnd==Bar) { if(cnt!=-1) { switch(cnt) { case B(ADC): { int result=AdcParamPanel(); if(result == DISK_PANEL) { UnloadPanel(Pnl); return DISK_PANEL; } else if(result == INPUT_PANEL) { UnloadPanel(Pnl); return INPUT_PANEL; } break; } case B(DAC): break; case B(TTL): UnloadPanel(Pnl); return TTL_PANEL; case B(QUIT): if(ConfirmPopup("Вы желаете выйти?")) { UnloadPanel(Pnl); return EXIT; } } } } // Выбpана опция на панели if(hnd == Pnl) { switch(cnt) { case P(START): { char str[200]; // запретим работу ЦАП if(!ENABLE_DAC_STREAM_PLX(&bi[0], 0)) { SetCtrlVal(Pnl, P(BOX), " Не выполнена функция ENABLE_DAC_STREAM_PLX()!"); SetMenuBarAttribute(B(DAC), ATTR_MENU_BAR_ENABLED, DISABLE); SetCtrlAttribute(Pnl, P(START), ATTR_CTRL_ENABLED, DISABLE); break; } // сформируем данные для буфера ЦАП MakeDacBuffer(SignalType); // положим сформированные данные в память программ DSP в буфер ЦАП PUT_PM_ARRAY_PLX(&bi[0], DacFifoBaseAddress, 2*DacFifoLength, Buffer); // разрешим работу ЦАП if(!ENABLE_DAC_STREAM_PLX(&bi[0], 1)) { SetCtrlVal(Pnl, P(BOX), " Не выполнена функция ENABLE_DAC_STREAM_PLX()!"); SetMenuBarAttribute(B(DAC), ATTR_MENU_BAR_ENABLED, DISABLE); SetCtrlAttribute(Pnl, P(START), ATTR_CTRL_ENABLED, DISABLE); break; } DefaultCtrl(Pnl, P(BOX)); sprintf(str, " Осуществлен запуск ЦАП.\n Сейчас ны выходном разъеме должен наблюдаться\n следующий тип сигнала - '%s'.", SignalTypeName[SignalType]); SetCtrlVal(Pnl, P(BOX), str); break; } case P(DAC_NUMBER): { char str[100]; GetCtrlVal(Pnl, P(DAC_NUMBER), &DAC_Number); sprintf(str, " Выбран ЦАП номер %1u.", DAC_Number+1); SetCtrlVal(Pnl, P(BOX), str); break; } case P(DAC_RATE): { char str[100]; GetCtrlVal(Pnl, P(DAC_RATE), &DAC_Rate); SET_DAC_RATE_PLX(&bi[0], &DAC_Rate); SetCtrlVal(Pnl, P(DAC_RATE), DAC_Rate); sprintf(str, " Частота работы ЦАП установлена %.3f кГц.", DAC_Rate); SetCtrlVal(Pnl, P(BOX), str); //изменилась и частоты выдаваемого сигнала double FREQ=DAC_Rate/(double)DacFifoLength; if(Frequency/FREQ < 0.5) Frequency=FREQ; else Frequency=FREQ*(int)((Frequency/FREQ)+0.5); SetCtrlVal(Pnl, P(FREQUENCY), Frequency); break; } case P(AMPLITUDE): { char str[100]; GetCtrlVal(Pnl, P(AMPLITUDE), &Amplitude); if(Amplitude > 2047) Amplitude=2047; else if(Amplitude < -2047) Amplitude=-2047; SetCtrlVal(Pnl, P(AMPLITUDE), Amplitude); sprintf(str, " Амплитуда сигнала равна %5i кодов ЦАП.", Amplitude); SetCtrlVal(Pnl, P(BOX), str); break; } case P(FREQUENCY): { char str[100]; GetCtrlVal(Pnl, P(FREQUENCY), &Frequency); Frequency=fabs(Frequency); double FREQ=DAC_Rate/(double)DacFifoLength; if(Frequency/FREQ < 0.5) Frequency=FREQ; else Frequency=FREQ*(int)((Frequency/FREQ)+0.5); SetCtrlVal(Pnl, P(FREQUENCY), Frequency); sprintf(str, " Частота выходного сигнала равна %.3f кГц.", Frequency); SetCtrlVal(Pnl, P(BOX), str); break; } case P(SIGNAL_TYPE): { char str[100]; GetCtrlVal(Pnl, P(SIGNAL_TYPE), &SignalType); sprintf(str, " Тип выходного сигнала - '%s'.", SignalTypeName[SignalType]); SetCtrlVal(Pnl, P(BOX), str); break; } } } } UnloadPanel(Pnl); return EXIT; }