Exemple #1
0
        private dynamic GetArchiveRecord(DateTime date, DevType dev, float ver, bool isDay = false, bool tsDay = false)
        {
            dynamic archive;

            if (testMode)
            {
                byte[] data = SendBraces(MakeArchiveRequest(isDay ? 7 : 3, date.Date, date.Date.AddDays(1).AddSeconds(-1), 10));

                var rsp = ParseArchiveResponse(data);
                if (!rsp.success)
                {
                    return(rsp);
                }

                archive = ParseArchiveRecordsGrouped(rsp.rows, dev, ver, tsDay);
            }
            else
            {
                byte[] data = SendBraces(MakeArchiveRequest(isDay ? 7 : 3, date.AddSeconds(-5), date.AddSeconds(5), 1));
                var    rsp  = ParseArchiveResponse(data);
                if (!rsp.success)
                {
                    return(rsp);
                }

                archive = ParseArchiveRecords(rsp.rows, dev, ver, tsDay);
            }

            return(archive);
        }
Exemple #2
0
        private void Client_ReceiveData(string devName, DevType head, IBaseModule module)
        {
            switch (head)
            {
            case DevType.行车:
                AwcDataRecive?.Invoke(devName, (DeviceAWC)module);
                break;

            case DevType.固定辊台:
                FrtDataRecive?.Invoke(devName, (DeviceFRT)module);
                break;

            case DevType.摆渡车:
                ArfDataRecive?.Invoke(devName, (DeviceARF)module);
                break;

            case DevType.运输车:
                RgvDataRecive?.Invoke(devName, (DeviceRGV)module);
                break;

            case DevType.包装线辊台:
                PklDataRecive?.Invoke(devName, (DevicePKL)module);
                break;

            default:
                break;
            }
        }
        protected bool IsDriverEnabled(DevType devType)
        {
            switch (devType)
            {
            case DevType.vJoy:
                log.Info("vJoy Version: " + _Joystick.GetvJoyVersion());
                if (!_Joystick.vJoyEnabled())
                {
                    log.Info("  vJoy driver not enabled: Failed Getting vJoy attributes.");
                    return(false);
                }
                break;

            case DevType.vXbox:
                if (!_Joystick.isVBusExist())
                {
                    log.Info("ScpVBus driver not installed!");
                    return(false);
                }
                else
                {
                    byte nSlots = 0;
                    _Joystick.GetNumEmptyBusSlots(ref nSlots);
                    log.Info("ScpVBus enabled with " + nSlots.ToString() + " empty bus slots.");
                }
                break;
            }
            return(true);
        }
Exemple #4
0
        public static IBaseModule Parse(DevType type, byte[] msg)
        {
            try
            {
                switch (type)
                {
                case DevType.行车:
                    return(new AwcMessage(msg).Module);

                case DevType.固定辊台:
                    return(new FrtMessage(msg).Module);

                case DevType.摆渡车:
                    return(new ArfMessage(msg).Module);

                case DevType.运输车:
                    return(new RgvMessage(msg).Module);

                case DevType.包装线辊台:
                    return(new PklMessage(msg).Module);

                default:
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceWarning(string.Format("Failed to parse message e:{0}", ex.Message));
                return(null);
            }
        }
Exemple #5
0
    /// <summary>
    /// 点击移除分类
    /// </summary>
    /// <param name="i"></param>
    public void OnButtonRemove(DevType devType)
    {
        EditorObjectSelection.Instance.ClearSelection(false);
        List <GameObject>   objList = new List <GameObject>();
        DeviceEditUIManager manager = DeviceEditUIManager.Instacne;

        if (devType == DevType.noramDev)
        {
            normalDevTemp.Clear();
        }
        else if (devType == DevType.cameraDev)
        {
            cameraDevTemp.Clear();
        }
        else if (devType == DevType.doorDev)
        {
            doorDevTemp.Clear();
        }
        else if (devType == DevType.fireDev)
        {
            fireDevTemp.Clear();
        }
        else
        {
            borderDevTemp.Clear();
        }
        objList.AddRange(normalDevTemp);
        objList.AddRange(cameraDevTemp);
        objList.AddRange(doorDevTemp);
        objList.AddRange(borderDevTemp);
        objList.AddRange(fireDevTemp);
        EditorObjectSelection.Instance.SetSelectedObjects(objList, false);
    }
Exemple #6
0
 public bool InitDriver()
 {
     try
     {
         int res = mLib.MV_Usb2Init(string.Format("MVCCamera{0}", devIndex), out devIndex, ref capinfo, out handle);
         if (res == 0 && handle != IntPtr.Zero)
         {
             IsInit = true;
             res    = mLib.MV_SetUsb2ADCMode(handle, luminance);
             DevType type = DevType.MVC1000MF;
             res        = mLib.MV_Usb2GetDeviceType(handle, ref type);
             sourceName = type.ToString() + devIndex.ToString();
             //res = mLib.MV_Usb2SetMirrorMode(handle, 1);//采集数据进行水平垂直翻转 bit0 水平镜像 bit1 垂直镜像 效率较低
             return(res == 0);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         UninitDriver();
         return(false);
     }
 }
 public DeveloperDto(string devCode, string name, DevType devType, List <TaskToDoDto> tasksToDo)
 {
     DevCode   = devCode;
     Name      = name;
     DevType   = devType;
     TasksToDo = tasksToDo;
 }
        /// <summary>
        /// 目录查询响应消息处理
        /// </summary>
        /// <param name="localEP">本地终结点</param>
        /// <param name="remoteEP">远程终结点</param>
        /// <param name="request">sip请求</param>
        /// <param name="catalog">目录结构体</param>
        private void CatalogHandle(SIPEndPoint localEP, SIPEndPoint remoteEP, SIPRequest request, Catalog catalog)
        {
            try
            {
                catalog.DeviceList.Items.FindAll(item => item != null).ForEach(catalogItem =>
                {
                    catalogItem.RemoteEP = remoteEP.ToHost();
                    var devCata          = DevType.GetCataType(catalogItem.DeviceID);
                    //logger.Debug("CatalogHandle: DevCataType=" + devCata);
                    if (devCata == DevCataType.Device)
                    {
                        if (!_nodeMonitorService.ContainsKey(catalogItem.DeviceID))
                        {
                            //remoteEP.Port = _LocalSipAccount.RemotePort;
                            _nodeMonitorService.TryAdd(catalogItem.DeviceID, new SIPMonitorCore(this, _transport, _sipAccountStorage)
                            {
                                RemoteEndPoint = remoteEP,
                                DeviceId       = catalogItem.DeviceID
                            });
                            logger.Debug("CatalogHandle: nodeMonitorService.Count=" + _nodeMonitorService.Count);
                            logger.Debug("CatalogHandle: nodeMonitorService.TryAdd DeviceId=" + catalogItem.DeviceID);
                        }
                    }
                    //   CommandType cmdType = i == 0 ? CommandType.Play : CommandType.Playback;
                });

                OnCatalogReceived?.Invoke(catalog);
            }
            catch (Exception ex)
            {
                logger.Warn("CatalogHandle Exception: " + ex.Message);
            }
        }
Exemple #9
0
 public PLAYER_INFO(int i, PLAYER_TYPE t, CHARACTER c, DevType[] _dev = null)
 {
     id = i;
     type = t;
     character = c;
     dev = _dev;
 }
Exemple #10
0
 public Developer(DevCode id, string name, DevType devType)
 {
     Id         = id;
     Name       = name;
     DevType    = devType;
     _tasksToDo = new Collection <TaskToDo>();
 }
Exemple #11
0
 public DeveloperDto(int id, string name, DevType devType, GoalDto goal, List <TaskToDoDto> tasksToDo)
 {
     Id        = id;
     Name      = name;
     DevType   = devType;
     Goal      = goal;
     TasksToDo = tasksToDo;
 }
Exemple #12
0
 public Shield(Fight scene, Hashtable parameters, RectangleD rect, int owner, DevType[] dev)
     : base(scene, parameters)
 {
     this.owner = owner;
     this.dev = dev;
     MakeModel("");
     RecVisible.Copy(rect);
     RecCollision = RecVisible;
 }
Exemple #13
0
 // This is the Select method to selects a single DevType_view item with the id
 // USAGE: <asp:FormView SelectMethod="GetItem">
 public IMserver.Models.DevType GetItem([FriendlyUrlSegmentsAttribute(0)] string TypeId)
 {
     if (TypeId == null)
     {
         return(null);
     }
     ex   = p => p.TypeId == new ObjectId(TypeId);
     item = _DevType.FindOneBy(ex);
     return(item);
 }
Exemple #14
0
        private dynamic GetDays(DateTime start, DateTime end, int contractHour, DevType devType, float version, bool tsDays = false)
        {
            dynamic archive = new ExpandoObject();

            archive.records   = new List <dynamic>();
            archive.emptyDays = new List <DateTime>();

            for (DateTime date = start; date < end; date = date.AddDays(1))
            {
                var     dt  = date.Date.AddDays(1).AddHours(contractHour);
                dynamic day = null;
                for (int i = 0; i < TRY_COUNT; i++)
                {
                    if (cancel())
                    {
                        archive.success = false;
                        archive.error   = "опрос отменен";
                        return(archive);
                    }

                    day = GetArchiveRecord(dt, devType, version, tsDays, true);
                    if (day.success || (!day.success && !day.badChannel))
                    {
                        break;
                    }

                    //log(string.Format("суточная запись {0:dd.MM.yy} не получена, ошибка: {1}", date, day.error));
                }

                if (!day.success)
                {
                    log(string.Format("суточная запись {0:dd.MM.yy} не получена, ошибка: {1}", date, day.error));
                    if (day.badChannel)
                    {
                        return(day);
                    }
                    archive.emptyDays.Add(dt);
                    continue;
                }


                //foreach (var rec in day.records)
                //{
                //    rec.date = rec.date.AddHours(contractHour).Date;
                //}

                log(string.Format("суточная запись {0:dd.MM.yy HH:mm} получена", date));
                records(day.records);
                archive.records.AddRange(day.records);
            }

            archive.success = true;
            archive.error   = string.Empty;
            return(archive);
        }
Exemple #15
0
    /// <summary>
    /// 初始化按钮
    /// </summary>
    /// <param name="type"></param>
    /// <param name="child"></param>
    private void InitButton(DevType type, Transform child)
    {
        Button button = child.GetComponentInChildren <Button>();

        if (button)
        {
            button.onClick.AddListener(() =>
            {
                OnButtonRemove(type);
            });
        }
    }
Exemple #16
0
        // GET: ModelProperty/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DevType model = bll.DevTypes.Find(id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(model));
        }
 public ActionResult Edit(DevType Property)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bll.DevTypes.Edit(Property);
             return(RedirectToAction("Index"));
         }
         return(View(Property));
     }
     catch
     {
         return(View());
     }
 }
Exemple #18
0
        private dynamic GetDaysIsPresent(DateTime start, DateTime end, DevType devType, float version)
        {
            dynamic answer = new ExpandoObject();

            answer.success     = false;
            answer.error       = string.Empty;
            answer.supportDays = false;

            var arc = 7;

            if (devType == DevType.TC215)
            {
                arc = 3;
            }

            for (int i = 0; i < TRY_COUNT; i++)
            {
                if (cancel())
                {
                    answer.success = false;
                    answer.error   = "опрос отменен";
                    return(answer);
                }

                var data = Send(MakeArchiveRequest(arc, start, end, 1));
                var rsp  = ParseArchiveResponse(data);
                if (!rsp.success)
                {
                    log(string.Format("ошибка при считывании суточных показаний: {0}", rsp.error));
                    continue;
                }

                var ar = ParseArchiveRecords(rsp.rows, devType, version);
                if (ar.success)
                {
                    List <dynamic> arRecs = ar.records;
                    if (arRecs.Any())
                    {
                        answer.supportDays = true;
                    }
                    return(answer);
                }
                log(string.Format("при считывании суточных показаний: {0}", ar.error));
            }

            return(answer);
        }
Exemple #19
0
        private dynamic GetHours(DateTime start, DateTime end, DevType devType, float version)
        {
            dynamic archive = new ExpandoObject();

            archive.records = new List <dynamic>();

            //var head = "date\tGONo\tAONo\tVb\tVbT\tV\tVo\tpMP\tTMP\tKMP\tCMP\tT2Tek\tSt2\tSt4\tSt7\tSt6\tStSy";
            //  log(head);

            var startHour = start.Date.AddHours(start.Hour);

            for (DateTime date = startHour; date < end; date = date.AddHours(1))
            {
                dynamic hour = null;
                for (int i = 0; i < TRY_COUNT; i++)
                {
                    if (cancel())
                    {
                        archive.success = false;
                        archive.error   = "опрос отменен";
                        return(archive);
                    }

                    var dt = date.AddHours(1);
                    hour = GetArchiveRecord(dt, devType, version);
                    if (hour.success)
                    {
                        break;
                    }
                }

                if (!hour.success)
                {
                    log(string.Format("часовая запись {0:dd.MM.yy HH:00} не получена, ошибка: {1}", date, hour.error));
                    return(hour);
                }

                log(string.Format("часовая запись {0:dd.MM.yy HH:mm} получена", date));
                records(hour.records);
                archive.records.AddRange(hour.records);
            }

            archive.success = true;
            archive.error   = string.Empty;
            return(archive);
        }
Exemple #20
0
        /// <summary>
        /// 通知信息接收
        /// </summary>
        /// <param name="type"></param>
        /// <param name="data"></param>
        internal override void NoticeDataReceive(DevType head, byte[] data)
        {
            ReciveDataHandler tmp = ReceiveData;

            if (tmp != null)
            {
                try
                {
                    IBaseModule message = MessageParser.Parse(head, data);

                    tmp(m_DevName, head, message);
                }
                catch (Exception e)
                {
                    log.LOG(e);
                    //Console.WriteLine(ex.Message + ex.StackTrace);
                }
            }
        }
        private dynamic SetConsumerCastle(DevType type, string password, bool?isConsumer)
        {
            dynamic answer = new ExpandoObject();

            answer.password = (string.IsNullOrEmpty(password)) ? GetDefaultPassword(type) : password;
            if (isConsumer == null)
            {
                var passResponse = Send(MakeRequest(RequestType.Write, "4:171.0", answer.password));
                var passAns      = ParseResponse(passResponse);
                if (!passAns.success)
                {
                    return(passAns);
                }

                //TODO: если на passAns отвечает ACK(06h) - неправильный пароль

                if (passAns != null && !string.IsNullOrEmpty(passAns.Raw) && passAns.Raw.Contains("17"))
                {
                    SendInstant(MakeRequest(RequestType.Write, "3:171.0", answer.password));
                }
            }
            else if (isConsumer == true)
            {
                var passAns = ParseResponse(Send(MakeRequest(RequestType.Write, "4:171.0", answer.password)));
                if (!passAns.success)
                {
                    return(passAns);
                }
            }
            else
            {
                var passAns = ParseResponse(Send(MakeRequest(RequestType.Write, "3:171.0", answer.password)));
                if (!passAns.success)
                {
                    return(passAns);
                }
            }

            answer.error   = string.Empty;
            answer.success = true;

            return(answer);
        }
Exemple #22
0
 public DevTypeIni()
 {
     try
     {
         if (_devType.FindAll().FirstOrDefault() == null)
         {
             DevType myDevType = new DevType();
             myDevType.TypeName = "油色谱在线监测";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "GIS局放";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "变压器局放";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "开关柜测温";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "铁芯接地";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "避雷器";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "容性设备";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "SF6微水密度";
             _devType.Insert(myDevType);
             myDevType          = new DevType();
             myDevType.TypeName = "SF6泄露";
             _devType.Insert(myDevType);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("数据库连接出错!请检查数据库!");
         Console.WriteLine(ex.Message);
         return;
     }
 }
        private string GetDefaultPassword(DevType type)
        {
            var pass = "******";

            switch (type)
            {
            case DevType.EK260:
            case DevType.EK270:
                pass = "******";
                break;

            case DevType.TC210:
            case DevType.TC215:
            case DevType.TC220:
                pass = "******";
                break;
            }
            log(string.Format("{0}: принят пароль по умолчанию '{1}'", type, pass));
            return(pass);
        }
        public override object Clone()
        {
            Data obj = new Data(this.LibType, this.Name);

            obj.Description = Description;
            if (this.DevType != null)
            {
                obj.DevType = (ObjectRef)DevType.Clone();
            }
            if (_data != null)
            {
                XmlDocument doc  = new XmlDocument();
                XmlNode     node = doc.CreateElement("Clone");
                XmlSerialization.WriteValue(node, _data);
                object v;
                XmlSerialization.ReadValue(node, out v);
                obj.DataValue = v;
            }
            return(obj);
        }
Exemple #25
0
        /// <summary>
        /// 固定辊台作业判断执行接货?
        /// </summary>
        public static bool JobPartFRT_Take(string jobid, DevType dev)
        {
            bool result = false;

            switch (dev)
            {
            case DevType.AGV:
                // ? NDC 确认AGV是否到达卸货点
                result = mNDCControl.IsUnLoadReady(Convert.ToInt32(jobid.Substring(1)));
                break;

            case DevType.摆渡车:
                result = mArf.IsTaskConform(jobid, TaskStatus.ongivesite);
                break;

            default:
                break;
            }
            return(result);
        }
Exemple #26
0
        static void dev_axes(int hDev)
        {
            string[] j_axes = new string[8] {
                " X ", " Y ", " Z ", "Rx ", "Ry ", "Rz ", "S1 ", "S2 "
            };
            string[] x_axes = new string[6] {
                " X ", " Y ", "TR ", "Rx ", "Ry ", "TL "
            };
            bool    Exist = false;
            DevType type  = DevType.vJoy;
            int     lim   = 6;

            if (type == DevType.vJoy)
            {
                lim = 8;
            }


            joystick.GetDevType(hDev, ref type);

            Console.WriteLine("");
            for (uint i = 1; i <= lim; i++)
            {
                joystick.isAxisExist(hDev, i, ref Exist);
                if (Exist)
                {
                    if (type == DevType.vJoy)
                    {
                        Console.Write(j_axes[i - 1]);
                    }
                    else
                    {
                        Console.Write(x_axes[i - 1]);
                    }
                }
                else
                {
                    Console.Write("   ");
                }
            }
        }
Exemple #27
0
        /// <summary>
        /// 目录查询响应消息处理
        /// </summary>
        /// <param name="localEP">本地终结点</param>
        /// <param name="remoteEP">远程终结点</param>
        /// <param name="request">sip请求</param>
        /// <param name="catalog">目录结构体</param>
        private void CatalogHandle(SIPEndPoint localEP, SIPEndPoint remoteEP, SIPRequest request, Catalog catalog)
        {
            foreach (var cata in catalog.DeviceList.Items)
            {
                if (cata == null)
                {
                    continue;
                }
                cata.RemoteEP = remoteEP.ToHost();
                DevCataType devCata = DevType.GetCataType(cata.DeviceID);
                if (devCata != DevCataType.Device)
                {
                    continue;
                }
                for (int i = 0; i < 2; i++)
                {
                    CommandType cmdType = i == 0 ? CommandType.Play : CommandType.Playback;
                    MonitorKey  key     = new MonitorKey()
                    {
                        DeviceID = cata.DeviceID,
                        CmdType  = cmdType
                    };
                    lock (MonitorService)
                    {
                        if (MonitorService.ContainsKey(key))
                        {
                            continue;
                        }
                        remoteEP.Port = _account.KeepaliveInterval;
                        ISIPMonitorService monitor = new SIPMonitorCore(this, cata.DeviceID, remoteEP, _account);
                        MonitorService.Add(key, monitor);
                    }
                }
            }

            if (OnCatalogReceived != null)
            {
                OnCatalogReceived(catalog);
            }
        }
Exemple #28
0
        /// <summary>
        /// 获取设备类型转义
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private string GetDevTypeS(DevType dt)
        {
            switch (dt)
            {
            case DevType.行车:
                return(DeviceType.行车);

            case DevType.固定辊台:
                return(DeviceType.固定辊台);

            case DevType.摆渡车:
                return(DeviceType.摆渡车);

            case DevType.运输车:
                return(DeviceType.运输车);

            case DevType.包装线辊台:
                return(DeviceType.包装线辊台);

            default:
                return(null);
            }
        }
Exemple #29
0
        public void OnCatalogReceived(Catalog obj)
        {
            if (!Catalogs.ContainsKey(obj.DeviceID))
            {
                Catalogs.Add(obj.DeviceID, obj);
                logger.Debug("OnCatalogReceived: " + JsonConvert.SerializeObject(obj));
            }
            if (GBSIPTransactions.ContainsKey(obj.DeviceID))
            {
                SIPTransaction _SIPTransaction = GBSIPTransactions[obj.DeviceID];
                obj.DeviceList.Items.FindAll(item => item != null).ForEach(catalogItem =>
                {
                    var devCata = DevType.GetCataType(catalogItem.DeviceID);
                    if (devCata == DevCataType.Device)
                    {
                        _SIPTransaction.TransactionRequestFrom.URI.User = catalogItem.DeviceID;
                        string gbname = "GB_" + catalogItem.Name;
                        //string gbname = "gb" + _SIPTransaction.TransactionRequest.RemoteSIPEndPoint.Address.ToString();
                        if (!string.IsNullOrEmpty(catalogItem.ParentID) && !obj.DeviceID.Equals(catalogItem.DeviceID))
                        {
                            gbname = "GB_" + catalogItem.Name;
                        }
                        logger.Debug("OnCatalogReceived.DeviceDmsRegister: catalogItem=" + JsonConvert.SerializeObject(catalogItem));

                        //query device info from db
                        string edit = IsDeviceExisted(catalogItem.DeviceID) ? "updated" : "added";

                        //Device Dms Register
                        DeviceDmsRegister(_SIPTransaction, gbname);

                        //Device Edit Event
                        DeviceEditEvent(catalogItem.DeviceID, edit);
                    }
                });
            }
        }
Exemple #30
0
 public ActionResult Create(DevType Property)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var result = bll.DevTypes.Add(Property);
             if (result)
             {
                 return(Json(new { success = result }));
             }
             else
             {
                 return(Json(new { success = result, errors = bll.DevTypes.ErrorMessage }));
             }
             //return RedirectToAction("Index");
         }
         return(View(Property));
     }
     catch
     {
         return(View());
     }
 }
        /// <summary>
        /// 目录查询响应消息处理
        /// </summary>
        /// <param name="localEP">本地终结点</param>
        /// <param name="remoteEP">远程终结点</param>
        /// <param name="request">sip请求</param>
        /// <param name="catalog">目录结构体</param>
        private void CatalogHandle(SIPEndPoint localEP, SIPEndPoint remoteEP, SIPRequest request, Catalog catalog)
        {
            catalog.DeviceList.Items.FindAll(item => item != null).ForEach(catalogItem =>
            {
                catalogItem.RemoteEP = remoteEP.ToHost();
                var devCata          = DevType.GetCataType(catalogItem.DeviceID);
                if (devCata != DevCataType.Device)
                {
                    if (!_nodeMonitorService.ContainsKey(catalogItem.DeviceID))
                    {
                        remoteEP.Port = _LocalSipAccount.KeepaliveInterval;
                        _nodeMonitorService.TryAdd(catalogItem.DeviceID, new SIPMonitorCoreService(this, _transport, _sipAccountStorage)
                        {
                            RemoteEndPoint = remoteEP,
                            DeviceId       = catalogItem.DeviceID
                        });
                    }
                }

                //   CommandType cmdType = i == 0 ? CommandType.Play : CommandType.Playback;
            });

            OnCatalogReceived?.Invoke(catalog);
        }
Exemple #32
0
 public Vector2 Stick(DevType[] dev = null)
 {
     if (dev == null) dev = all;
     return Stick(cur, dev);
 }
Exemple #33
0
 public Vector2 Stick(int c, DevType[] dev = null)
 {
     Vector2 ans = new Vector2( 0.0f, 0.0f );
     foreach (DevType d in dev)
     {
         Vector2 tmp = new Vector2( 0.0f, 0.0f );
         switch (d)
         {
             case DevType.KEYBOARD:
                 if (isOn(BUTTON.LEFT, dev))     tmp.X -= 1.0f;
                 if (isOn(BUTTON.RIGHT, dev))    tmp.X += 1.0f;
                 if (isOn(BUTTON.UP, dev))       tmp.Y -= 1.0f;
                 if (isOn(BUTTON.DOWN, dev))     tmp.Y += 1.0f;
                 break;
             case DevType.GAMEPAD1:
                 if (gs1[c].IsConnected)
                 {
                     tmp = gs1[c].ThumbSticks.Left;
                     tmp.Y = -tmp.Y;
                     if (gs1[c].IsButtonDown(Buttons.DPadLeft))
                     {
                         tmp.X = -1;
                     }
                     if (gs1[c].IsButtonDown(Buttons.DPadRight))
                     {
                         tmp.X = 1;
                     }
                     if (gs1[c].IsButtonDown(Buttons.DPadUp))
                     {
                         tmp.Y = 1;
                     }
                     if (gs1[c].IsButtonDown(Buttons.DPadDown))
                     {
                         tmp.Y = -1;
                     }
                 }
                 break;
             case DevType.GAMEPAD2:
                 if (gs2[c].IsConnected)
                 {
                     tmp = gs2[c].ThumbSticks.Left;
                     tmp.Y = -tmp.Y;
                     if (gs2[c].IsButtonDown(Buttons.DPadLeft))
                     {
                         tmp.X = -1;
                     }
                     if (gs2[c].IsButtonDown(Buttons.DPadRight))
                     {
                         tmp.X = 1;
                     }
                     if (gs2[c].IsButtonDown(Buttons.DPadUp))
                     {
                         tmp.Y = 1;
                     }
                     if (gs2[c].IsButtonDown(Buttons.DPadDown))
                     {
                         tmp.Y = -1;
                     }
                 }
                 break;
             case DevType.CPU:
                 tmp = cpu[c].stick;
                 tmp.Y = -tmp.Y;
                 break;
             default:
                 break;
         }
         if (ans.LengthSquared() < tmp.LengthSquared()) ans = tmp;
     }
     return ans;
 }
Exemple #34
0
 public bool isUp(BUTTON b, DevType[] dev = null)
 {
     if (dev == null) dev = all;
     return !isOn(cur, b, dev) && isOn(pre, b, dev);
 }
Exemple #35
0
 public bool isStick(int c, float th, BUTTON b, DevType[] dev = null)
 {
     if (dev == null) dev = all;
     float stick;
     foreach (DevType d in dev)
     {
         switch (d)
         {
             case DevType.KEYBOARD:
                 if (ks[c].IsKeyDown(kbinfo[(int)b].key))
                     return true;
                 break;
             case DevType.GAMEPAD1:
                 stick = 0.0f;
                 if (gs1[c].IsConnected)
                 {
                     switch (b)
                     {
                         case BUTTON.LEFT: stick = -gs1[c].ThumbSticks.Left.X; break;
                         case BUTTON.RIGHT: stick = gs1[c].ThumbSticks.Left.X; break;
                         case BUTTON.UP: stick = gs1[c].ThumbSticks.Left.Y; break;
                         case BUTTON.DOWN: stick = -gs1[c].ThumbSticks.Left.Y; break;
                     }
                     if (stick > th) return true;
                     switch (b)
                     {
                         case BUTTON.LEFT: if (gs1[c].IsButtonDown(Buttons.DPadLeft)) return true; break;
                         case BUTTON.RIGHT: if (gs1[c].IsButtonDown(Buttons.DPadRight)) return true; break;
                         case BUTTON.UP: if (gs1[c].IsButtonDown(Buttons.DPadUp)) return true; break;
                         case BUTTON.DOWN: if (gs1[c].IsButtonDown(Buttons.DPadDown)) return true; break;
                     }
                 }
                 break;
             case DevType.GAMEPAD2:
                 stick = 0.0f;
                 if (gs2[c].IsConnected)
                 {
                     switch (b)
                     {
                         case BUTTON.LEFT: stick = -gs2[c].ThumbSticks.Left.X; break;
                         case BUTTON.RIGHT:  stick = gs2[c].ThumbSticks.Left.X; break;
                         case BUTTON.UP: stick = gs2[c].ThumbSticks.Left.Y; break;
                         case BUTTON.DOWN: stick = -gs2[c].ThumbSticks.Left.Y; break;
                     }
                     if (stick > th) return true;
                     switch (b)
                     {
                         case BUTTON.LEFT: if (gs2[c].IsButtonDown(Buttons.DPadLeft)) return true; break;
                         case BUTTON.RIGHT: if (gs2[c].IsButtonDown(Buttons.DPadRight)) return true; break;
                         case BUTTON.UP: if (gs2[c].IsButtonDown(Buttons.DPadUp)) return true; break;
                         case BUTTON.DOWN: if (gs2[c].IsButtonDown(Buttons.DPadDown)) return true; break;
                     }
                 }
                 break;
             case DevType.CPU:
                 stick = 0.0f;
                 switch (b)
                 {
                     case BUTTON.LEFT: stick = -cpu[c].stick.X; break;
                     case BUTTON.RIGHT: stick = cpu[c].stick.X; break;
                     case BUTTON.UP: stick = cpu[c].stick.Y; break;
                     case BUTTON.DOWN: stick = -cpu[c].stick.Y; break;
                 }
                 if (stick > th) return true;
                 break;
             default: break;
         }
     }
     return false;
 }
Exemple #36
0
 public bool isOn(int c, BUTTON b, DevType[] dev = null)
 {
     if (dev == null) dev = all;
     int n = (int)b;
     if ((int)BUTTON.LEFT <= (int)b && (int)b <= (int)BUTTON.DOWN) return isStick(c, 0.5f, b, dev);
     foreach (DevType d in dev)
     {
         switch (d)
         {
             case DevType.KEYBOARD:
                 if (ks[c].IsKeyDown(kbinfo[n].key))
                     return true;
                 break;
             case DevType.GAMEPAD1:
                 if (gs1[c].IsButtonDown(kbinfo[n].but))
                     return true;
                 break;
             case DevType.GAMEPAD2:
                 if (gs2[c].IsButtonDown(kbinfo[n].but))
                     return true;
                 break;
             case DevType.CPU:
                 if (cpu[c].button[n])
                     return true;
                 break;
             default:
                 break;
         }
     }
     return false;
 }
Exemple #37
0
 public bool isOn(BUTTON b, DevType[] dev = null)
 {
     if (dev == null) dev = all;
     return isOn(cur, b, dev);
 }
Exemple #38
0
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="task"></param>
        public void AddTask(string jobid, string area, TaskTypeEnum tasktype, int goodsnum, DevType fromdev, DevType todev, string frt = null)
        {
            int id = ADS.ID;

            ADS.PlusID();
            TaskFRT t = new TaskFRT()
            {
                id         = id,
                jobid      = jobid,
                area       = area,
                tasktype   = tasktype,
                goodsnum   = goodsnum,
                fromdev    = fromdev,
                todev      = todev,
                taskstatus = TaskStatus.init,
                frt        = frt,
                device     = new DevInfoFRT()
            };

            task.Add(t);
            t.InsertDB();
        }