コード例 #1
0
 /// <summary>
 /// Thread which extracts commands from commandsQueue queue and sends them to SP.
 /// </summary>
 private void outThread()
 {
     //An object to be sent (command).
     AltiLinkPlus.ALPCommand cmd       = null;
     Diacom.Cmd.CmdBase      spCommand = null;
     // While outThreadLivingStatus == true we should dequeue commands from outgoing queue and send them.
     while (outThreadLivingStatus)
     {
         try
         {
             // Getting next command and processing it.
             object obj = commandsQueue.Dequeue();
             // First try as a raw ALP command
             cmd = obj as AltiLinkPlus.ALPCommand;
             // If not ALP command - convert to
             if (cmd == null)
             {
                 spCommand = obj as Diacom.Cmd.CmdBase;
                 cmd       = ProcessCommand(spCommand);
             }
             // If not null then command is valid - sending it.
             if (cmd != null)
             {
                 // Creating new packet.
                 AltiLinkPlus.ALPPacket outThreadPacket = new AltiLinkPlus.ALPPacket();
                 // Putting command into a packet.
                 outThreadPacket.Add(cmd);
                 TraceOut.Put("AltiGenSPCore::ProcessCommand LocId=" + cmd.LocationId + " CmdId=" + ((ALPCmdID)cmd.CommandId).ToString() + " SeqId=" + cmd.SequenceId);
                 // Sending out the packet.
                 outThreadPacket.Write(bw);
             }
         }
         catch (Exception x)
         {
             if (outThreadLivingStatus)
             {
                 TraceOut.Put(x);
                 RaiseEvent(SPStatus.ERROR_CONNECTION, String.Format("Sending command: {0}", x.Message));
             }
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Sends command (one of <see cref="Diacom.Cmd"/> neamespace classes).
 /// </summary>
 /// <param name="cmd">Command to send of <see cref="Diacom.Cmd"/> type.</param>
 /// <remarks>Returns immediately.</remarks>
 public void Send(Diacom.Cmd.CmdBase cmd)
 {
     this.AltiGenSP.Send(cmd);
 }
コード例 #3
0
 /// <summary>
 /// Implements <see cref="Diacom.ISP.Send"/> method of <see cref="Diacom.ISP"/> interface.
 /// Sends command (one of <see cref="Diacom.Cmd"/> namespace classes).
 /// </summary>
 /// <param name="cmd">Command to send.</param>
 /// <remarks>
 /// <para>Returns immediately.</para>
 /// <seealso cref="Diacom.ISP"/>
 /// </remarks>
 public void Send(Diacom.Cmd.CmdBase cmd)
 {
     this.commandsQueue.Enqueue(cmd);
 }