示例#1
0
 private void PortStatusInfo(PortStatus status)
 {
     if (status == PortStatus.Connected)
     {
         button_connection.Text           = "Disconnect";
         statusBar_connection_status.Text = "Connected / " + baudrate.SelectedItem.ToString() + " bps";
         tabControl1.Enabled         = true;
         groupBox_preview.Enabled    = true;
         groupBox_send.Enabled       = true;
         groupBox_statistics.Enabled = true;
     }
     if (status == PortStatus.Disconnected)
     {
         button_connection.Text           = "Connect";
         statusBar_connection_status.Text = "Disconected";
         tabControl1.Enabled         = false;
         groupBox_preview.Enabled    = false;
         groupBox_send.Enabled       = false;
         groupBox_statistics.Enabled = false;
     }
     if (status == PortStatus.Busy)
     {
         button_connection.Text           = "Connect";
         statusBar_connection_status.Text = "Busy";
     }
 }
示例#2
0
        /// <summary>
        /// Inputs used by the device in the active instruction
        /// </summary>
        /// <param name="bankID">BankID of the device</param>
        /// <param name="cycle">Zero-based program cycle number</param>
        /// <param name="acuAddrPortOut_Stat"></param>
        /// <param name="ramACUPortIn_Stat"></param>
        /// <param name="mux1PortOut_Stat"></param>
        /// <param name="ramMux1PortIn_Stat"></param>
        private static void InputsUsed(
            Bank bankID,
            int cycle,
            out PortStatus acuAddrPortOut_Stat,
            out PortStatus mux1PortOut_Stat,
            out PortStatus ramACUPortIn_Stat,
            out PortStatus ramMux1PortIn_Stat)
        {
            ramMux1PortIn_Stat = PortStatus.Inactive;

            // acu addr out, ram addr, and mux1 out in are always active
            acuAddrPortOut_Stat = PortStatus.Active;
            ramACUPortIn_Stat   = PortStatus.Active;
            mux1PortOut_Stat    = PortStatus.Active;

            // mux1in and is active if a ram write operation is in progress
            if (cycle < 0)
            {
                return;
            }

            var instr = CodeStoreModel.Instruction(cycle);

            if (instr == null)
            {
                return;
            }

            // ram write instruction?
            if ((bankID == Bank.Bank_A && instr.Da == 1) ||
                (bankID == Bank.Bank_B && instr.Db == 1))
            {
                ramMux1PortIn_Stat = PortStatus.Active;
            }
        }
示例#3
0
 public TcpClientPort(string ipAddress, int port, int autoReConnectionInterval = 5)
 {
     portStatus     = PortStatus.Closed;
     this.ipAddress = ipAddress;
     this.port      = port;
     this.autoReConnectionInterval = autoReConnectionInterval;
 }
示例#4
0
    public override void InitializeGUI()
    {
        if (base._mIsLoaded)
        {
            return;
        }
        base._mIsLoaded = true;
        this.GUILevel   = 10;

        DailyTaskBtnNull.transform.localScale = Vector3.zero;

        StorageFriendInfo friendInfo = new StorageFriendInfo();

        friendInfo.friendId         = -1;
        friendInfo.friendType       = -1;
        friendInfo.friendGender     = 0;
        friendInfo.friednAppearance = null;
        friendInfo.friendCloth      = null;
        friendInfo.friendActing     = 0;
        Globals.Instance.MTaskManager.mTaskDailyData.FriendInfo = friendInfo;

        PortStatus port = ((PortStatus)GameStatusManager.Instance.MCurrentGameStatus);

        port.orbitCamera.SetRotationStatus(false);
    }
示例#5
0
 private void ReadCallBack(IAsyncResult iar)
 {
     try
     {
         DataRead dataRead = (DataRead)iar.AsyncState;
         int      recv     = dataRead.ns.EndRead(iar);
         if (recv != 0)
         {
             byte[] receBytes = new byte[recv];
             Array.Copy(dataRead.msg, 0, receBytes, 0, recv);
             if (isExit == false)
             {
                 dataRead = new DataRead(ns, client.ReceiveBufferSize);
                 ns.BeginRead(dataRead.msg, 0, dataRead.msg.Length, ReadCallBack, dataRead);
             }
             //这里发送数据事件
             PortDataReceived(new ReceBytesEventArge(receBytes));
         }
         else
         {
             //这里表示掉线了
             portStatus = PortStatus.Closed;
             ConnNotify(new ConnStatusChangedEventArgs(DateTime.Now, false, portStatus));
         }
     }
     catch (Exception ex)
     {
         portStatus = PortStatus.Error;
         ConnNotify(new ConnStatusChangedEventArgs(DateTime.Now, false, portStatus));
     }
 }
示例#6
0
        /// <summary>
        /// Inputs used by the device in the active instruction
        /// </summary>
        /// <param name="cycle">Zero-based program cycle number</param>
        /// <param name="stagePortAOut_Stat"></param>
        /// <param name="stagePortBOut_Stat"></param>
        /// <param name="muxStagePortAIn_Stat"></param>
        /// <param name="muxStagePortBIn_Stat"></param>
        private static void InputsUsed(
            int cycle,
            out PortStatus stagePortAOut_Stat,
            out PortStatus stagePortBOut_Stat,
            out PortStatus muxStagePortAIn_Stat,
            out PortStatus muxStagePortBIn_Stat)
        {
            stagePortAOut_Stat   = PortStatus.Inactive;
            stagePortBOut_Stat   = PortStatus.Inactive;
            muxStagePortAIn_Stat = PortStatus.Inactive;
            muxStagePortBIn_Stat = PortStatus.Inactive;

            bool busRead_A;
            bool busRead_B;

            BusInModel.BusRead(cycle,
                               out busRead_A,
                               out busRead_B);

            if (busRead_A)
            {
                stagePortAOut_Stat   = PortStatus.Active;
                muxStagePortAIn_Stat = PortStatus.Active;
            }

            if (busRead_B)
            {
                stagePortBOut_Stat   = PortStatus.Active;
                muxStagePortBIn_Stat = PortStatus.Active;
            }
        }
示例#7
0
 public void Write(byte[] bytes)
 {
     if (portStatus != PortStatus.Connected)
     {
         return;
     }
     //在重连的时候,禁止发送数据
     try
     {
         if (ns != null && ns.CanWrite)
         {
             ns.BeginWrite(bytes, 0, bytes.Length, new AsyncCallback(SendCallBack), ns);
             ns.Flush();
         }
         else
         {
             portStatus = PortStatus.Closed;
             ConnNotify(new ConnStatusChangedEventArgs(DateTime.Now, false, portStatus));
         }
     }
     catch (Exception ex)
     {
         portStatus = PortStatus.Error;
         ConnNotify(new ConnStatusChangedEventArgs(DateTime.Now, false, portStatus));
     }
 }
示例#8
0
 public Port(int id)
 {
     Id             = id;
     Status         = PortStatus.Free;
     StatusChanging = null;
     StatusChanged  = null;
 }
示例#9
0
 /// <summary>
 /// Изменяет статус порта (лучше использовать только на станции!)
 /// </summary>
 /// <param name="status"></param>
 internal void PortStatusChange(PortStatus status)
 {
     if (Enum.IsDefined(typeof(PortStatus), status))
     {
         Status = status;
     }
 }
示例#10
0
 public QueryResult(string address, ProtocolType protocol, string port, PortStatus status)
 {
     this.address  = address;
     this.protocol = protocol;
     this.port     = port;
     this.status   = status;
 }
示例#11
0
 public PortInfo(Tuple <IPAddress, string> host, int port, PortLookupInfo lookupInfo, PortStatus status)
 {
     Host       = host;
     Port       = port;
     LookupInfo = lookupInfo;
     Status     = status;
 }
示例#12
0
        public SPort(string PortName, int BaudRate, Parity Parity, int DataBits, StopBits StopBit)
        {
            _serial = new SerialPort(PortName, BaudRate, Parity, DataBits, StopBit);
            //_serial.DataReceived +=new SerialDataReceivedEventHandler(_serial_DataReceived);
            _serial.Handshake = Handshake.None;

            if (!NodeAgent.IsDebug)
            {
                _timer = new Timer(_checkport);

                _timer.Change(0, 3);
            }

//            _serial.ErrorReceived += new SerialErrorReceivedEventHandler(_serial_ErrorReceived);
//            _serial.RtsEnable = false;


            CmdToSend       = new Queue <byte[]>();
            InFrameHandlers = new Dictionary <byte, IOInFrameHandler>();

            ifrm = new FrameBuffer();
            ifrm.ResetFlag();

            Status = PortStatus.CLOSED;
        }
示例#13
0
 public bool Open()
 {
     if (NodeAgent.IsDebug)
     {
         return(true);
     }
     if (Status != PortStatus.CLOSED)
     {
         return(true);
     }
     try
     {
         _serial.Open();
         _serial.DiscardInBuffer();
     }
     catch (System.Exception e)
     {
         MessageBox.Show(e.Message);
         Status = PortStatus.ERROR;
     }
     if (_serial.IsOpen)
     {
         Status = PortStatus.IDLE;
     }
     _serial.DiscardInBuffer();
     return(_serial.IsOpen);
 }
示例#14
0
 public PortInfo(IPAddress ipAddress, string hostname, int port, PortLookupInfo lookupInfo, PortStatus status)
 {
     IPAddress  = ipAddress;
     Hostname   = hostname;
     Port       = port;
     LookupInfo = lookupInfo;
     Status     = status;
 }
示例#15
0
        public ThingService(tirotdbContext context)
        {
            _thing = new List <Thing> {
            };

            // Get Machine
            var objMachine = from x in context.TbMachine orderby x.MachineId select x;

            foreach (TbMachine mch in objMachine)
            {
                var objThing = new Thing();
                objThing.Id            = mch.MachineId;
                objThing.Name          = mch.MachineName;
                objThing.StartWorkTime = "00:00";
                objThing.EndWorkTime   = "00:00";

                // Get and Update Last Status from MongoDB
                var objMongo    = new MachineRunningStatus();
                var objTimeLine = objMongo.GetLastMachineStatus(objThing.Id);

                if (objTimeLine != null && objTimeLine.Count() > 0)
                {
                    objThing.OnlineStatus       = objTimeLine.ElementAt(0).MachineRunningStatus;
                    objThing.LastUpdateDateTime = objTimeLine.ElementAt(0).CDateTime.ToLocalTime();
                }
                else
                {
                    objThing.OnlineStatus       = "0";
                    objThing.LastUpdateDateTime = DateTime.Now;
                }


                //objThing.ThingWorkStatus = new PortStatus();
                objThing.ThingPortsStatus = new List <PortStatus> {
                };

                //var objPort = from y in context.TbIoTdevicePort select y;
                _thing.Add(objThing);
            }
            // Get Port
            var objPort = from x in context.TbIoTdevicePort select x;

            // Add Port
            foreach (TbIoTdevicePort dp in objPort)
            {
                var objPS = new PortStatus();
                objPS.IoTdevicePortID = dp.IoTdevicePort.ToString();
                objPS.IoTdevicePort   = dp.IoTdevicePort;
                objPS.SensorType      = dp.SensorType;
                objPS.MeasurementType = dp.MeasurementId;

                var tmpThing = _thing.First(x => x.Id.Contains(dp.MachineId));
                if (tmpThing != null)
                {
                    tmpThing.ThingPortsStatus.Add(objPS);
                }
            }
        }
        public void RejectCall(object sender, RejectedCallEvent e)
        {
            PortStatus = PortStatus.Free;

            OnNotifyStationAboutRejectionOfCall(new RejectedCallEvent(PhoneNumber)
            {
                CallRejectionTime = e.CallRejectionTime
            });
        }
示例#17
0
        /// <summary>
        /// Inputs used by the device in the active instruction
        /// </summary>
        /// <param name="cycle">Zero-based program cycle number</param>
        /// <param name="mux2APortOut_Stat"></param>
        /// <param name="mux2BPortOut_Stat"></param>
        /// <param name="shifterPortOut_Stat"></param>
        /// <param name="macMux2APortIn_Stat"></param>
        /// <param name="macMux2BPortIn_Stat"></param>
        /// <param name="macShifterPortIn_Stat"></param>
        private static void InputsUsed(
            int cycle,
            out PortStatus mux2APortOut_Stat,
            out PortStatus mux2BPortOut_Stat,
            out PortStatus shifterPortOut_Stat,
            out PortStatus macMux2APortIn_Stat,
            out PortStatus macMux2BPortIn_Stat,
            out PortStatus macShifterPortIn_Stat)
        {
            // Mux 2 and shifter outputs are always active
            mux2APortOut_Stat   = PortStatus.Active;
            mux2BPortOut_Stat   = PortStatus.Active;
            shifterPortOut_Stat = PortStatus.Active;

            // Default
            macMux2APortIn_Stat   = PortStatus.Inactive;
            macMux2BPortIn_Stat   = PortStatus.Inactive;
            macShifterPortIn_Stat = PortStatus.Inactive;

            var instr = CodeStoreModel.Instruction(cycle - 1);

            if (instr == null)
            {
                return;
            }

            var instMAC = instr.Mac;

            switch (instMAC ?? "")
            {
            case "loadalu":
                // Adds the previous ALU output (from the shifter) to the product and
                // starts a new accumulation.
                macMux2APortIn_Stat   = PortStatus.Active;
                macMux2BPortIn_Stat   = PortStatus.Active;
                macShifterPortIn_Stat = PortStatus.Active;
                break;

            case "clra":
                // Clears the accumulator and stores the current product
                macMux2APortIn_Stat = PortStatus.Active;
                macMux2BPortIn_Stat = PortStatus.Active;
                break;

            case "hold":
                // Holds the value in the accumulator from the previous cycle.
                // No multiply
                break;

            case "macc":
                // Multiplies the values on mux2 of side A and side B.
                // Adds the product to the current value of the accumulator.
                macMux2APortIn_Stat = PortStatus.Active;
                macMux2BPortIn_Stat = PortStatus.Active;
                break;
            }
        }
示例#18
0
    public bool OnFingerPinchMove(Vector2 fingerPos1, Vector2 fingerPos2, float delta)
    {
        if (m_fingerPinchState)
        {
            PortStatus.OnFingerPinchMove_imple(delta);
        }

        return(true);
    }
示例#19
0
        /// <summary>
        /// Inputs used by the device in the active instruction
        /// </summary>
        /// <param name="cycle">Zero-based program cycle number</param>
        /// <param name="holdA"></param>
        /// <param name="holdB"></param>
        private static void InputsUsed(int cycle, out PortStatus holdA, out PortStatus holdB)
        {
            var busActive = BusWritten(cycle);

            holdA = busActive != null && busActive.Equals("A")
                                ? PortStatus.Active
                                : PortStatus.Inactive;
            holdB = busActive != null && busActive.Equals("B")
                                ? PortStatus.Active
                                : PortStatus.Inactive;
        }
        public void OutgoingCall(object sender, OutgoingCallEvent e)
        {
            if (PortStatus != PortStatus.Free || PhoneNumber == e.ReceiverPhoneNumber)
            {
                return;
            }

            PortStatus = PortStatus.Busy;

            OnNotifyStationOfOutgoingCall(new OutgoingCallEvent(PhoneNumber, e.ReceiverPhoneNumber));
        }
 public void ConnectToTelephone(object sender, ConnectionEvent e)
 {
     if (PortStatus == PortStatus.SwitchedOff)
     {
         PortStatus = PortStatus.Free;
     }
     else
     {
         e.Port = null;
     }
 }
示例#22
0
 public void SetPortStatus(IPAddress localAddress, IPAddress globalAddress, PortStatus value)
 {
     foreach (var listener in OutputListeners.Where(port => IsIPAddressMatch(port.LocalEndPoint.Address, localAddress)))
     {
         if (globalAddress != null)
         {
             listener.GlobalAddress = globalAddress;
         }
         listener.Status = value;
     }
 }
示例#23
0
 public bool Disconnect(Terminal terminal)
 {
     if (Status == PortStatus.Connect)
     {
         Status                 = PortStatus.Disconnect;
         terminal.CallEvent    -= CallingTo;
         terminal.AnswerEvent  -= AnswerTo;
         terminal.EndCallEvent -= EndCall;
         Flag = false;
     }
     return(false);
 }
 public List <object> GetPortStatusList()
 {
     SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
     return(Ports
            .Select(port =>
     {
         PortStatus status = GetPortStatus(port);
         return new { name = port.Name, number = port.Number, status = status, statusDescription = GetStatusDescription(status) };
     })
            .Cast <object>()
            .ToList());
 }
示例#25
0
 public bool Connect(Terminal terminal)
 {
     if (Status == PortStatus.Disconnect)
     {
         Status                 = PortStatus.Connect;
         terminal.CallEvent    += CallingTo;
         terminal.AnswerEvent  += AnswerTo;
         terminal.EndCallEvent += EndCall;
         Flag = true;
     }
     return(Flag);
 }
示例#26
0
 public ParaSet(PortStatus ps)
 {
     InitializeComponent();
     PS = ps;
     comboBoxOnValue.Items.AddRange(new string[] { "1", "2" });
     combPort.Items.AddRange(new string[] { "278", "378", "3BC" });
     comboBoxInterval.Items.AddRange(new string[] { "1", "2", "5", "10", "20" });
     comboBoxTimeOut.Items.AddRange(new string[] { "20", "50", "100", "200", "500", "1000" });
     combPort.SelectedIndex         = 0;
     comboBoxOnValue.SelectedIndex  = 1;
     comboBoxInterval.SelectedIndex = 1;
     comboBoxTimeOut.SelectedIndex  = 1;
 }
示例#27
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PortStatus portStatus = (PortStatus)value;

            string status = LocalizationManager.GetStringByKey("String_PortStatus_" + portStatus.ToString());

            if (string.IsNullOrEmpty(status))
            {
                return(portStatus.ToString());
            }

            return(status);
        }
示例#28
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PortStatus portStatus = (PortStatus)value;

            string status = Application.Current.Resources["String_PortStatus_" + portStatus.ToString()] as string;

            if (string.IsNullOrEmpty(status))
            {
                return(portStatus.ToString());
            }

            return(status);
        }
        public IPPortStatus(byte[] data, int portID)
        {
            int pos = START + (LENGTH * portID);

            Status        = (PortStatus)data[pos++];
            KeyCtrlVHWVer = data[pos++];
            SwitchState   = data[pos++];
            SwitchState  |= (ushort)(data[pos++] << 8);
            TBar          = data[pos++];
            JoyX          = data[pos++];
            JoyY          = data[pos++];
            JoyZ          = data[pos];
        }
示例#30
0
    protected override void OnDestroy()
    {
        base.OnDestroy();

        mMissionItemList.Clear();

        PortStatus port = ((PortStatus)GameStatusManager.Instance.MCurrentGameStatus);

        if (port != null)
        {
            port.orbitCamera.SetRotationStatus(true);
        }
    }
示例#31
0
        public SPort(string PortName, int BaudRate, Parity Parity, int DataBits, StopBits StopBit)
        {
            int hit = 20;
            while (hit-- > 0)
            {
                try
                {
                    if (SerialPort.GetPortNames().Contains<string>(PortName))
                    {
                        _serial = new SerialPort(PortName, BaudRate, Parity, DataBits, StopBit);
                        _serial.Handshake = Handshake.None;
                        break;
                    }
                }
                catch
                {
                    Thread.Sleep(1000);
                }
            }
            if (hit <= 0)
                throw new Exception("Failed to open port "+PortName);
            //_serial.DataReceived +=new SerialDataReceivedEventHandler(_serial_DataReceived);
            

           
//            _serial.ErrorReceived += new SerialErrorReceivedEventHandler(_serial_ErrorReceived);
//            _serial.RtsEnable = false;
            
            ifrm = new FrameBuffer();
            ifrm.ResetFlag();

            Status = PortStatus.CLOSED;
        }
示例#32
0
        public SPort(string PortName, int BaudRate, Parity Parity, int DataBits, StopBits StopBit)
        {
            _serial = new SerialPort(PortName, BaudRate, Parity, DataBits, StopBit);
            //_serial.DataReceived +=new SerialDataReceivedEventHandler(_serial_DataReceived);
            _serial.Handshake = Handshake.None;

            if (!NodeAgent.IsDebug)
            {
                _timer = new Timer(_checkport);

                _timer.Change(0, 3);
            }
            
//            _serial.ErrorReceived += new SerialErrorReceivedEventHandler(_serial_ErrorReceived);
//            _serial.RtsEnable = false;

            
            CmdToSend = new Queue<byte[]>();
            InFrameHandlers = new Dictionary<byte, IOInFrameHandler>();
            
            ifrm = new FrameBuffer();
            ifrm.ResetFlag();

            Status = PortStatus.CLOSED;
        }
示例#33
0
 public bool Open()
 {
     if (NodeAgent.IsDebug)
         return true;
     if (Status != PortStatus.CLOSED)
         return true;
     try
     {
         _serial.Open();
         _serial.DiscardInBuffer();
     }
     catch (System.Exception e)
     {
         MessageBox.Show(e.Message);
         Status = PortStatus.ERROR;
     }
     if (_serial.IsOpen)
     {
         Status = PortStatus.IDLE;
     }
     _serial.DiscardInBuffer();
     return _serial.IsOpen;            	
 }
示例#34
0
 protected string GetStatusDescription(PortStatus status)
 {
     return MonitoringResource.ResourceManager.GetString("PortStatus" + status) ?? status.ToString();
 }
示例#35
0
 public bool Open()
 {
     if (Status != PortStatus.CLOSED)
         return true;
     try
     {
         _serial.Open();
     }
     catch (System.Exception e)
     {
         Program.MsgShow(e.Message);
         Status = PortStatus.ERROR;
         return false ;
     }
     if (_serial.IsOpen)
     {
         Status = PortStatus.IDLE;
     }
     _serial.DiscardInBuffer();
     ifrm.ResetFlag();
     return _serial.IsOpen;            	
 }
示例#36
0
        public SPort(string PortName, int BaudRate, Parity Parity, int DataBits, StopBits StopBit)
        {
            _serial = new SerialPort(PortName, BaudRate, Parity, DataBits, StopBit);
            _serial.DataReceived +=new SerialDataReceivedEventHandler(_serial_DataReceived);
            _serial.Handshake = Handshake.None;

            
            CmdToSend = new Queue<byte[]>();
            InFrameHandlers = new Dictionary<byte, IOInFrameHandler>();
            
            ifrm = new FrameBuffer();
            ifrm.ResetFlag();

            Status = PortStatus.CLOSED;
        }
示例#37
0
 public void Close()
 {
     _serial.Close();
     Status = PortStatus.CLOSED;
 }
 /// <summary>
 /// Change Send Ports status.
 /// </summary>
 /// <param name="sendPortNames">The Send Port names.</param>
 /// <param name="newPortStatus">The Send Port status.</param>
 private void ChangeSendPortStatus(IEnumerable<string> sendPortNames, PortStatus newPortStatus)
 {
     foreach (string sendPortName in sendPortNames)
     {
         foreach (ISendPort2 sendPort in this.bizTalkApplication.SendPorts)
         {
             // Can't access ICollection via index, so must "foreach" and check each
             if (sendPort.Name == sendPortName)
             {
                 sendPort.Status = newPortStatus;
                 break;
             }
         }
     }
 }