private void initButton_Click(object sender, EventArgs e) { try { mcInst[0] = new GPIBMotorMChromator(); mcInst[0].initVISASession(VisMCTextBox.Text); mcInst[0].deviceName = "VISmono"; mcInst[1] = new GPIBMotorMChromator(); mcInst[1].initVISASession(NIRMCTextBox.Text); mcInst[1].deviceName = "NIRmono"; LIAInst[0] = new lockInAmp(); LIAInst[0].initVISASession(MainLIATextBox.Text); } catch (System.ArgumentException) { deviceMessageBox.Text = "failed"; } }
private void loadSettingFromFile() { try { //Deserialization //Read device obejct information from the files GPIBMotorMChromator[] GMChromator = new GPIBMotorMChromator[2]; System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(GPIBMotorMChromator[])); System.IO.TextReader r = new System.IO.StreamReader("defaultMCSetting.xml"); GMChromator = (GPIBMotorMChromator[])s.Deserialize(r); r.Close(); mcInst[0] = GMChromator[0]; mcInst[1] = GMChromator[1]; mcInst[2] = new BenDLLMChromator(); s = new System.Xml.Serialization.XmlSerializer(typeof(lockInAmp[])); r = new System.IO.StreamReader("defaultLIASetting.xml"); LIAInst = (lockInAmp[])s.Deserialize(r); r.Close(); } catch (System.IO.FileNotFoundException e) { MessageBox.Show(e.FileName + " not found."); } catch (Exception) { MessageBox.Show("Initilize the object fails"); } }