/// <summary>
        /// 根据通讯类型格式化配置实例
        /// </summary>
        /// <param name="type"></param>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static IComConfig FormatConfiguration(ComType type, object instance)
        {
            switch (type)
            {
            case ComType.SerialPort:
                return((SerialPortConfigModel)instance);

            case ComType.TCP:
                return((TcpIpConfigModel)instance);

            case ComType.UDP:
                return((UdpConfigModel)instance);

            case ComType.GPIB:
                return((GPIBConfigModel)instance);

            case ComType.USB:
                return((UsbConfigModel)instance);

            case ComType.CAN:
                return((CANConfigModel)instance);

            default:
                return(null);
            }
        }
Example #2
0
        /// <summary>
        ///[ComType]表查询实体的方法
        /// </summary>
        public static ComType getComTypeById(int id)
        {
            ComType comtype = null;

            string sql = "select * from ComType where id=@id";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@id", id)
            };
            DataTable dt = DBHelper.GetDataSet(sql, sp);

            if (dt.Rows.Count > 0)
            {
                comtype = new ComType();
                foreach (DataRow dr in dt.Rows)
                {
                    comtype.Id         = Convert.ToInt32(dr["id"]);
                    comtype.TypeName   = Convert.ToString(dr["typeName"]);
                    comtype.Typeremark = Convert.ToString(dr["typeremark"]);
                }
            }

            return(comtype);
        }
        /// <summary>
        /// 创建通讯接口实例
        /// </summary>
        /// <param name="type">通讯类型</param>
        /// <returns></returns>
        public static ICommunication CreateInstance(ComType type)
        {
            switch (type)
            {
            case ComType.SerialPort:
                return(new SerialPortHelper());

            case ComType.TCP:
                return(new TcpIpHelper());

            case ComType.UDP:
                return(new UdpHelper());

            case ComType.GPIB:
                return(new GPIBHelper());

            case ComType.USB:
                return(new UsbHelper());

            case ComType.CAN:
                return(new CANHelper());

            default:
                return(null);
            }
        }
Example #4
0
        public ICommand GetCommand(byte[] request)
        {
            intCommand = null;

            var buf     = new ByteBuffer(request);
            var message = Message.GetRootAsMessage(buf);

            command = message.Comtype;
            switch (command)
            {
            case ComType.GetChildrenConts:
            {
                intCommand = new CommandGetchildrenContainers(message.DbID);
                break;
            }

            case ComType.SavePara:
            {
                var senttlist = SentenceMap.BuildFromMessage(message);
                var docID     = -1;     // TODO docID надо передавать в первом элементе таблицы documents сообщения
                intCommand = new CommandSaveParagraph(message.DbID, docID, senttlist);
                break;
            }

            case ComType.ReadPara:
            {
                var ParagraphID = message.DbID;
                intCommand = new CommandReadParagraph(message.DbID);
                break;
            }

            case ComType.GetWord:
            {
                Param?par      = message.Params(0);
                var   strParam = "";
                if (par.HasValue)
                {
                    strParam = par.Value.Value;
                }
                intCommand = new CommandGetWord(strParam);
                break;
            }

            case ComType.SaveLex:
            {
                Param?par      = message.Params(0);
                var   strParam = "";
                if (par.HasValue)
                {
                    strParam = par.Value.Value;
                }
                intCommand = new CommandSaveLex(strParam);
                break;
            }

            default:
                break;
            }
            return(intCommand);
        }
Example #5
0
 protected void imgbtnsave_Click(object sender, ImageClickEventArgs e)
 {
     if (tbxTypeName.Text.ToString() == "")
     {
         this.lblTypename.Text = "<span style='Color:red'>类别名称不能为空!<span>";
     }
     else if (CheckTypeName(tbxTypeName.Text.ToString()) > 0)
     {
         this.lblTypename.Text = "<span style='Color:red'>类别名称已存在<span>";
     }
     else
     {
         if (CheckTypeName(tbxTypeName.Text.ToString()) > 0)
         {
             //Response.Write("<script language=javascript>alert( '类别名称已存在!');window.location.href='ComAddType.aspx';</script>");
             this.lblTypename.Text = "<span style='color:red'>类别名称已存在!</span>";
         }
         else
         {
             ComType type = new ComType();
             type.TypeName   = this.tbxTypeName.Text.ToString();
             type.Typeremark = this.tbxTypeRemark.Text.ToString();
             ComTypeManager.addComType(type);
             getType();
             this.tbxTypeName.Text = "";
             this.lblTypename.Text = "";
         }
     }
 }
Example #6
0
 internal ComTypeDesc(ITypeInfo typeInfo, ComType memberType, ComTypeLibDesc typeLibDesc) : base(memberType)
 {
     if (typeInfo != null)
     {
         ComRuntimeHelpers.GetInfoFromType(typeInfo, out _typeName, out _documentation);
     }
     _typeLibDesc = typeLibDesc;
 }
Example #7
0
 internal ComTypeDesc(ITypeInfo typeInfo, ComType memberType, ComTypeLibDesc typeLibDesc)
     : base(memberType)
 {
     if (typeInfo != null) {
         ComRuntimeHelpers.GetInfoFromType(typeInfo, out _typeName, out _documentation);
     }
     _typeLibDesc = typeLibDesc;
 }
Example #8
0
        /// <summary>
        ///[ComType]表添加的方法
        /// </summary>
        public static int addComType(ComType comtype)
        {
            string sql = "insert into ComType([typeName],[typeremark]) values (@typeName,@typeremark)";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@typeName", comtype.TypeName),
                new SqlParameter("@typeremark", comtype.Typeremark)
            };
            return(DBHelper.ExecuteCommand(sql, sp));
        }
Example #9
0
        public ICommand GetCommand(byte[] request)
        {
            intCommand = null;

            var buf     = new ByteBuffer(request);
            var message = Message.GetRootAsMessage(buf);

            command = message.Comtype;
            switch (command)
            {
            case ComType.Synt:
            {
                Param?par      = message.Params(0);
                var   strParam = "";
                if (par.HasValue)
                {
                    strParam = par.Value.Value;
                }
                intCommand = new CommandSyntAn(strParam);
                break;
            }

            case ComType.Separ:
            {
                Param?par      = message.Params(0);
                var   strParam = "";
                if (par.HasValue)
                {
                    strParam = par.Value.Value;
                }
                intCommand = new CommandSepar(strParam);
                break;
            }

            case ComType.Repar:
            {
                SentenceMap sentence = null;
                var         sentlist = SentenceMap.BuildFromMessage(message);
                if (sentlist.Count > 0)
                {
                    sentence = sentlist[0];
                }
                intCommand = new CommandRepar(sentence);
                break;
            }

            case ComType.Morph:
                break;

            default:
                break;
            }
            return(intCommand);
        }
Example #10
0
 // regular dialogue communication initializer
 public void BeginCommunication(ComType type, Dialogue dialogue, ComController currentController)
 {
     if (_active)
     {
         Debug.Log("ComManager BeginCommunication Error: Communications already active, cannot begin new communication session!");
     }
     else
     {
         _currentController = currentController; // reference to current com controller
         BeginCommunication(type, dialogue);
     }
 }
Example #11
0
        /// <summary>
        ///[ComType]表修改的方法
        /// </summary>
        public static int updateComTypeById(ComType comtype)
        {
            string sql = "update ComType set typeName=@typeName,typeremark=@typeremark where id=@id";

            SqlParameter[] sp = new SqlParameter[]
            {
                new SqlParameter("@id", comtype.Id),
                new SqlParameter("@typeName", comtype.TypeName),
                new SqlParameter("@typeremark", comtype.Typeremark)
            };
            return(DBHelper.ExecuteCommand(sql, sp));
        }
Example #12
0
        static void Main2222(string[] args)
        {
            var h5 = H5F.create(@"D:\test.h5", H5F.ACC_TRUNC);

            var typeId = H5T.create(H5T.class_t.COMPOUND, new IntPtr(40));

            var strtype = H5T.copy(H5T.C_S1);

            H5T.set_size(strtype, new IntPtr(16));

            H5T.insert(typeId, "Name", new IntPtr(0), strtype);
            H5T.insert(typeId, "x_pos", new IntPtr(16), H5T.NATIVE_INT32);
            H5T.insert(typeId, "y_pos", new IntPtr(20), H5T.NATIVE_INT32);
            H5T.insert(typeId, "Mass", new IntPtr(24), H5T.NATIVE_FLOAT);
            H5T.insert(typeId, "Temperature", new IntPtr(32), H5T.NATIVE_DOUBLE);

            ulong[] dims       = new ulong[] { 10000 };
            ulong[] chunk_size = new ulong[] { 1000 };

            var spaceid = H5S.create_simple(dims.Length, dims, null);


            var dcpl = H5P.create(H5P.DATASET_CREATE);

            H5P.set_layout(dcpl, H5D.layout_t.COMPACT);
            H5P.set_deflate(dcpl, 6);

            H5P.set_chunk(dcpl, chunk_size.Length, chunk_size);



            var datasetid = H5D.create(h5, "Table1", typeId, spaceid, H5P.DEFAULT, dcpl);

            ComType ct = new ComType()
            {
                Name        = "aabb",
                x_pos       = 2,
                y_pos       = 1,
                Mass        = 1.24F,
                Temperature = 45.7,
            };

            IntPtr p = Marshal.AllocHGlobal(40 * (int)dims[0]);

            Marshal.StructureToPtr(ct, p, false);



            H5D.write(datasetid, typeId, spaceid, H5S.ALL, H5P.DEFAULT, p);

            H5F.close(h5);
        }
Example #13
0
 /// <summary>
 /// Constructor, initialize all attributes except id, state and date
 /// </summary>
 /// <param name="clientName">ClientName to initialize</param>
 /// <param name="os">Operative system to initialize</param>
 /// <param name="type">Computer type to initialize</param>
 /// <param name="processor">Processor to initialize</param>
 /// <param name="hardDisk">Hard disk to initialize</param>
 /// <param name="ram">RAM to initialize</param>
 /// <param name="desc">Description to initialize</param>
 /// <param name="graphicCard">Graphic card to initialize</param>
 public Computer(string clientName, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard)
 {
     this.clientName      = clientName;
     this.operativeSystem = os;
     this.type            = type;
     this.processor       = processor;
     this.hardDisk        = hardDisk;
     this.ram             = ram;
     this.desc            = desc;
     this.date            = DateTime.Now;
     this.state           = State.Recibida;
     this.graphicCard     = graphicCard;
 }
Example #14
0
        // choice dialouge communication initialzer
        public void BeginCommunication(ComType type, Dialogue dialogue, Choices choices, int choiceIndex, ResponseType[] responses, ComController currentController)
        {
            if (_active)
            {
                Debug.Log("ComManager BeginCommunication Error: Communications already active, cannot begin new communication session!");
            }
            else
            {
                _currentReponses   = responses; // assing current responses
                _choiceIndex       = choiceIndex;
                _currentChoices    = choices;
                _currentController = currentController; // reference to current com controller

                BeginCommunication(type, dialogue);
            }
        }
Example #15
0
 private void EndComHelper()
 {
     _currentReponses = null;
     _currentIndex    = 0;            // reset current index
     _choiceIndex     = 0;            // reset choices index
     _choiceMade      = false;
     _currentDialogue = null;         // update active dialogue reference
     _active          = false;        // set inactive
     _currentComType  = ComType.None; // update current communication type
     HideDialogueUI();
     _sentences.Clear();
     if (AbilityDescriptionUIController.Instance != null)
     {
         AbilityDescriptionUIController.Instance.Activatable = true;
     }
 }
Example #16
0
     public bool CallFunction(arg1, arg2)
     {
         Type ComType;
         object ComObject;
 
         ComType = Type.GetTypeFromProgID("Registered.ComClass");
         // Create an instance of your COM Registered Object.
         ComObject = Activator.CreateInstance(ComType);
 
         object[] args = new object[2];
         args[0] = arg1;
         args[1] = arg2;
 
         // Call the Method and cast return to whatever it should be.
         return (bool)ComType.InvokeMember("MethodToCall", BindingFlags.InvokeMethod, null, ComObject, args))
     }
Example #17
0
        /// <summary>
        ///根据SQL语句获取实体
        /// </summary>
        public static ComType getComTypeBySql(string sql)
        {
            ComType   comtype = null;
            DataTable dt      = DBHelper.GetDataSet(sql);

            if (dt.Rows.Count > 0)
            {
                comtype = new ComType();
                foreach (DataRow dr in dt.Rows)
                {
                    comtype.Id         = Convert.ToInt32(dr["id"]);
                    comtype.TypeName   = Convert.ToString(dr["typeName"]);
                    comtype.Typeremark = Convert.ToString(dr["typeremark"]);
                }
            }
            return(comtype);
        }
Example #18
0
        /// <summary>
        ///根据SQL语句获取集合
        /// </summary>
        public static IList <ComType> getComTypesBySql(string sql)
        {
            IList <ComType> list = new List <ComType>();
            DataTable       dt   = DBHelper.GetDataSet(sql);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    ComType comtype = new ComType();
                    comtype.Id         = Convert.ToInt32(dr["id"]);
                    comtype.TypeName   = Convert.ToString(dr["typeName"]);
                    comtype.Typeremark = Convert.ToString(dr["typeremark"]);
                    list.Add(comtype);
                }
            }
            return(list);
        }
Example #19
0
        public static void ParameterCreate <T>(SqlCommand cmd, ComType ct, T ent)
        {
            PropertyInfo[] propertys = typeof(T).GetProperties();

            foreach (PropertyInfo pi in propertys)
            {
                string name = pi.Name;
                if (name.ToLower() == "ıd" || name.ToLower() == "id" &&
                    ct == ComType.Insert)
                {
                    continue;
                }
                else if (ct == ComType.Delete && (name.ToLower() != "id" || name.ToLower() != "ıd"))
                {
                    continue;
                }

                object value = pi.GetValue(ent);
                cmd.Parameters.AddWithValue("@" + name, value);
            }
        }
Example #20
0
        // function performing generic steps in beginning communication
        public void BeginCommunication(ComType type, Dialogue dialogue)
        {
            if (_active)
            {
                Debug.Log("ComManager BeginCommunication Error: Communications already active, cannot begin new communication session!");
            }
            else
            {
                if (AbilityDescriptionUIController.Instance != null)
                {
                    AbilityDescriptionUIController.Instance.Activatable = false;
                    AbilityDescriptionUIController.Instance.HideCanvas();
                }


                if (InventoryUIController.Instance != null)
                {
                    InventoryUIController.Instance.HideInventory();
                }
                if (QuestInventoryUIController.Instance != null)
                {
                    QuestInventoryUIController.Instance.HideQuestLog();
                }
                if (TargetUIController.Instance != null)
                {
                    TargetUIController.Instance.TargetChange(null); // remove target UI's target
                }
                _currentDialogue = dialogue;                        // set current dialogue reference
                if (PlayerController.Instance != null)
                {
                    PlayerController.Instance.FreezePlayer(); // freeze player movement
                    PlayerController.Instance.RemoveTarget();
                }

                _active         = true;      // set active
                _currentComType = type;      // update current communication type
                StartCommDialogue(dialogue); // start the dailogue
            }
        }
Example #21
0
 public static Offset <Message> CreateMessage(FlatBufferBuilder builder,
                                              MessType messType             = MessType.mRequest,
                                              ServType serverType           = ServType.svMorph,
                                              ComType comtype               = ComType.Undef,
                                              VectorOffset paramsOffset     = default(VectorOffset),
                                              VectorOffset sentencesOffset  = default(VectorOffset),
                                              VectorOffset paragraphsOffset = default(VectorOffset),
                                              VectorOffset documentsOffset  = default(VectorOffset),
                                              VectorOffset containersOffset = default(VectorOffset),
                                              long dbID = 0)
 {
     builder.StartObject(9);
     Message.AddDbID(builder, dbID);
     Message.AddComtype(builder, comtype);
     Message.AddContainers(builder, containersOffset);
     Message.AddDocuments(builder, documentsOffset);
     Message.AddParagraphs(builder, paragraphsOffset);
     Message.AddSentences(builder, sentencesOffset);
     Message.AddParams(builder, paramsOffset);
     Message.AddServerType(builder, serverType);
     Message.AddMessType(builder, messType);
     return(Message.EndMessage(builder));
 }
Example #22
0
 public Notebook(int id, string clientName, Brand brand, bool charger, bool touchScreen, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard, State state, DateTime date)
     : base(id, clientName, os, type, processor, hardDisk, ram, desc, graphicCard, state, date)
 {
     this.brand       = brand;
     this.touchScreen = touchScreen;
     this.charger     = charger;
 }
Example #23
0
 internal ComTypeLibMemberDesc(ComType kind)
 {
     Kind = kind;
 }
Example #24
0
 public Desktop(int id, string clientName, Cooler cooler, bool dvdBurner, bool extraAccesory, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard)
     : this(clientName, cooler, dvdBurner, extraAccesory, os, type, processor, hardDisk, ram, desc, graphicCard)
 {
     base.ID = id;
 }
Example #25
0
 /// <summary>
 /// Constructor, initialize all attributes
 /// </summary>
 /// <param name="clientName">ClientName to initialize</param>
 /// <param name="cooler">Coolr to initialize</param>
 /// <param name="dvdBurner">DvdBurner to initialize</param>
 /// <param name="extraAccesory">Extracessory to initialize</param>
 /// <param name="os">Operative system to initialize</param>
 /// <param name="type">Computer type to initialize</param>
 /// <param name="processor">Processor to initialize</param>
 /// <param name="hardDisk">Hard disk to initialize</param>
 /// <param name="ram">RAM to initialize</param>
 /// <param name="desc">Description to initialize</param>
 /// <param name="graphicCard">Graphic card to initialize</param>
 public Desktop(string clientName, Cooler cooler, bool dvdBurner, bool extraAccesory, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard)
     : base(clientName, os, type, processor, hardDisk, ram, desc, graphicCard)
 {
     this.cooler        = cooler;
     this.dvdBurner     = dvdBurner;
     this.extraAccesory = extraAccesory;
 }
Example #26
0
 private unsafe static void Type_Match(char *ptr, ComType t1, ComType t2, ComType t3)
 {
 }
Example #27
0
 public ICommunication ExecuteCreation(ComType com) => _factories[com].Create();
Example #28
0
 public Notebook(int id, string clientName, Brand brand, bool charger, bool touchScreen, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard)
     : this(clientName, brand, charger, touchScreen, os, type, processor, hardDisk, ram, desc, graphicCard)
 {
     base.ID = id;
 }
Example #29
0
 /// <summary>
 /// Constructor, initiate all attributes
 /// </summary>
 /// <param name="id">Id to initialize</param>
 /// <param name="clientName">Client name to initialize</param>
 /// <param name="os">Operative system to initialize</param>
 /// <param name="type">Computer type to initialize</param>
 /// <param name="processor">Processor to initialize</param>
 /// <param name="hardDisk">Hard disk to initialize</param>
 /// <param name="ram">RAM to initialize</param>
 /// <param name="desc">Description to initialize</param>
 /// <param name="graphicCard">Graphic card to initialize</param>
 /// <param name="state">State to initialize</param>
 /// <param name="date">Date to initialize</param>
 public Computer(int id, string clientName, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard, State state, DateTime date) : this(clientName, os, type, processor, hardDisk, ram, desc, graphicCard)
 {
     this.id    = id;
     this.state = state;
     this.date  = date;
 }
Example #30
0
 /// <summary>
 /// Constructor, initialize all attributes
 /// </summary>
 /// <param name="id">Id to initialize</param>
 /// <param name="clientName">ClientName to initialize</param>
 /// <param name="cooler">Coolr to initialize</param>
 /// <param name="dvdBurner">DvdBurner to initialize</param>
 /// <param name="extraAccesory">Extracessory to initialize</param>
 /// <param name="os">Operative system to initialize</param>
 /// <param name="type">Computer type to initialize</param>
 /// <param name="processor">Processor to initialize</param>
 /// <param name="hardDisk">Hard disk to initialize</param>
 /// <param name="ram">RAM to initialize</param>
 /// <param name="desc">Description to initialize</param>
 /// <param name="graphicCard">Graphic card to initialize</param>
 /// <param name="state">State to initialize</param>
 /// <param name="date">Date to initialize</param>
 public Desktop(int id, string clientName, Cooler cooler, bool dvdBurner, bool extraAccesory, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard, State state, DateTime date)
     : base(id, clientName, os, type, processor, hardDisk, ram, desc, graphicCard, state, date)
 {
     this.cooler        = cooler;
     this.dvdBurner     = dvdBurner;
     this.extraAccesory = extraAccesory;
 }
Example #31
0
 internal ComTypeLibMemberDesc(ComType kind)
 {
     _kind = kind;
 }
Example #32
0
 public static void AddComtype(FlatBufferBuilder builder, ComType comtype)
 {
     builder.AddLong(2, (long)comtype, 0);
 }