Пример #1
0
        private void LMMMAsyncFileCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);

            modified |= (l.NetComm.UseAsynchFileIO != ((CheckBox)sender).Checked);
            l.NetComm.UseAsynchFileIO = ((CheckBox)sender).Checked;
        }
Пример #2
0
        private void LMMMStreamCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);

            modified |= (l.NetComm.UsingStreamRawAnalysis != ((CheckBox)sender).Checked);
            l.NetComm.UsingStreamRawAnalysis = ((CheckBox)sender).Checked;
        }
Пример #3
0
        private void check_HV_set_CheckedChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            // int tolerance = l.DeviceConfig.LLD;
            // int to = l.DeviceConfig.HVTimeout;
            int disabled = l.DeviceConfig.LEDs;

            if (((CheckBox)sender).Checked == true)
            {
                //l.DeviceConfig.HVTimeout = 0;
                l.DeviceConfig.LEDs = 2;
                //l.DeviceConfig.LLD = 0;
                VoltageTolerance.Enabled  = false;
                VoltageTolerance.ReadOnly = true;
                VoltageTimeout.Enabled    = false;
                VoltageTimeout.ReadOnly   = true;
            }
            else
            {
                VoltageTolerance.Enabled  = true;
                VoltageTolerance.ReadOnly = false;
                VoltageTimeout.Enabled    = true;
                VoltageTimeout.ReadOnly   = false;
                l.DeviceConfig.LEDs       = 1;
                //l.DeviceConfig.HVTimeout = 0;
                //l.DeviceConfig.LLD = 1;
                // Int32.TryParse(VoltageTolerance.Text, out tolerance);
                // This is a hack for the moment, just a place to store our definable tolerance hn 2.3.3015
                // l.DeviceConfig.LLD = tolerance;
            }
            modified = /* to != l.DeviceConfig.HVTimeout || tolerance != l.DeviceConfig.LLD || */
                       disabled != l.DeviceConfig.LEDs;
        }
Пример #4
0
        private void LMMMBroadcastCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);

            modified           |= (l.NetComm.Broadcast != ((CheckBox)sender).Checked);
            l.NetComm.Broadcast = !((CheckBox)sender).Checked;
        }
Пример #5
0
        private void LMMMLEDs_CheckedChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int val            = ((CheckBox)sender).Checked ? 2 : 1; // the 1 and 2 must be an LMMM-specific detail

            modified           |= (l.DeviceConfig.LEDs != val);
            l.DeviceConfig.LEDs = val;
        }
Пример #6
0
        private void LMMMDebugFlag_CheckedChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int val            = ((CheckBox)sender).Checked ? 1 : 0;

            modified            |= (l.DeviceConfig.Debug != val);
            l.DeviceConfig.Debug = val;
        }
Пример #7
0
        private void LMMMHV_Leave(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int i = l.DeviceConfig.HV;

            modified |= Format.ToNZInt(((TextBox)sender).Text, ref i);
            if (modified)
            {
                l.DeviceConfig.HV = i;
            }
        }
Пример #8
0
        private void VoltageTolerance_Leave(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int i = l.DeviceConfig.LLD;

            modified |= Format.ToNZInt(((TextBox)sender).Text, ref i);
            if (modified)
            {
                l.DeviceConfig.LLD = i;
            }
        }
Пример #9
0
        private void LMMMEventBufferTextBox_Leave(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            uint             i = l.NetComm.ParseBufferSize;

            modified |= Format.ToNN(((TextBox)sender).Text, ref i);
            if (modified)
            {
                l.NetComm.ParseBufferSize = i;
            }
        }
Пример #10
0
        private void LMMMConnectionsTextBox_Leave(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int i = l.NetComm.NumConnections;

            modified |= Format.ToInt(((TextBox)sender).Text, ref i);
            if (modified)
            {
                l.NetComm.NumConnections = i;
            }
        }
Пример #11
0
        private void LMMMInModeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int i = l.DeviceConfig.Input;

            if (((ComboBox)sender).SelectedIndex != i)
            {
                l.DeviceConfig.Input = ((ComboBox)sender).SelectedIndex;
                modified            |= true;
            }
        }
Пример #12
0
        private void LMMMRemotePortTextBox_Leave(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int i = l.NetComm.LMListeningPort;

            modified |= Format.ToInt(((TextBox)sender).Text, ref i);
            if (modified)
            {
                l.NetComm.LMListeningPort = i;
            }
        }
Пример #13
0
        private void LMMMSubnetTextBox_Leave(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            String           s = l.NetComm.Subnet;

            modified |= Format.Changed(((TextBox)sender).Text, ref s);
            if (modified)
            {
                l.NetComm.Subnet = s;
            }
        }
Пример #14
0
        // Depending on the shift register type for d, fill in the fields in the appropriate panel and make it visible.
        private void PopulateParamFields()
        {
            if (det != null)
            {
                if (det.Id.SRType == InstrType.LMMM)
                {    // Fill edit panel fields
                    // LMNetComm
                    LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
                    LMMMSubnetTextBox.Text        = l.NetComm.Subnet;
                    LMMMLocalPortTextBox.Text     = l.NetComm.Port.ToString();
                    LMMMRemotePortTextBox.Text    = l.NetComm.LMListeningPort.ToString();
                    LMMMDiscWaitTimeTextBox.Text  = l.NetComm.Wait.ToString();
                    LMMMBroadcastCheckBox.Checked = l.NetComm.Broadcast;

                    LMMMConnectionsTextBox.Text      = l.NetComm.NumConnections.ToString();
                    LMMMBufferTextBox.Text           = l.NetComm.ReceiveBufferSize.ToString();
                    LMMMEventBufferTextBox.Text      = l.NetComm.ParseBufferSize.ToString();
                    LMMMStreamCheckBox.Checked       = l.NetComm.UsingStreamRawAnalysis;
                    LMMMAsyncFileCheckBox.Checked    = l.NetComm.UseAsynchFileIO;
                    LMMMSyncAnalysisCheckBox.Checked = !l.NetComm.UseAsynchAnalysis;

                    // LMHWConfig
                    LMMMInModeComboBox.SelectedIndex = l.DeviceConfig.Input;  // 0 is ribbon, 1 is TTL
                    LMMMDebugFlag.Checked            = (l.DeviceConfig.Debug == 1 ? true : false);
                    LMMMHV.Text      = l.DeviceConfig.HV.ToString();
                    LMMMLEDs.Checked = (l.DeviceConfig.LEDs == 2 ? true : false);
                    LMMMLLDmV.Text   = l.DeviceConfig.LLD.ToString();

                    LMMMIntervalTextBox.Text         = acq.lm.Separation.ToString();
                    LMMMFeedbackFlagCheckBox.Checked = acq.lm.Feedback;

                    // Make edit panel visible
                    this.LMMMPanel.Visible = true;
                }
                else if (det.Id.SRType == InstrType.PTR32)
                {
                    this.PTR32Panel.Visible = true;
                    this.PTR32Id.Text       = String.Copy(det.Id.DetectorId);
                    //Warning: hack attack.  using extra fields here to store hv enabling and tolerance hn 2.3.2015
                    // OK, was logic error.  Checked box means HV disabled..... fixed.  hn 5.19.2015
                    LMConnectionInfo lmi = (LMConnectionInfo)(det.Id.FullConnInfo);
                    check_HV_set.Checked     = lmi.DeviceConfig.LEDs == 2 ? true : false;
                    VoltageTimeout.Visible   = true;
                    VoltageTimeout.Text      = lmi.DeviceConfig.HVTimeout.ToString();
                    VoltageTolerance.Text    = lmi.DeviceConfig.LLD.ToString();
                    VoltageTolerance.Visible = true;
                }
                else if (det.Id.SRType == InstrType.NILA)
                {
                    this.PTR32Panel.Visible = true;
                }
            }
        }
Пример #15
0
        public void ApplyInstrumentSettings()
        {
            foreach (Instrument instrument in Instruments.Active)
            {
                try
                {
                    instrument.ApplySettings();
                }
                catch (Exception ex)
                {
                    collog.TraceException(ex);
                }
            }

            // for now, this is for the LMs only
            if (!Instruments.Active.HasConnectedLM())
            {
                return;
            }

            LMInstrument     lm  = (LMInstrument)Instruments.Active.AConnectedLM();
            LMConnectionInfo lmc = (LMConnectionInfo)lm.id.FullConnInfo;

            if (lm.id.SRType == InstrType.LMMM)             // it's an LMMM
            {
                // look for any flags requiring conditioning of the instrument prior to assay or HV
                // e.g. input=0, the arg to each is already parsed in the command line processing state
                //if (NC.App.Config.LMMM.isSet(LMFlags.input))
                {
                    DAQControl.LMMMComm.FormatAndSendLMMMCommand(LMMMLingo.Tokens.input, lmc.DeviceConfig.Input);
                }
                //if (NC.App.Config.LMMM.isSet(LMFlags.debug))
                {
                    DAQControl.LMMMComm.FormatAndSendLMMMCommand(LMMMLingo.Tokens.debug, lmc.DeviceConfig.Debug);
                }
                //if (NC.App.Config.LMMM.isSet(LMFlags.leds))
                {
                    DAQControl.LMMMComm.FormatAndSendLMMMCommand(LMMMLingo.Tokens.leds, lmc.DeviceConfig.LEDs);
                }
                //if (NC.App.Config.LMMM.isSet(LMFlags.hv))
                {
                    DAQControl.LMMMComm.FormatAndSendLMMMCommand(LMMMLingo.Tokens.hvset, lmc.DeviceConfig.HV);
                }
            }
            else if (lm.id.SRType == InstrType.PTR32)               // its a PTR-32
            {
            }
            else if (lm.id.SRType == InstrType.MCA527)
            {
            }
        }
Пример #16
0
        public LMConnectionInfo LastBestConnInfo()
        {
            DB.LMNetCommParams gray = new DB.LMNetCommParams();
            DataTable          dt   = gray.GetComms();
            LMConnectionInfo   lm   = new LMConnectionInfo();

            if (dt.Rows.Count < 1)
            {
                return(lm);
            }
            DataRow drl = dt.Rows[dt.Rows.Count - 1];

            lm.NetComm.Broadcast       = DB.Utils.DBBool(drl["broadcast"]);
            lm.NetComm.LMListeningPort = DB.Utils.DBInt32(drl["broadcastport"]);
            lm.NetComm.Port            = DB.Utils.DBInt32(drl["port"]);
            lm.NetComm.Subnet          = (string)(drl["subnet"]);
            lm.NetComm.Wait            = DB.Utils.DBInt32(drl["wait"]);

            lm.NetComm.NumConnections         = DB.Utils.DBInt32(drl["numConnections"]);
            lm.NetComm.ReceiveBufferSize      = DB.Utils.DBInt32(drl["receiveBufferSize"]);
            lm.NetComm.ParseBufferSize        = DB.Utils.DBUInt32(drl["parseBufferSize"]);
            lm.NetComm.UseAsynchAnalysis      = DB.Utils.DBBool(drl["useAsyncAnalysis"]);
            lm.NetComm.UseAsynchFileIO        = DB.Utils.DBBool(drl["useAsyncFileIO"]);
            lm.NetComm.UsingStreamRawAnalysis = DB.Utils.DBBool(drl["streamRawAnalysis"]);

            dt = gray.GetHW();
            if (dt.Rows.Count < 1)
            {
                return(lm);
            }
            drl = dt.Rows[dt.Rows.Count - 1];
            lm.DeviceConfig.LEDs  = DB.Utils.DBInt32(drl["leds"]);
            lm.DeviceConfig.HV    = DB.Utils.DBInt32(drl["hv"]);
            lm.DeviceConfig.LLD   = DB.Utils.DBInt32(drl["LLD"]); // alias for VoltageTolerance on PTR32 and MCA527
            lm.DeviceConfig.Debug = DB.Utils.DBInt32(drl["debug"]);
            lm.DeviceConfig.Input = DB.Utils.DBInt32(drl["input"]);
            try {
                lm.DeviceConfig.HVTimeout = DB.Utils.DBInt32(drl["hvtimeout"]);
            } catch (Exception) { }
            return(lm);
        }
Пример #17
0
        private void PopulateMCA527ParamFields()
        {
            if (det != null && det.Id.SRType == InstrType.MCA527)
            {
                PTR32Panel.Visible   = true;
                MCANameLabel.Visible = MCAName.Visible = true;
                MCAName.Text         = string.Copy(det.Id.DetectorId);
                ConnIdField.Text     = string.Copy(det.Id.ElectronicsId);
                connIdLabel.Text     = "MCA-527 serial number: ";
                connLabel.Text       = "MCA-527 Connection Parameters";
                LoadtheMCACombobox();


                LMConnectionInfo lmi = (LMConnectionInfo)(det.Id.FullConnInfo);
                check_HV_set.Checked     = lmi.DeviceConfig.LEDs == 2 ? true : false;
                VoltageTimeout.Visible   = true;
                VoltageTimeout.Text      = lmi.DeviceConfig.HVTimeout.ToString();
                VoltageTolerance.Text    = lmi.DeviceConfig.VoltageTolerance.ToString();
                VoltageTolerance.Visible = true;
            }
        }
Пример #18
0
        /// <summary>
        ///
        /// </summary>
        internal void StartLMDAQServer(LMConnectionInfo lmc = null)
        {
            if (_SL == null)
            {
                LMMMNetComm lmn;
                if (lmc == null)
                {
                    // get the one associated with selected current detector, and if not available, then get the last one used
                    Detector det = IntegrationHelpers.GetCurrentAcquireDetector();
                    if (det.Id.SRType.IsSocketBasedLM())
                    {
                        lmc = (DetectorDefs.LMConnectionInfo)det.Id.FullConnInfo;
                    }
                    else
                    {
                        lmc = NC.App.LMBD.LastBestConnInfo();
                    }
                }
                lmn = lmc.NetComm;

                _SL                  = new Server(lmn.Port, lmn.NumConnections, lmn.ReceiveBufferSize, lmn.subnetip);
                _SL.Logger           = collog;
                LMMMComm.LMServer    = _SL; // server root visible to COMM class
                _SL.clientConnected += SL_ClientConnected;
                _SL.DataReceived    += SL_DataReceived;
            }

            if (_SL.IsRunning)
            {
                ctrllog.TraceEvent(LogLevels.Verbose, 123, "The LM DAQ Server is already running");
                return;
            }
            else
            {
                _SL.Start();
            }

            CurState.State = DAQInstrState.Offline;
        }
Пример #19
0
        List <string> GenDetIdStr(DataSourceIdentifier dsid)
        {
            List <string> ls = new List <string>();

            ls.Add(string.Format("{0,10}: {1}", "Name", dsid.DetectorId));
            if (dsid.SRType.IsListMode())
            {
                ls.Add(string.Format("{0,10}: {1}", "LM type", dsid.SRType.ToString()));
            }
            else
            {
                ls.Add(string.Format("{0,10}: {1}", "SR type", dsid.SRType.INCC5ComboBoxString()));
            }
            ls.Add(string.Format("{0,10}: {1}", "User type", dsid.Type));
            ls.Add(string.Format("{0,10}: {1}", "Elec. id", dsid.ElectronicsId));
            if (dsid.SRType.IsCOMPortBasedSR())
            {
                ls.Add(string.Format("{0,10}: {1}", "Baud rate", dsid.BaudRate));
            }
            ls.Add(string.Format("{0,10}: {1}", "Data src", dsid.source.HappyFunName()));
            if (dsid.SRType.IsListMode())
            {
                LMConnectionInfo lm = (LMConnectionInfo)dsid.FullConnInfo;                 // todo: finish this
                //lm.NetComm and
                //lm.DeviceConfig
                //ls.Add(string.Format("{0,10}: {1}", "Port", lm.NetComm.));
                //ls.Add(string.Format("{0,10}: {1}", "Port", dsid.FullConnInfo.Port));
            }
            if (!string.IsNullOrEmpty(dsid.FullConnInfo.Port))
            {
                ls.Add(string.Format("{0,10}: {1}", "COM port", dsid.FullConnInfo.Port));
            }
            if (dsid.FullConnInfo.Wait != 0)
            {
                ls.Add(string.Format("{0,10}: {1}", "Wait", dsid.FullConnInfo.Wait) + " mSec");
            }

            return(ls);
        }
Пример #20
0
        private void check_HV_set_CheckedChanged(object sender, EventArgs e)
        {
            LMConnectionInfo l = (LMConnectionInfo)(det.Id.FullConnInfo);
            int disabled       = l.DeviceConfig.LEDs;

            if (((CheckBox)sender).Checked == true)
            {
                l.DeviceConfig.LEDs       = 2;
                VoltageTolerance.Enabled  = false;
                VoltageTolerance.ReadOnly = true;
                VoltageTimeout.Enabled    = false;
                VoltageTimeout.ReadOnly   = true;
            }
            else
            {
                VoltageTolerance.Enabled  = true;
                VoltageTolerance.ReadOnly = false;
                VoltageTimeout.Enabled    = true;
                VoltageTimeout.ReadOnly   = false;
                l.DeviceConfig.LEDs       = 1;
            }
            modified = disabled != l.DeviceConfig.LEDs;
        }
Пример #21
0
        // UDP broadcast
        public bool PostLMMMCommand(LMMMLingo.Tokens cmd, bool terminator = false)
        {
            bool res = true;

            if (NC.App.AppContext.Emulate)
            { // look up OpDesc instance from map
                // dispatch to thrift based on cmd token
                LMMMLingo.OpDesc op = null;
                cmdprocessor.LookupOpDescriptor(cmd, ref op);
                DivertToEmulation(op, 0, -1);
            }
            else
            {
                try {
                    string cmds = cmdprocessor.ComposeCommandStrings(cmd, 0);
                    if (cmds.Length > 0)
                    {
                        LMConnectionInfo net = ((LMConnectionInfo)(NC.App.Opstate.Measurement.Detectors[0].Id.FullConnInfo));
                        // broadcast go message to all cfg.Net.Subnet addresses.    This is the instrument group.
                        Socket    s         = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                        IPAddress broadcast = IPAddress.Parse(net.NetComm.Subnet);
                        if (terminator)
                        {
                            cmds += LMMMLingo.eol;
                        }
                        Byte[] sendBuffer = Encoding.ASCII.GetBytes(cmds);

                        IPEndPoint ep = new IPEndPoint(broadcast, net.NetComm.LMListeningPort);
                        s.SendTo(sendBuffer, ep);
                        commlog.TraceEvent(LogLevels.Verbose, 361, "UDP send: '" + LMLoggers.LognLM.FlattenChars(cmds) + "'");
                    }
                }
                catch (ObjectDisposedException ex)
                {
                    commlog.TraceEvent(LogLevels.Error, 357, "LOST an instrument: " + ex.Message);
                }
            }
Пример #22
0
        public LMConnectionInfo LastBestConnInfo()
        {
            DB.LMNetCommParams gray = new DB.LMNetCommParams();
            DataTable dt = gray.GetComms();
            LMConnectionInfo lm = new LMConnectionInfo();
            if (dt.Rows.Count < 1)
                return lm;
            DataRow drl = dt.Rows[dt.Rows.Count - 1];

            lm.NetComm.Broadcast = DB.Utils.DBBool(drl["broadcast"]);
            lm.NetComm.LMListeningPort = DB.Utils.DBInt32(drl["broadcastport"]);
            lm.NetComm.Port = DB.Utils.DBInt32(drl["port"]);
            lm.NetComm.Subnet = (string)(drl["subnet"]);
            lm.NetComm.Wait = DB.Utils.DBInt32(drl["wait"]);

            lm.NetComm.NumConnections = DB.Utils.DBInt32(drl["numConnections"]);
            lm.NetComm.ReceiveBufferSize = DB.Utils.DBInt32(drl["receiveBufferSize"]);
            lm.NetComm.ParseBufferSize = DB.Utils.DBUInt32(drl["parseBufferSize"]);
            lm.NetComm.UseAsynchAnalysis = DB.Utils.DBBool(drl["useAsyncAnalysis"]);
            lm.NetComm.UseAsynchFileIO = DB.Utils.DBBool(drl["useAsyncFileIO"]);
            lm.NetComm.UsingStreamRawAnalysis = DB.Utils.DBBool(drl["streamRawAnalysis"]);

            dt = gray.GetHW(); 
            if (dt.Rows.Count < 1)
                return lm;
            drl = dt.Rows[dt.Rows.Count - 1];
            lm.DeviceConfig.LEDs = DB.Utils.DBInt32(drl["leds"]);
            lm.DeviceConfig.HV = DB.Utils.DBInt32(drl["hv"]);
            lm.DeviceConfig.LLD = DB.Utils.DBInt32(drl["LLD"]);
            lm.DeviceConfig.Debug = DB.Utils.DBInt32(drl["debug"]);
            lm.DeviceConfig.Input = DB.Utils.DBInt32(drl["input"]);
            try {
                lm.DeviceConfig.HVTimeout = DB.Utils.DBInt32(drl["hvtimeout"]);
            } catch (Exception) { }
           return lm;
        }
Пример #23
0
        // class to encode and support all commands to and from an LMMM and a client
        public LMMMLingo()
        {
            LMConnectionInfo lmci = NC.App.LMBD.LastBestConnInfo();

            CmdStringOpDescMap = new System.Collections.Hashtable();
            CmdStringOpDescMap.Add(Tokens.broadcast.ToString(), new OpDesc(Tokens.broadcast, true));                                                                                   //+ config with duration and separation and [master|slave]
            CmdStringOpDescMap.Add(Tokens.prep.ToString(), new OpDesc(Tokens.prep, false));                                                                                            // config with duration and separation and [master|slave]
            CmdStringOpDescMap.Add("a", new OpDesc(Tokens.arm, false));                                                                                                                // arm if asynch broadcast go
            CmdStringOpDescMap.Add(Tokens.arm.ToString(), new OpDesc(Tokens.arm, false));
            CmdStringOpDescMap.Add(Tokens.go.ToString(), new OpDesc(Tokens.go, false));                                                                                                // TCP/IP tell LMMM to go go go
            CmdStringOpDescMap.Add("start", new OpDesc(Tokens.assay, true));                                                                                                           // *** prep, [arm], go
            CmdStringOpDescMap.Add(Tokens.assay.ToString(), new OpDesc(Tokens.assay, true,
                                                                       new ConfigInt32Value(() => { int v = (int)NC.App.Opstate.Measurement.MeasurementId.MeasOption; return(v); }))); //+ start assay
            CmdStringOpDescMap.Add(Tokens.stop.ToString(), new OpDesc(Tokens.stop, true));                                                                                             //+ stop full assay
            CmdStringOpDescMap.Add(Tokens.cancel.ToString(), new OpDesc(Tokens.cancel, true));                                                                                         //+ stop current cycle

            CmdStringOpDescMap.Add(Tokens.lm.ToString(), new OpDesc(Tokens.lm, true,
                                                                    new ConfigInt32Value(() => { int r = NC.App.Opstate.Measurement.AcquireState.lm.LM; return(r); }))); //+ get or set context current LM #
            CmdStringOpDescMap.Add(Tokens.quit.ToString(), new OpDesc(Tokens.quit, true));                                                                               //+ quit console prompt
            CmdStringOpDescMap.Add(Tokens.help.ToString(), new OpDesc(Tokens.help, true));                                                                               //+ show console prompt help
            CmdStringOpDescMap.Add(Tokens.config.ToString(), new OpDesc(Tokens.config, true));                                                                           //+ show current loaded config settings

            CmdStringOpDescMap.Add(Tokens.exit.ToString(), new OpDesc(Tokens.exit, true));                                                                               //+ tell LMMM to exit linux apps, WTM
            CmdStringOpDescMap.Add(Tokens.leds.ToString(), new OpDesc(Tokens.leds, true,
                                                                      new ConfigInt32Value(() => { int v = lmci.DeviceConfig.LEDs; return(v); })));                      //+ set and get leds value
            CmdStringOpDescMap.Add(Tokens.debug.ToString(), new OpDesc(Tokens.debug, true,
                                                                       new ConfigInt32Value(() => { int v = lmci.DeviceConfig.Debug; return(v); })));                    //+ set debug value on LMMM
            CmdStringOpDescMap.Add(Tokens.cstatus.ToString(), new OpDesc(Tokens.cstatus, true));                                                                         //+ request cstatus, this is a response prefix too
            CmdStringOpDescMap.Add(Tokens.input.ToString(), new OpDesc(Tokens.input, true,
                                                                       new ConfigInt32Value(() => { int v = lmci.DeviceConfig.Input; return(v); })));                    //+ set input on LMMM
            CmdStringOpDescMap.Add(Tokens.lld.ToString(), new OpDesc(Tokens.lld, true,
                                                                     new ConfigInt32Value(() => { int v = lmci.DeviceConfig.LLD; return(v); })));                        //+ read/set LLD on NPOD
            CmdStringOpDescMap.Add(Tokens.rates.ToString(), new OpDesc(Tokens.rates, true));                                                                             //+ read rates on LMMM/NPOD
            CmdStringOpDescMap.Add(Tokens.power.ToString(), new OpDesc(Tokens.power, true));                                                                             //+ read power on NPOD
            CmdStringOpDescMap.Add(Tokens.hvset.ToString(), new OpDesc(Tokens.hvset, true,
                                                                       new ConfigInt32Value(() => { int v = lmci.DeviceConfig.HV; return(v); })));                       //+ set high voltage
            CmdStringOpDescMap.Add("hv", new OpDesc(Tokens.hvread, false));                                                                                              // read hv,  // this is a response prefix too
            CmdStringOpDescMap.Add(Tokens.hvread.ToString(), new OpDesc(Tokens.hvread, true));                                                                           //+ read hv
            CmdStringOpDescMap.Add(Tokens.hvprep.ToString(), new OpDesc(Tokens.hvprep, false));                                                                          // HV calib config with voltage and duration
            CmdStringOpDescMap.Add(Tokens.hvcalib.ToString(), new OpDesc(Tokens.hvcalib, true));                                                                         //do HV Calib op, response prefix too
            CmdStringOpDescMap.Add(Tokens.shutdown.ToString(), new OpDesc(Tokens.shutdown, true));                                                                       // todo: shutdown the test server

            // responses associated with the direct data collection
            CmdStringOpDescMap.Add("to sen", new OpDesc(Tokens.tosenddatasize, false));
            CmdStringOpDescMap.Add("unreco", new OpDesc(Tokens.unrecognizeddata, false));
            CmdStringOpDescMap.Add("status", new OpDesc(Tokens.statusdata, false));
            CmdStringOpDescMap.Add(".....", new OpDesc(Tokens.statusdata, false));      // 6th char is ' '  or '.'
            CmdStringOpDescMap.Add("lled. ", new OpDesc(Tokens.assaycancelled, false)); // 6th char is ' ', 'Assay Cancelled. '
            //CmdStringtoTokenMap.Add("*", Tokens.odddata);

            // for moving from token to op desc to test driver
            LMMMOpOpDescMap = new System.Collections.Hashtable();
            LMMMOpOpDescMap.Add(Tokens.broadcast, CmdStringOpDescMap[Tokens.broadcast.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.prep, CmdStringOpDescMap[Tokens.prep.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.arm, CmdStringOpDescMap[Tokens.arm.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.go, CmdStringOpDescMap[Tokens.go.ToString()]);
            //       LMMMOpOpStructMap.Add(Tokens.bgo, CmdStringOpStructMap["bgo"]);
            LMMMOpOpDescMap.Add(Tokens.cstatus, CmdStringOpDescMap[Tokens.cstatus.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.exit, CmdStringOpDescMap[Tokens.exit.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.debug, CmdStringOpDescMap[Tokens.debug.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.leds, CmdStringOpDescMap[Tokens.leds.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.input, CmdStringOpDescMap[Tokens.input.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.rates, CmdStringOpDescMap[Tokens.rates.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.lld, CmdStringOpDescMap[Tokens.lld.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.power, CmdStringOpDescMap[Tokens.power.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.shutdown, CmdStringOpDescMap[Tokens.shutdown.ToString()]); // todo: implement this op
            LMMMOpOpDescMap.Add(Tokens.cancel, CmdStringOpDescMap[Tokens.cancel.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.stop, CmdStringOpDescMap[Tokens.stop.ToString()]);
            // hv calib ops
            LMMMOpOpDescMap.Add(Tokens.hvread, CmdStringOpDescMap[Tokens.hvread.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.hvprep, CmdStringOpDescMap[Tokens.hvprep.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.hvcalib, CmdStringOpDescMap[Tokens.hvcalib.ToString()]);
            LMMMOpOpDescMap.Add(Tokens.hvset, CmdStringOpDescMap[Tokens.hvset.ToString()]);

            // base strings used to and from the LMMM
            LMMMOpStringMap = new System.Collections.Hashtable();
            LMMMOpStringMap.Add(Tokens.broadcast, "NDAC Control");
            LMMMOpStringMap.Add(Tokens.prep, "Duration = {0}" + eol + "Separation = {1}");
            LMMMOpStringMap.Add(Tokens.arm, "Arm");
            LMMMOpStringMap.Add(Tokens.go, "Go");
            LMMMOpStringMap.Add(Tokens.assay, "***"); // chain of actions: loop of these strings, ["master\r\n"|"slave\r\n"][Feedback = 1\r\n"]"Duration = {0}\r\n";Separation = {1}\r\n"; followed by optional Arm, then Go
            LMMMOpStringMap.Add(Tokens.cancel, "Cancel");
            LMMMOpStringMap.Add(Tokens.quit, "**");   // shell command
            LMMMOpStringMap.Add(Tokens.exit, "Exit");
            LMMMOpStringMap.Add(Tokens.lm, "**");     // shell command
            LMMMOpStringMap.Add(Tokens.leds, "Leds");
            LMMMOpStringMap.Add(Tokens.lld, "LLD");
            LMMMOpStringMap.Add(Tokens.cstatus, "cStatus");  // response prefix as well
            LMMMOpStringMap.Add(Tokens.input, "input");
            LMMMOpStringMap.Add(Tokens.debug, "Debug");
            LMMMOpStringMap.Add(Tokens.rates, "Rates");
            LMMMOpStringMap.Add(Tokens.power, "Power");
            LMMMOpStringMap.Add(Tokens.hvset, "HVset");                                 // HV single command set op, but see next line for the plateau prep command
            LMMMOpStringMap.Add(Tokens.hvprep, "HVset = {0}" + eol + "Duration = {1}"); // prep line
            LMMMOpStringMap.Add(Tokens.hvread, "HVread");
            LMMMOpStringMap.Add(Tokens.hvcalib, "HVcalib");                             // / request calibration status

            // yes this is hack for the six special response strings that need to be
            // matched during non-data processing response string parsing.
            NonDataResponses = new List <string>();
            NonDataResponses.Add(((string)LMMMOpStringMap[Tokens.cstatus]).ToLower());
            NonDataResponses.Add(((string)LMMMOpStringMap[Tokens.hvread]).ToLower());
            NonDataResponses.Add(((string)LMMMOpStringMap[Tokens.hvcalib]).ToLower());
            NonDataResponses.Add(((string)LMMMOpStringMap[Tokens.rates]).ToLower());
            NonDataResponses.Add(((string)LMMMOpStringMap[Tokens.power]).ToLower());
            NonDataResponses.Add(((string)LMMMOpStringMap[Tokens.lld]).ToLower());
        }
Пример #24
0
        /// <summary>
        ///
        /// </summary>
        internal void StartLMDAQServer(LMConnectionInfo lmc = null)
        {
            if (_SL == null)
            {
                LMMMNetComm lmn;
                if (lmc == null)
                {
                    // get the one associated with selected current detector, and if not available, then get the last one used
                    Detector det = IntegrationHelpers.GetCurrentAcquireDetector();
                    if (det.Id.SRType.IsSocketBasedLM())
                        lmc = (DetectorDefs.LMConnectionInfo)det.Id.FullConnInfo;
                    else
                        lmc = NC.App.LMBD.LastBestConnInfo();
                }
                lmn = lmc.NetComm;

                _SL = new Server(lmn.Port, lmn.NumConnections, lmn.ReceiveBufferSize, lmn.subnetip);
                _SL.Logger = collog;
                LMMMComm.LMServer = _SL;  // server root visible to COMM class
                _SL.clientConnected += SL_ClientConnected;
                _SL.DataReceived += SL_DataReceived;
            }

            if (_SL.IsRunning)
            {
                ctrllog.TraceEvent(LogLevels.Verbose, 123, "The LM DAQ Server is already running");
                return;
            }
            else
            {
                _SL.Start();
            }

            CurState.State = DAQInstrState.Offline;
        }