Beispiel #1
0
 public PnCadReader(IPnCadDocument document, IFileReadLine lineReader) : base(document, lineReader)
 {
     OnLine.Where(line => !string.IsNullOrWhiteSpace(line)).Subscribe(line => {
         var values = Regex.Split(line, @"\s+");
         if (values.Length != 14)
         {
             return;
         }
         PnCadSchema schema = new PnCadSchema()
         {
             Color     = values[1].TrySetIntValue() ?? 0,
             Prop2     = values[2].TrySetIntValue() ?? 0,
             Prop3     = values[3].TrySetIntValue() ?? 0,
             Prop4     = values[4].TrySetIntValue() ?? 0,
             Prop5     = values[5].TrySetIntValue() ?? 0,
             Prop6     = values[6].TrySetIntValue() ?? 0,
             Type      = values[7].TrySetIntValue() ?? 0,
             Direction = values[8].TrySetIntValue() ?? 0,
             Point1X   = values[9].TrySetDoubleValue() ?? 0.0,
             Point1Y   = values[10].TrySetDoubleValue() ?? 0.0,
             Point2X   = values[11].TrySetDoubleValue() ?? 0.0,
             Point2Y   = values[12].TrySetDoubleValue() ?? 0.0,
             Angle     = values[13].TrySetDoubleValue() ?? 0.0
         };
         document.Schema.Add(schema);
     });
 }
        internal void AddShareSkill()
        {
            ExcelLib.PopulateInCollection(Base.ExcelPath, "ManageListings");

            GlobalDefinitions.WaitForElement(ShareSkillButton, 30);
            ShareSkillButton.Click();

            GlobalDefinitions.WaitForElement(Title, 30);
            Title.SendKeys(ExcelLib.ReadData(2, "Title"));

            Description.SendKeys(ExcelLib.ReadData(2, "Description"));

            Category(CategoryDropDown, ExcelLib.ReadData(2, "Category"));

            SubCategory(SubCategoryDropDown, ExcelLib.ReadData(2, "Sub Category"));

            Tags.SendKeys(ExcelLib.ReadData(2, "Tags"));
            Tags.SendKeys(Keys.Enter);

            OneOff.Click();

            OnLine.Click();

            StartDateDropDown.SendKeys(ExcelLib.ReadData(2, "Start Date"));

            EndDateDropDown.SendKeys(ExcelLib.ReadData(2, "End Date"));

            Sunday.Click();
            SundayStartTime.SendKeys(ExcelLib.ReadData(2, "Sunday Start Time"));
            SundayEndTime.SendKeys(ExcelLib.ReadData(2, "Sunday End Time"));

            Monday.Click();
            MondayStartTime.SendKeys(ExcelLib.ReadData(2, "Monday Start Time"));
            MondayEndTime.SendKeys(ExcelLib.ReadData(2, "Monday End Time"));

            Tuesday.Click();
            TuesdayStartTime.SendKeys(ExcelLib.ReadData(2, "Monday Start Time"));
            TuesdayEndTime.SendKeys(ExcelLib.ReadData(2, "Monday End Time"));

            CreditOption.Click();

            if (SkillExchangeOption.Selected)
            {
                SkillExchange.SendKeys(ExcelLib.ReadData(2, "Skill Exchange"));
            }
            else
            {
                CreditAmount.SendKeys(ExcelLib.ReadData(2, "Credit"));
            }

            Hidden.Click();

            Save.Click();
        }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            OnLine  line  = new OnLine();
            OnPlane plane = new OnPlane();

            MRhinoGetPoint gp = new MRhinoGetPoint();

            gp.SetCommandPrompt("Start of line");
            gp.GetPoint();
            if (gp.CommandResult() != IRhinoCommand.result.success)
            {
                return(gp.CommandResult());
            }

            line.from = gp.Point();
            plane     = new OnPlane(RhUtil.RhinoActiveCPlane());
            plane.SetOrigin(line.from);

            gp.SetCommandPrompt("End of line");
            gp.Constrain(plane);
            gp.SetBasePoint(line.from);
            gp.DrawLineFromPoint(line.from, true);
            gp.GetPoint();
            if (gp.CommandResult() != IRhinoCommand.result.success)
            {
                return(gp.CommandResult());
            }

            line.to = plane.ClosestPointTo(gp.Point());
            if (!line.IsValid())
            {
                return(IRhinoCommand.result.nothing);
            }

            SampleCsDrawArrowheadConduit conduit = new SampleCsDrawArrowheadConduit(plane, line, 1.0);

            conduit.Enable();
            context.m_doc.Redraw();

            MRhinoGetString gs = new MRhinoGetString();

            gs.SetCommandPrompt("Press <Enter> to continue");
            gs.AcceptNothing();
            gs.GetString();

            conduit.Disable();
            context.m_doc.Redraw();

            return(IRhinoCommand.result.success);
        }
        private void ReadTask()
        {
            while (!_cancelTokenSource.Token.IsCancellationRequested)
            {
                //check if data is available
                if (_dataWaitHandle.WaitOne(0, false))
                {
                    var result = _serialPort.ReadLine();
                    OnLine?.Invoke(result.AsSpan());
                    _dataWaitHandle.Reset();
                }

                WaitHandle.WaitAny(new WaitHandle[] { _dataWaitHandle, _cancelTokenSource.Token.WaitHandle });
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     // Since our form is modeless, the user can run commands
       // while our form is visible, including the Open command,
       // which closes the current document and opens a new one.
       // Thus, it's best to always ask for the active document
       // instead of maintaining a reference to the document passed
       // to the command that created this form.
       MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc();
       if (null != doc)
       {
     On3dPoint a = new On3dPoint(0.0, 0.0, 0.0);
     On3dPoint b = new On3dPoint(5.0, 5.0, 5.0);
     OnLine line = new OnLine(a, b);
     doc.AddCurveObject(line);
     doc.Redraw();
       }
 }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Since our form is modeless, the user can run commands
            // while our form is visible, including the Open command,
            // which closes the current document and opens a new one.
            // Thus, it's best to always ask for the active document
            // instead of maintaining a reference to the document passed
            // to the command that created this form.
            MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc();

            if (null != doc)
            {
                On3dPoint a    = new On3dPoint(0.0, 0.0, 0.0);
                On3dPoint b    = new On3dPoint(5.0, 5.0, 5.0);
                OnLine    line = new OnLine(a, b);
                doc.AddCurveObject(line);
                doc.Redraw();
            }
        }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            OnLine line = new OnLine();
              OnPlane plane = new OnPlane();

              MRhinoGetPoint gp = new MRhinoGetPoint();
              gp.SetCommandPrompt("Start of line");
              gp.GetPoint();
              if (gp.CommandResult() != IRhinoCommand.result.success)
            return gp.CommandResult();

              line.from = gp.Point();
              plane = new OnPlane(RhUtil.RhinoActiveCPlane());
              plane.SetOrigin(line.from);

              gp.SetCommandPrompt("End of line");
              gp.Constrain(plane);
              gp.SetBasePoint(line.from);
              gp.DrawLineFromPoint(line.from, true);
              gp.GetPoint();
              if (gp.CommandResult() != IRhinoCommand.result.success)
            return gp.CommandResult();

              line.to = plane.ClosestPointTo(gp.Point());
              if (!line.IsValid())
            return IRhinoCommand.result.nothing;

              SampleCsDrawArrowheadConduit conduit = new SampleCsDrawArrowheadConduit(plane, line, 1.0);
              conduit.Enable();
              context.m_doc.Redraw();

              MRhinoGetString gs = new MRhinoGetString();
              gs.SetCommandPrompt("Press <Enter> to continue");
              gs.AcceptNothing();
              gs.GetString();

              conduit.Disable();
              context.m_doc.Redraw();

              return IRhinoCommand.result.success;
        }
        /// <summary>
        /// Public constructor
        /// </summary>
        public SampleCsDrawArrowheadConduit(OnPlane plane, OnLine line, double scale)
            : base(new MSupportChannels(MSupportChannels.SC_CALCBOUNDINGBOX | MSupportChannels.SC_DRAWOVERLAY), false)
        {
            m_bDraw     = false;
            m_plane     = plane;
            m_line      = line;
            m_arrowhead = new On3dPointArray();

            double x = 0, y = 0;

            m_plane.ClosestPointTo(line.from, ref x, ref y);
            On2dPoint from = new On2dPoint(x, y);

            m_plane.ClosestPointTo(line.to, ref x, ref y);
            On2dPoint to = new On2dPoint(x, y);

            On2dVector dir = new On2dVector(from - to);

            dir.Unitize();

            m_bDraw = GetArrowHead(dir, from, scale, ref m_arrowhead);
        }
Beispiel #9
0
        public String GetURL(OneNetContext context)
        {
            otherParameters.Add(Key_WORDS, Keywords);
            if (OnLine.HasValue)
            {
                otherParameters.Add(ONLINE, OnLine.ToString());
            }
            if (Private.HasValue)
            {
                otherParameters.Add(PRIVATE, Private.ToString());
            }
            otherParameters.Add(PAGE, Page.ToString());
            otherParameters.Add(PER_PAGE, PageSize.ToString());
            otherParameters.Add(TAG, Tag);

            context.setContext(DEVICE_ID, DeviceIds);

            var url      = URIUtils.fmtURI(URI, context);
            var webUtils = new WebUtils();

            return(webUtils.BuildGetUrl(url, otherParameters));
        }
        /// <summary>
        /// Public constructor
        /// </summary>
        public SampleCsDrawArrowheadConduit(OnPlane plane, OnLine line, double scale)
            : base(new MSupportChannels(MSupportChannels.SC_CALCBOUNDINGBOX | MSupportChannels.SC_DRAWOVERLAY), false)
        {
            m_bDraw = false;
              m_plane = plane;
              m_line = line;
              m_arrowhead = new On3dPointArray();

              double x = 0, y = 0;

              m_plane.ClosestPointTo(line.from, ref x, ref y);
              On2dPoint from = new On2dPoint(x, y);

              m_plane.ClosestPointTo(line.to, ref x, ref y);
              On2dPoint to = new On2dPoint(x, y);

              On2dVector dir = new On2dVector(from - to);
              dir.Unitize();

              m_bDraw = GetArrowHead(dir, from, scale, ref m_arrowhead);
        }
Beispiel #11
0
 void Awake()
 {
     my = this;
 }
Beispiel #12
0
        /// <summary>
        /// 处理收到的AP消息
        /// </summary>
        /// <param name="apToKen"></param>
        /// <param name="msg"></param>
        private void HandleApMsg(AsyncUserToken apToKen, string msg)
        {
            //解析AP发过来的消息
            UInt16          msgId   = 0;
            Msg_Body_Struct msgBody = null;

            try
            {
                msgBody = Xml_codec.DecodeApXmlMessage(msg, ref msgId);
            }
            catch (Exception)
            {
                OnOutputLog(LogInfoType.EROR, string.Format("解析收到的Ap[{0}:{1}]消息出错!",
                                                            apToKen.IPAddress.ToString(), apToKen.Port.ToString()));
                return;
            }

            if (msgBody == null)
            {
                OnOutputLog(LogInfoType.EROR, "收到消息格式错误!");
                OnOutputLog(LogInfoType.DEBG, "出错消息内容:" + msg);
                return;
            }

            if (msgBody.type == ApMsgType.device_test_request)
            {
                Send2ap_device_test_response(apToKen);
                return;
            }

            if (msgBody.type != ApMsgType.status_response)
            {
                OnOutputLog(LogInfoType.INFO, string.Format("处理AP[{0}:{1}]消息({2}),消息Id={3}!",
                                                            apToKen.IPAddress.ToString(), apToKen.Port, msgBody.type, msgId));
            }

            //处理透传消息
            if (msgId >= ApMsgIdClass.MIN_TRANSPARENT_MSG_ID && msgId <= ApMsgIdClass.MAX_TRANSPARENT_MSG_ID)
            {
                if (msgBody.type != ApMsgType.get_general_para_response) //参数上报消息不透传
                {
                    Msg_Body_Struct body = new Msg_Body_Struct(Main2ApControllerMsgType.transparent_msg_response, "transparent_msg", msg);
                    OnSendMsg2Main(msgId, MsgStruct.MsgType.TRANSPARENT, apToKen, body);
                    return;
                }
            }

            //心跳消息处理
            if (msgBody.type == ApMsgType.status_response)
            {
                //OnOutputLog(LogInfoType.INFO, "收到心跳消息");
                heartbeatMsgNum++;

                //UInt32 oldDetail = apToKen.Detail;
                UInt32 detail  = 0;
                string sDetail = GetMsgStringValueInList("detail", msgBody);
                if (!string.IsNullOrEmpty(sDetail))
                {
                    detail = Convert.ToUInt32(sDetail, 16);
                }

                //Byte oldApReadySt = apToKen.ApReadySt;
                Byte   ApReadySt  = 5;
                string sApReadySt = GetMsgStringValueInList("addStatus", msgBody);
                if (!string.IsNullOrEmpty(sApReadySt))
                {
                    ApReadySt = Convert.ToByte(sApReadySt);
                }

                apToKen.version  = GetMsgStringValueInList("version", msgBody);
                apToKen.Mode     = GetMsgStringValueInList("mode", msgBody);
                apToKen.Sn       = GetMsgStringValueInList("sn", msgBody);
                apToKen.FullName = GetMsgStringValueInList("fullname", msgBody);
                if (string.IsNullOrEmpty(apToKen.FullName))   //兼容老Agent拼写错误
                {
                    apToKen.FullName = GetMsgStringValueInList("fullaname", msgBody);
                }
                apToKen.Id = GetMsgStringValueInList("id", msgBody);
                //apToKen.Detail = detail;

                int i = MyDeviceList.add(apToKen);
                Send2main_OnOffLine(OnLine, i, apToKen);

                //判断是周期心跳,还是上线心跳
                if ((detail & (int)AP_STATUS_LTE.OnLine) > 0) //上线
                {
                    //OnOutputLog(LogInfoType.DEBG, "上线消息");
                    if (OnLine.Equals(MyDeviceList.GetMainControllerStatus(apToKen)))
                    {
                        Send2ap_status_request(apToKen);
                        Thread.Sleep(1000);
                        Send2ap_get_general_para_request(apToKen);
                    }
                    else
                    {
                        OnOutputLog(LogInfoType.DEBG, "MainController未回复上线成功消息!");
                    }
                }
                else //周期心跳
                {
                    //OnOutputLog(LogInfoType.DEBG, "周期心跳消息");
                }
                //发送状态改变
                Send2ap_ApStatusChange_LTE(apToKen, detail, ApReadySt);
            }
            else if (msgBody.type == ApMsgType.get_general_para_response)
            {
                Msg_Body_Struct SendMsgBody = msgBody;
                SendMsgBody.type = Main2ApControllerMsgType.ReportGenPara;
                // 向Main模块发消息
                OnSendMsg2Main(0, MsgStruct.MsgType.NOTICE, apToKen, SendMsgBody);
            }
            else if (msgBody.type == ApMsgType.set_general_para_response)
            {
                Msg_Body_Struct SendMsgBody = msgBody;
                SendMsgBody.type = Main2ApControllerMsgType.SetGenParaRsp;
                // 向Main模块发消息
                OnSendMsg2Main(0, MsgStruct.MsgType.NOTICE, apToKen, SendMsgBody);
            }
            else if (msgBody.type == ApMsgType.imsi_list_config_result)
            {
                Msg_Body_Struct SendMsgBody = msgBody;
                SendMsgBody.type = Main2ApControllerMsgType.app_add_bwlist_response;
                // 向Main模块发消息
                OnSendMsg2Main(msgId, MsgStruct.MsgType.NOTICE, apToKen, SendMsgBody);
            }
            else if (msgBody.type == ApMsgType.imsi_list_delconfig_result)
            {
                Msg_Body_Struct SendMsgBody = msgBody;
                SendMsgBody.type = Main2ApControllerMsgType.app_del_bwlist_response;
                // 向Main模块发消息
                OnSendMsg2Main(msgId, MsgStruct.MsgType.NOTICE, apToKen, SendMsgBody);
            }
            else if (msgBody.type == ApMsgType.scanner)
            {
                imsiMsgNum++;
                recvApImsiMsgNum++;

                string imsi = GetMsgStringValueInList("imsi", msgBody);
                if (!string.IsNullOrEmpty(imsi))
                {
                    //IMSI去重处理
                    if (DataController.RemoveDupMode == 1)
                    {
                        //有该IMSI,去重,不用上报
                        if (ImsiRemoveDup.isExist(imsi))
                        {
                            OnOutputLog(LogInfoType.INFO,
                                        string.Format("Imsi[{0}]在{1}时被抓到过,不再上报!",
                                                      imsi, ImsiRemoveDup.GetTime(imsi)));
                            return;
                        }
                        ImsiRemoveDup.add(imsi);
                    }

                    Msg_Body_Struct body = new Msg_Body_Struct(msgBody.type, msgBody.dic);

                    OnOutputLog(LogInfoType.DEBG, string.Format("上报imsi:{0}", imsi));
                    OnSendMsg2Main(0, MsgStruct.MsgType.NOTICE, apToKen, body);
                }
            }
            else
            {
                Msg_Body_Struct body = new Msg_Body_Struct(msgBody.type, msgBody.dic);
                OnSendMsg2Main(msgId, MsgStruct.MsgType.CONFIG, apToKen, body);
            }

            msgBody = null;
        }
Beispiel #13
0
        /// <summary>
        /// Progress the story using the given input.
        /// This yields line data from internal dialogue runner, whose data is passed via invoking actions.
        /// If delayed next was called previously, this runner is current waiting for that to finish and won't run the next line.
        /// </summary>
        /// <param name="input"></param>
        public static LineTag Next(string input = "", bool auto = false)
        {
#if UNITY_EDITOR
            string caller = (new System.Diagnostics.StackTrace()).GetFrame(auto ? 2 : 1).GetMethod().Name;
            Debug.Log($"Kataru.Runner.Next('{input}') from {caller}.");
#endif
            if (isWaiting)
            {
#if UNITY_EDITOR
                Debug.LogWarning($@"Called Runner.Next while runner was busy waiting.
                                    Don't call Runner.Next until Runner.DelayedNext has finished.");
#endif
                return(LineTag.End);
            }

            FFI.Next(input);
            Tag = FFI.Tag();
#if UNITY_EDITOR
            Debug.Log($"Tag: {Tag}");
#endif
            switch (Tag)
            {
            case LineTag.Choices:
                OnChoices.Invoke(FFI.LoadChoices());
                break;

            case LineTag.InvalidChoice:
                OnInvalidChoice.Invoke();
                break;

            case LineTag.Dialogue:
                Dialogue dialogue = FFI.LoadDialogue();
#if UNITY_EDITOR
                Debug.Log($"{dialogue.name}: '{dialogue.text}'");
#endif
                CharacterDelegates.Invoke(dialogue.name, new object[] { dialogue });
                break;

            case LineTag.Command:
                Command command = FFI.GetCommand();
#if UNITY_EDITOR
                Debug.Log($"Calling command '{command.name}'");
                if (string.IsNullOrEmpty(command.name))
                {
                    throw new KeyNotFoundException($"Received empty Kataru command. Did you use a global command as a character command?");
                }
#endif
                ConcurrentDictionary <Delegate, bool> delegates;
                if (CommandDelegates.TryGetValue(command.name, out delegates))
                {
                    object[] @params = new object[] { };
                    foreach (var @delegate in delegates.Keys)
                    {
                        @params = command.Params(@delegate.Method);
                        break;
                    }
                    CommandDelegates.Invoke(command.name, @params);
                }
                else
                {
                    throw new KeyNotFoundException($"No Kataru command named '{command.name}' was registered in Unity. Are you missing a command definition, attribute, or reference?");
                }
                break;

            case LineTag.InputCommand:
                OnInputCommand?.Invoke(FFI.LoadInputCommand());
                break;

            case LineTag.End:
                Exit();
                break;
            }
            OnLine?.Invoke(Tag);
            return(Tag);
        }