示例#1
0
 internal void LookupOpDescriptor(LMMMLingo.Tokens cmd, ref LMMMLingo.OpDesc op)
 {
     try
     {
         op = (LMMMLingo.OpDesc)LMMMOpOpDescMap[cmd];
     }
     catch (Exception e)
     {
         commlog.TraceEvent(LogLevels.Error, 888, "Unable to look up cmd in descriptor map:" + e.Message);
     }
 }
示例#2
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);
                }
            }