示例#1
0
        private void CreateProtocolCollection()
        {
            NativeMethods.Profile profile = CapiPInvoke.GetProfile(_id);
            // B1 protocols;
            List <Protocol> protocolList = GetProtocols(profile.B1_Protocols, typeof(NativeMethods.B1Protocol), ProtocolStrings.ResourceManager, "B1_");

            _protocols = new ProtocolCollection(protocolList);
        }
示例#2
0
 public void SendMessage(Message message)
 {
     using (MemoryStream stream = new MemoryStream()) {
         if (message.Identity.SubCommand == SubCommand.Request && message.Number == 0)
         {
             message.Number = GetUniqueMessageNumber();
         }
         _serializer.Serialize(stream, message);
         CapiPInvoke.PutMessage(_appID, stream);
     }
 }
示例#3
0
        private ControllerCollection CreateControllerCollection()
        {
            NativeMethods.Profile profile        = CapiPInvoke.GetProfile(0);
            List <Controller>     controllerList = new List <Controller>();

            for (UInt16 i = 1; i <= profile.number; i++)
            {
                controllerList.Add(new Controller(this, i));
            }
            return(new ControllerCollection(controllerList));
        }
示例#4
0
 public /*override*/ void Dispose(/*bool disposing*/)
 {
     if (_appID != AppIDPlaceHolder)
     {
         _run = false;
         SendFakeListenRequest();
         _messageQueueThread.Join(MessageQueueTimeout);
         CapiPInvoke.Release(_appID);
         _appID = AppIDPlaceHolder;
     }
     //base.Dispose(disposing);
 }
示例#5
0
        public CapiApplication(int messageBufferLenght, int maxLogicalConnections, int maxBDataBlocks, int maxBDataLen)
        {
            _BDataBlocks = maxBDataBlocks;
            _BDataLenght = maxBDataLen;

            _appID              = CapiPInvoke.Register(messageBufferLenght, maxLogicalConnections, maxBDataBlocks, maxBDataLen);
            _serializer         = new CapiSerializer(this);
            _messageQueueThread = new Thread(WaitForConfirmation);
            _messageQueueThread.IsBackground = true;
            _messageQueueThread.Name         = string.Format("CAPI Application: {0} message queue", _appID);
            _messageQueueThread.Start();
        }
示例#6
0
        private void WaitForConfirmation()
        {
            while (_run)
            {
                try {
                    CapiPInvoke.WaitForSignal(_appID);
                    using (MemoryStream stream = CapiPInvoke.GetMessage(_appID)) {
                        MessageHeader header;
                        Message       message = _serializer.Deserialize(stream, out header);

                        Trace.TraceInformation("CapiApplication#" + ValidationHelper.HashString(this)
                                               + "WaitForConfirmation header  = " + header.Command.ToString() + "," + header.SubCommand.ToString());

                        message.Notify(this);
                    }
                } catch (Exception e) {
                    Trace.TraceError("CapiApplication#{0}::WaitForConfirmation, Exception = {1}", ValidationHelper.HashString(this), e);
                }
            }
        }