public virtual void Initialise(TableData x, TableData y)
 {
     this.x = x;
     this.y = y;
     if (this.x.Rows.Count == 0 && this.y.Rows.Count != 0) throw new ArgumentException("Cannot determine columns for comparison because x has no rows but y does.", "x");
     if (this.x.Rows.Count != 0 && this.x.Rows[0].Count == 0) throw new ArgumentException("Cannot determine columns for comparison because row 0 in x has no values", "x");
 }
 public virtual void Initialise(TableData x, TableData y)
 {
     if (x.ColumnNames == null || !x.ColumnNames.Any()) throw new ArgumentNullException("Column names X cannot be null or empty");
     if (y.ColumnNames == null || !y.ColumnNames.Any()) throw new ArgumentNullException("Column names Y cannot be null or empty");
     columnsX = x.ColumnNames;
     columnsY = y.ColumnNames;
 }
コード例 #3
0
      public static string CreateManyToOneAssociation(this TableData table, TableData foreignTable, string primaryKeyName, string foreignKeyName, bool backwardReference = false)
      {
         // use the foreign table's type name as property name
         var propertyName = table.FindFreePropertyName(foreignTable.TypeBuilder.Name);
         table.PropertyAndFieldNames.Add(propertyName);

         // create a property of the foreign table's type in the table entity
         var property = table.TypeBuilder.DefineProperty(propertyName, foreignTable.TypeBuilder);

         // create a getter for the property
         var propertyGetter = table.TypeBuilder.DefineGetter(property);

         // obtain ResolveManyToOne method
         var resolveManyToOneMethod = typeof(Entity).GetMethod("ResolveManyToOne", BindingFlags.Instance | BindingFlags.NonPublic).MakeGenericMethod(property.PropertyType);

         // "implement" the method to obtain and return the value by calling 'ResolveManyToOne'
         var ilGenerator = propertyGetter.GetILGenerator();

         // call the method and return the value
         ilGenerator.Emit(OpCodes.Ldarg_0);
         ilGenerator.Emit(OpCodes.Ldstr, property.Name);
         ilGenerator.Emit(OpCodes.Call, resolveManyToOneMethod);
         ilGenerator.Emit(OpCodes.Ret);

         property.SetGetMethod(propertyGetter);

         // add the 'AssociationAttribute' to the property
         property.AddAssociationAttribute(foreignKeyName, primaryKeyName, foreignTable.Name, true);

         // create the explorer item
         var explorerItem = new ExplorerItem(propertyName, ExplorerItemKind.ReferenceLink, ExplorerIcon.ManyToOne);
         table.ExplorerItem.Children.Add(explorerItem);

         return property.Name;
      }
コード例 #4
0
      public static void CreateAndAddType(this TypeBuilder dataContextTypeBuilder, TableData tableData)
      {
         var typeBuilder = tableData.TypeBuilder;
         var explorerItem = tableData.ExplorerItem;

         var type = typeBuilder.CreateType();

         // create a Table<> field in the data context type
         var genericTableType = typeof(ITable<>).MakeGenericType(type);

         // create the property itself
         var property = dataContextTypeBuilder.DefineProperty(explorerItem.Text, PropertyAttributes.None, genericTableType, Type.EmptyTypes);

         // create a getter for the property
         var propertyGetter = dataContextTypeBuilder.DefineMethod($"get_{property.Name}", MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig, genericTableType, Type.EmptyTypes);

         // obtain GetTable method
         var getTableMethod = typeof(DataConnection).GetMethod("GetTable", Type.EmptyTypes).MakeGenericMethod(type);

         // "implement" the method to obtain and return the value by calling GetTable<T>()
         var ilGenerator = propertyGetter.GetILGenerator();

         // call the method and return the value
         ilGenerator.Emit(OpCodes.Ldarg_0);
         ilGenerator.Emit(OpCodes.Call, getTableMethod);
         ilGenerator.Emit(OpCodes.Ret);

         property.SetGetMethod(propertyGetter);
      }
コード例 #5
0
ファイル: ParserLogic.tt.cs プロジェクト: LosManos/St4mpede
		public TableData Parse(Table table, string excludedTablesRegex)
		{
			var ret = new TableData();
			ret.Name = table.Name;
			ret.Include = false == Regex.IsMatch(table.Name, excludedTablesRegex);
			ret.Columns = Parse(table.Columns.Cast<Column>()).ToList();
			return ret;
		}
        public void TableDataIsMatchCustomComparerThrows()
        {
            var other = new TableData();
            other.ColumnNames = tableData.ColumnNames;
            var strategy = new TableDataComparerStrategyFactory().Comparer(TableDataComparers.OrdinalRowOrdinalColumn);

            tableData.VerifyMatch(other, strategy);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: AdamStefan/DataMining
        public static TableData LoadDataFromfCSV(string fileName, string delimeter = null, bool hasHeaderRecord = true,
            bool ignoreQuotes = true, int[] columnIndexes = null, int classIndex=-1)
        {
            var configuration = new CsvConfiguration();
            configuration.Delimiter = delimeter ?? "\t";
            configuration.HasExcelSeparator = false;
            configuration.IgnoreQuotes = ignoreQuotes;
            configuration.HasHeaderRecord = hasHeaderRecord;
            configuration.QuoteNoFields = true;
            using (var reader = new CsvReader(new StreamReader(fileName), configuration))
            {

                var data = new TableData();
                var index = 0;

                while (reader.Read())
                {

                    if (index == 0)
                    {
                        var noOfAttributes = hasHeaderRecord ? reader.FieldHeaders.Length : reader.CurrentRecord.Length;

                        if (columnIndexes == null)
                        {
                            columnIndexes = new int[noOfAttributes];
                            for (var j = 0; j < columnIndexes.Length; j++)
                            {
                                columnIndexes[j] = j;
                            }
                        }

                        for (int column = 0; column < columnIndexes.Length; column++)
                        {
                            var columnName = column == classIndex
                                ? "Class"
                                : hasHeaderRecord
                                    ? reader.FieldHeaders[columnIndexes[column]]
                                    : "Column" + column;
                            data.AddAttribute(columnName);
                        }

                        index++;
                    }

                    var row = data.NewRow();
                    var attributes = data.Attributes.ToArray();
                    for (var columnIndex = 0; columnIndex < columnIndexes.Length; columnIndex++)
                    {
                        var columnName = attributes[columnIndex];
                        row[columnName] = reader.GetField(columnIndexes[columnIndex]);
                    }
                    data.AddRow(row);

                }
                return data;
            }
        }
        public void TableDataIsMatchSpecificComparerFromEnum()
        {
            var other = new TableData();
            other.ColumnNames = tableData.ColumnNames;
            other.Rows = tableData.Rows;

            bool actual = tableData.IsMatch(other, TableDataComparers.OrdinalRowOrdinalColumn);

            Assert.IsTrue(actual);
        }
        public void TableDataIsMatchCustomComparer()
        {
            var other = new TableData();
            other.ColumnNames = tableData.ColumnNames;
            other.Rows = tableData.Rows;
            var strategy = new TableDataComparerStrategyFactory().Comparer(TableDataComparers.OrdinalRowOrdinalColumn);

            bool actual = tableData.IsMatch(other, strategy);

            Assert.IsTrue(actual);
        }
        public bool IsMatch(TableData x, TableData y)
        {
            if (x.Rows == null) throw new ArgumentNullException("x", "Rows in x cannot be null");
            if (y.Rows == null) throw new ArgumentNullException("y", "Rows in y cannot be null");

            ColumnComparer.Initialise(x, y);
            if (!ColumnComparer.IsMatch()) return false;

            RowComparer.Initialise(x.Rows, y.Rows, ColumnComparer.ColumnMappings, ValueComparer);

            return RowComparer.IsMatch();
        }
コード例 #11
0
    public static string GetTable(TableData TableData)
    {
        Controller<TMEventRegister> C = new Controller<TMEventRegister>();
        if (TableData == null) TableData = new TableData();
        C.Model = new TCEventRegister(DB).GetTable(C.Model, TableData);

        Ding.Controls.DataTable DataTable = new Ding.Controls.DataTable();
        DataTable.ID = "ERTTable";
        DataTable.CreateDataTable<TDEventRegister>(C.Model);

        return DataTable.HtmlDataTableBuilder.S().FormatHtml();
    }
コード例 #12
0
 public TableDataReader(TableData tableData)
 {            
     _source = tableData.Rows.GetEnumerator();
     _fields = tableData.Schema.Fields.Select(f =>
         new FieldDefinition
         {
             AllowNull = f.ValueType.IsValueType && Nullable.GetUnderlyingType(f.ValueType) == null,
             Name = f.Name,
             Type = Nullable.GetUnderlyingType(f.ValueType) ?? f.ValueType
         }
      ).ToArray();
     _names = _fields.Select(f => f.Name).ToArray();
 }
コード例 #13
0
ファイル: MongodbServer_Table.cs プロジェクト: yhhno/Adhesive
 public List<TableData> GetTableDataByContextId(string contextId)
 {
     try
     {
         var beginTime = new DateTime(DateTime.Now.Year, 1, 1);
         var endTime = DateTime.Now;
         var data = new ConcurrentBag<TableData>();
         var databaseInfos = MongodbServerMaintainceCenter.GetDatabaseInfos(beginTime, endTime);
         if (databaseInfos.Count == 0) return null;
         foreach(var databaseInfo in databaseInfos)
         {
             var databasePrefix = databaseInfo.DatabasePrefix;
             var columnDescriptions = MongodbServerMaintainceCenter.GetMongodbColumnDescriptions(databasePrefix);
             var contextColumn = columnDescriptions.FirstOrDefault(desc => desc.IsContextIdentityColumn);
             if (contextColumn != null)
             {
                 var collectionInfos = databaseInfo.Collections;
                 var tableData = GetTableData(databasePrefix, collectionInfos.Select(c => c.CollectionName).ToList(), databaseInfo.DatabaseDate.ToLocalTime(), databaseInfo.DatabaseDate.ToLocalTime().AddMonths(1), 0, 100, new Dictionary<string, object>
                 {
                     { contextColumn.ColumnName, contextId }
                 });
                 tableData.ForEach(item =>
                 {
                     foreach (var t in item.Tables)
                     {
                         if (t.Data.Count > 0)
                         {
                             var d = new TableData
                             {
                                 PkColumnDisplayName = item.PkColumnDisplayName,
                                 PkColumnName = item.PkColumnName,
                                 TableName = item.TableName,
                                 Tables = new List<Table>
                                 {
                                     t,
                                 }
                             };
                             data.Add(d);
                         }
                     }
                 });
             }
         };
         return data.ToList();
     }
     catch (Exception ex)
     {
         LocalLoggingService.Error("{0} {1} {2} {3}", MongodbServerConfiguration.ModuleName, "MongodbServer_Table", "GetTableDataByContextId", ex.Message);
         throw;
     }
 }
コード例 #14
0
ファイル: Program.cs プロジェクト: riazi/DataMining
        public static TableData LoadDataFromfCSV(string fileName)
        {
            var configuration = new CsvHelper.Configuration.CsvConfiguration();
            configuration.Delimiter = "\t";
            configuration.HasExcelSeparator = false;
            configuration.IgnoreQuotes = true;
            configuration.QuoteNoFields = true;
            using (var reader = new CsvReader(new StreamReader(fileName), configuration))
            {

                var data = new TableData();
                var index = 0;
                string[] headers = null;

                while (reader.Read())
                {

                    if (index == 0)
                    {
                        headers = reader.FieldHeaders;

                        for (var columnIndex = 0; columnIndex < headers.Length; columnIndex++)
                        {
                            var columnName = headers[columnIndex];
                            data.AddAttribute(columnName);
                        }
                        index++;
                        continue;
                    }

                    var row = data.NewRow();
                    for (var columnIndex = 0; columnIndex < headers.Length; columnIndex++)
                    {
                        var columnName = headers[columnIndex];
                        row[columnName] = reader.GetField(columnIndex);
                    }
                    data.AddRow(row);

                }
                return data;
            }
        }
コード例 #15
0
      public static string CreateOneToManyAssociation(this TableData table, TableData foreignTable, string primaryKeyName, string foreignKeyName)
      {
         // create an IEnumerable<> with the type of the (main) table's type builder
         var typedEnumerableType = typeof(IEnumerable<>).MakeGenericType(table.TypeBuilder);

         // use the table's explorer item text as property name
         var propertyName = foreignTable.FindFreePropertyName(table.ExplorerItem.Text);
         foreignTable.PropertyAndFieldNames.Add(propertyName);

         // create a property in the foreign key's target table
         var property = foreignTable.TypeBuilder.DefineProperty(propertyName, typedEnumerableType);

         // create a getter for the property
         var propertyGetter = foreignTable.TypeBuilder.DefineGetter(property);

         // obtain ResolveOneToMany method
         var resolveOneToManyMethod = typeof(Entity).GetMethod("ResolveOneToMany", BindingFlags.Instance | BindingFlags.NonPublic).MakeGenericMethod(table.TypeBuilder);

         // "implement" the method to obtain and return the value by calling 'ResolveOneToMany'
         var ilGenerator = propertyGetter.GetILGenerator();

         // call the method and return the value
         ilGenerator.Emit(OpCodes.Ldarg_0);
         ilGenerator.Emit(OpCodes.Ldstr, property.Name);
         ilGenerator.Emit(OpCodes.Call, resolveOneToManyMethod);
         ilGenerator.Emit(OpCodes.Ret);

         property.SetGetMethod(propertyGetter);

         // add the 'AssociationAttribute' to the property
         property.AddAssociationAttribute(primaryKeyName, foreignKeyName, table.Name);

         // create the explorer item
         var explorerItem = new ExplorerItem(propertyName, ExplorerItemKind.CollectionLink, ExplorerIcon.OneToMany);
         foreignTable.ExplorerItem.Children.Add(explorerItem);

         // create 'backward' association
         table.CreateManyToOneAssociation(foreignTable, primaryKeyName, foreignKeyName, true);

         return propertyName;
      }
コード例 #16
0
ファイル: PocoGenerator.tt.cs プロジェクト: LosManos/St4mpede
		internal static IList<string> UT_CreateBodyForEqualsMethod(TableData table, ClassData classData, string parameterName)
		{
			return CreateBodyForEqualsMethod(table, classData,parameterName);
        }
コード例 #17
0
ファイル: LuaManager.cs プロジェクト: yamashita8655/Dominion
    public void getStack(IntPtr luastate, ArrayList list)
    {
        int num = NativeMethods.lua_gettop(luastate);

        //Debug.Log ("count = " + num);

        if (num == 0)
        {
            return;
        }

        for (int i = num; i >= 1; i--)
        {
            int type = NativeMethods.lua_type(luastate, i);

            switch (type)
            {
            case 0:            //LuaTypes.LUA_TNIL:
                break;

            case 1:            //LuaTypes.LUA_TBOOLEAN:
                int res_b = NativeMethods.lua_toboolean(luastate, i);
                list.Add(res_b);
                break;

            case 2:            //LuaTypes.LUA_TLIGHTUSERDATA:
                break;

            case 3:            //LuaTypes.LUA_TNUMBER:
                double res_d = NativeMethods.lua_tonumberx(luastate, i, 0);
                list.Add(res_d);
                break;

            case 4:            //LuaTypes.LUA_TSTRING:
                uint   res;
                IntPtr res_s     = NativeMethods.lua_tolstring(luastate, i, out res);
                string resString = Marshal.PtrToStringAnsi(res_s);
                list.Add(resString);
                break;

            case 5:            //LuaTypes.LUA_TTABLE:
                TableData tdata = new TableData();
                // まず、長さが指定されているはずなので、取得する
                NativeMethods.lua_getfield(luastate, i, "length");
                int tableLength = (int)NativeMethods.lua_tonumberx(luastate, i + 1, 0);
                for (int j = 0; j < tableLength; j++)
                {
                    // テーブルだけスタックに積んでおきたいので、トップの位置調整
                    NativeMethods.lua_settop(luastate, i);

                    // テーブルから、添え字に見立てた文字列からデータを取得
                    NativeMethods.lua_getfield(luastate, i, j.ToString());

                    // コントロールネームをスタックに積む
                    uint   r;
                    IntPtr r_s  = NativeMethods.lua_tolstring(luastate, i + 1, out r);
                    string text = Marshal.PtrToStringAnsi(r_s);
                    tdata.tableDataList.Add(text);
                    Debug.Log(text);
                }
                list.Add(tdata);
                break;

            case 6:            //LuaTypes.LUA_TFUNCTION:
                break;

            case 7:            //LuaTypes.LUA_TUSERDATA:
                break;
                //case LuaTypes.LUA_TTHREAD:
                //	break;
            }
        }
    }
コード例 #18
0
ファイル: Program.cs プロジェクト: riazi/DataMining
        private static void Test()
        {
            var data = new TableData();

            Random random = new Random(321);
            const int rows = 50;
            const int columns = 3;
            var matrix = new int[rows, columns];

            for (int currentColumn = 0; currentColumn < columns; currentColumn++)
            {
                data.AddAttribute("attribute" + (currentColumn + 1));
            }

            for (var currentRow = 0; currentRow < rows; currentRow++)
            {
                var row = data.NewRow();
                for (var currentColumn = 0; currentColumn < columns; currentColumn++)
                {
                    var attribute = "attribute" + (currentColumn + 1);
                    matrix[currentRow, currentColumn] = random.Next();
                    row[attribute] = matrix[currentRow, currentColumn];
                }

                data.AddRow(row);
            }

            for (var currentRow = 0; currentRow < rows; currentRow++)
            {
                for (var currentColumn = 0; currentColumn < columns; currentColumn++)
                {
                    var attribute = "attribute" + (currentColumn + 1);
                    //Convert.ChangeType()
                    //var matrix[currentRow, currentColumn]
                    //data[currentRow][attribute]

                    if (matrix[currentRow, currentColumn] != (int)data[currentRow][attribute])
                    {
                        throw new Exception("InvalidData");
                    }
                }
            }
        }
コード例 #19
0
 public void GetData(IQueryable <InventoryAlert> data, TableData result, PageReq pageRequest = null)
 {
     _app.GetData(data, result, pageRequest);
 }
        public void TableDataIsMatchNullCustomComparerThrows()
        {
            var other = new TableData();

            tableData.IsMatch(other, (TableDataComparer)null);
        }
コード例 #21
0
ファイル: Disp.cs プロジェクト: susan4343/StandardMathineHY
        public StationStep StepGoSnap(VisionControl visionControl, bool bmanual = false)
        {
            StationStep step = StationStep.Step_Stop;

            //拍照识别是否有料,计算偏差(6月后做)
            ParamSetMgr.GetInstance().SetBoolParam("启动点胶", true);
            //开始点胶(优先实现画轨迹)
            //获取当前夹取位置是A工位还是B工位
            int StationIndex = TableData.GetInstance().GetSocketNum(1, 0.5) - 1;

            PathHelper.Disp_ID = StationIndex;
            string stationAAName = StationIndex == 0 ? "A" : "B";

            ParamSetMgr.GetInstance().SetBoolParam($"{stationAAName}工位点胶", true);
            double     CenterX      = ParamSetMgr.GetInstance().GetDoubleParam("产品点胶X轴半径");
            double     CenterY      = ParamSetMgr.GetInstance().GetDoubleParam("产品点胶Y轴半径");
            double     DelZ         = ParamSetMgr.GetInstance().GetDoubleParam("点胶Z轴上升高度偏差");
            int        DispDelay    = ParamSetMgr.GetInstance().GetIntParam("出胶延迟");
            double     DispRunAngle = ParamSetMgr.GetInstance().GetDoubleParam("画胶角度");
            double     DispEndAngle = ParamSetMgr.GetInstance().GetDoubleParam("收胶角度");
            bool       DispEnable   = ParamSetMgr.GetInstance().GetBoolParam("屏蔽点胶");
            bool       DispPhoto    = ParamSetMgr.GetInstance().GetBoolParam("点胶相机拍照定位");
            double     SafeZ        = GetStationPointDic()[$"安全位置"].pointZ;
            double     X            = 0;
            double     Y            = 0;
            double     DispPhotoX   = GetStationPointDic()[$"{stationAAName}工位拍照位"].pointX;
            double     DispPhotoY   = GetStationPointDic()[$"{stationAAName}工位拍照位"].pointY;
            double     DispPhotoZ   = GetStationPointDic()[$"{stationAAName}工位拍照位"].pointZ;
            double     DispPosX     = GetStationPointDic()[$"{stationAAName}工位点胶位"].pointX;
            double     DispPosY     = GetStationPointDic()[$"{stationAAName}工位点胶位"].pointY;
            double     DispPosZ     = GetStationPointDic()[$"{stationAAName}工位点胶位"].pointZ;
            double     x1           = GetStationPointDic()["安全位置"].pointX;
            CameraBase cam          = null;

            if (!ParamSetMgr.GetInstance().GetBoolParam("屏蔽上相机"))
            {
                cam = CameraMgr.GetInstance().GetCamera("Top");
                cam.BindWindow(visionControl);
                Task.Run(() =>
                {
                    cam.StopGrap();
                    cam.SetTriggerMode(CameraModeType.Software);
                    cam.SetGain(ParamSetMgr.GetInstance().GetIntParam("点胶相机增益"));
                    cam.SetExposureTime(ParamSetMgr.GetInstance().GetIntParam("点胶相机曝光"));
                    cam.StartGrab();
                });
            }
            IOMgr.GetInstace().WriteIoBit($"相机光源", true);
retry_uplens:
            IOMgr.GetInstace().WriteIoBit($"{stationAAName}Lens升降气缸", true);
            WaranResult waranResult1 = CheckIobyName($"{stationAAName}Lens上升到位", true, $"{stationAAName}Lens上升到位", bmanual);

            if (waranResult1 == WaranResult.Retry)
            {
                goto retry_uplens;
            }
            MoveSigleAxisPosWaitInpos(AxisZ, SafeZ, (double)SpeedType.High, 0.005, bmanual, this);
            MoveY(DispPhotoY, SpeedType.High);

            MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPhotoX, DispPhotoZ }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this);
            HObject img = null;



            if (!ParamSetMgr.GetInstance().GetBoolParam("屏蔽上相机"))
            {
                img = cam.GetImage();
                if (img == null || !img.IsInitialized())
                {
                    img = cam.GetImage();
                }
                else
                {
                    ImageHelper.Instance.SaveImage($"{PathHelper.ImagePathDisp}{DateTime.Now.ToString("HHmmssfff")}.bmp", "bmp", img.Clone());
                }
            }


            IOMgr.GetInstace().WriteIoBit($"相机光源", false);
            //去画胶
            Task.Run(() =>
            {
                if (ParamSetMgr.GetInstance().GetBoolParam("是否选择程控电源"))
                {
                    double valueVoltage = ParamSetMgr.GetInstance().GetDoubleParam("程控电源电压");
                    OtherDevices.ckPower.SetVoltage(StationIndex + 1, valueVoltage);
                    double valueCurrent = ParamSetMgr.GetInstance().GetDoubleParam("程控电源电流");
                    OtherDevices.ckPower.SetCurrent(StationIndex + 1, valueCurrent);
                }
                IOMgr.GetInstace().WriteIoBit($"{stationAAName}模组上电", true);
                IOMgr.GetInstace().WriteIoBit($"12V开启", ParamSetMgr.GetInstance().GetBoolParam("是否开启非程控12V"));
            });
            if (DispEnable)
            {
                step = StationStep.Step_CheckIpos;
                MoveSigleAxisPosWaitInpos(AxisZ, SafeZ, (double)SpeedType.High, 0.005, bmanual, this);
                TableData.GetInstance().SetStationResult("A_UnLoadLoad", true);
                TableData.GetInstance().SetStationResult("B_UnLoadLoad", true);
                return(step);
            }
            if (DispPhoto)
            {
                ////MoveY(DispPhotoY, SpeedType.High);
                ////MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPhotoX, DispPhotoZ }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this);

                //拍照计算 +半径
                double CenterdelX = 0;
                double CenterdelY = 0;
                X        = CenterX + CenterdelX;
                Y        = CenterdelY;
                DispPosX = DispPhotoX - X;
                DispPosY = DispPhotoY + CenterdelY;
            }
            else
            {
                X = CenterX;
                Y = 0;
            }
            //  IOMgr.GetInstace().WriteIoBit("点胶机", false);
            bool brtnExc = true;

            MotionMgr.GetInstace().AddAxisToGroup("点胶群组", 2, new int[] { AxisX, AxisY });

            MoveY(DispPosY, SpeedType.High);
            MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPosX, DispPosZ + DelZ + 10 }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this);

            //    MoveMulitAxisPosWaitInpos(new int[] { AxisX }, new double[] { DispPosX }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this);
            IOMgr.GetInstace().WriteIoBit("点胶机", false);
            MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { DispPosZ + DelZ }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this);
            if (ParamSetMgr.GetInstance().GetStringParam("点胶轨迹") == "Circle")
            {
                DateTime dateTime = DateTime.Now;
                if (DispDelay >= 0)
                {
                    IOMgr.GetInstace().WriteIoBit("点胶机", true);
                    Thread.Sleep(DispDelay);
                }
                else
                {
                    Task.Run(() =>
                    {
                        while (true)
                        {
                            if ((DateTime.Now - dateTime).TotalSeconds > Math.Abs(DispDelay) / 1000.0)
                            {
                                IOMgr.GetInstace().WriteIoBit("点胶机", true);
                                break;
                            }
                            Thread.Sleep(10);
                        }
                    });
                }



                //走

                brtnExc &= MotionMgr.GetInstace().ClearBufMove("点胶群组");
                brtnExc &= MotionMgr.GetInstace().RestGpErr("点胶群组");
                //  GpState gps = MotionMgr.GetInstace().GetGpState("点胶群组");
                brtnExc &= MotionMgr.GetInstace().AddBufMove("点胶群组", BufMotionType.buf_Arc2dAbsAngleCW, 1, 2, (double)SpeedType.Mid, (double)SpeedType.Mid, new double[2] {
                    X, Y
                }, new double[2] {
                    DispPosZ, 0
                });
                brtnExc &= MotionMgr.GetInstace().BufTrans("点胶群组");//M314没有buf运动,所以放在这里star
                brtnExc &= MotionMgr.GetInstace().BufStart("点胶群组");
                Thread.Sleep(400);
                if (!WaitXY(DispPosX, DispPosY))
                {
                    IOMgr.GetInstace().WriteIoBit("点胶机", false);
                    return(step);
                }
                IOMgr.GetInstace().WriteIoBit("点胶机", false);
            }
            else
            {
                IOMgr.GetInstace().WriteIoBit("点胶机", true);
                Thread.Sleep(DispDelay);
                MoveY(DispPosY + CenterY * 10, SpeedType.Mid);
                MoveMulitAxisPosWaitInpos(new int[] { AxisX }, new double[] { DispPosX + CenterX * 2 }, new double[] { (double)SpeedType.Mid }, 0.005, bmanual, this);
                MoveY(DispPosY - CenterY * 10, SpeedType.Mid);
                MoveMulitAxisPosWaitInpos(new int[] { AxisX }, new double[] { DispPosX }, new double[] { (double)SpeedType.Mid }, 0.005, bmanual, this);
                MoveY(DispPosY, SpeedType.Mid);
                IOMgr.GetInstace().WriteIoBit("点胶机", false);
            }
            IOMgr.GetInstace().WriteIoBit($"相机光源", true);

            MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { DispPosZ + 3 }, new double[] { (double)SpeedType.Mid }, 0.005, bmanual, this);

            MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { DispPosZ + 10 }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this);
            if (!ParamSetMgr.GetInstance().GetBoolParam("屏蔽上相机"))
            {
                MoveMulitAxisPosWaitInpos(new int[] { AxisX, AxisZ }, new double[] { DispPhotoX, DispPhotoZ }, new double[] { (double)SpeedType.High, (double)SpeedType.High }, 0.005, bmanual, this);
                // MoveSigleAxisPosWaitInpos(AxisX, DispPhotoX, (double)SpeedType.High, 0.005, bmanual, this);
                MoveY(DispPhotoY, SpeedType.High);
                HObject img2 = cam.GetImage();
                if (img2 == null || !img2.IsInitialized())
                {
                    img2 = cam.GetImage();
                }
                else
                {
                    ImageHelper.Instance.SaveImage($"{PathHelper.ImagePathDisp}{DateTime.Now.ToString("HHmmssfff")}.bmp", "bmp", img2.Clone());
                }
            }
            IOMgr.GetInstace().WriteIoBit($"相机光源", false);

            MoveMulitAxisPosWaitInpos(new int[] { AxisZ }, new double[] { SafeZ }, new double[] { (double)SpeedType.High }, 0.005, bmanual, this);
            MoveSigleAxisPosWaitInpos(AxisX, x1, (double)SpeedType.High, 0.005, bmanual, this);
            step = StationStep.Step_CheckIpos;
            //if (DialogResult.OK!= MessageBox.Show("请确定点胶效果是否OK,OK按确定", "Info", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly))
            //{
            //    ParamSetMgr.GetInstance().SetBoolParam("重新上料", true);
            //    return step;
            //}
            ParamSetMgr.GetInstance().SetBoolParam("重新上料", false);
            SocketMgr.GetInstance().SetSocketState(SocketNumOfUnloadLoad, SocketState.Have);
            TableData.GetInstance().SetStationResult("A_UnLoadLoad", true);
            TableData.GetInstance().SetStationResult("B_UnLoadLoad", true);
            ParamSetMgr.GetInstance().SetBoolParam("点胶完成", true);
            return(step);
        }
コード例 #22
0
 static string GetTableTypeName(TableData table)
 {
     return(Escape(table.Name + "_Type"));
 }
コード例 #23
0
ファイル: TableHDU.cs プロジェクト: Cstolworthy/FITS-Helpers
 //private int currentColumn;
 internal TableHDU(TableData td)
 {
     table = td;
 }
コード例 #24
0
 public void GetData(IQueryable <OrderDetiailHistory> data, TableData result, PageReq pageRequest = null)
 {
     _app.GetData(data, result, pageRequest);
 }
コード例 #25
0
        private void InsertOrUpdateData(TableData table, SqlConnection conn, SqlTransaction tran, string sourceTable = null)
        {
            var insert = false;

            if (Update)
            {
                var clear =
                    SqlClearOptions.HasFlag(table.Schema.IsDimension()
                        ? SqlClearOptions.Dimensions
                        : SqlClearOptions.Facts);

                if (!clear && _cutoff.HasValue)
                {
                    var pfield = SqlUpdateUtil.GetPartitionField(table.Schema);
                    if (pfield != null)
                    {
                        var sql = string.Format("DELETE {0} FROM {0} {1}", Escape(table.Name),
                                                SqlUpdateUtil.GetUpdateCriteria(table.Schema, pfield, true, _cutoff));
                        new SqlCommand(sql, conn, tran)
                        {
                            CommandTimeout = Timeout
                        }.ExecuteNonQuery();
                        insert = true;
                    }
                }
                else
                {
                    new SqlCommand(string.Format("DELETE FROM {0}", Escape(table.Name)), conn, tran).ExecuteNonQuery();
                    insert = true;
                }
            }


            SqlCommand cmd;

            //Merge new dimension values
            if (Update && !insert)
            {
                var sql = new StringBuilder();

                sql.AppendFormat(@"MERGE [{0}] WITH (TABLOCK) AS Target USING {1} AS Source ON {2} ",
                                 table.Name,
                                 sourceTable ?? "@Data",
                                 //Join criteria
                                 string.Join(" AND ",
                                             (table.Schema.Keys.Length > 0 ? table.Schema.Keys : table.Schema.Dimensions).Select(
                                                 field =>
                                                 string.Format("{0} = {1}", Escape("Target", field.Value.Name),
                                                               Escape("Source", field.Value.Name)))));

                if (table.Schema.Fields.Any(f => !table.Schema.IsKey(f)))
                {
                    sql.AppendFormat(@"WHEN Matched THEN UPDATE SET {0}",
                                     //Update fields
                                     string.Join(", ",
                                                 table.Schema.Fields.Where(f => !table.Schema.IsKey(f)).Select(field =>
                                                                                                               string.Format(
                                                                                                                   field.FieldType == FieldType.Fact ? "{0} = [Target].{0} + {1}" : "{0} = {1}", // <- Consider this. What if dimensions have measures?
                                                                                                                   Escape(field.Name), Escape("Source", field.Name)))));
                }


                sql.AppendFormat("WHEN NOT MATCHED THEN INSERT ({0}) VALUES ({1});",
                                 //Insert fields
                                 string.Join(", ",
                                             table.Schema.Fields.Select(field => Escape(field.Name))),
                                 string.Join(", ",
                                             table.Schema.Fields.Select(field => Escape("Source", field.Name)))
                                 );

                cmd = new SqlCommand(sql.ToString(), conn, tran);
            }
            else
            {
                cmd =
                    new SqlCommand(
                        string.Format("INSERT {0} WITH (TABLOCK) SELECT * FROM {1}", Escape(table.Name), sourceTable ?? "@Data"), conn, tran);
            }

            cmd.CommandTimeout = Timeout;
            if (sourceTable == null)
            {
                var p = cmd.Parameters.AddWithValue("@Data", new SqlRecordAdapter(table));
                p.SqlDbType = SqlDbType.Structured;
                p.TypeName  = GetTableTypeName(table);
            }
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (ArgumentException ex)
            {
                //Ignore. SqlCommand throws ArgumentException when table is empty.
            }
        }
コード例 #26
0
 public void GetData(IQueryable <StepTrace> data, TableData result, PageReq pageRequest = null)
 {
     _app.GetData(data, result, pageRequest);
 }
コード例 #27
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(TableData.GetEnumerator());
 }
コード例 #28
0
 public IEnumerator <T> GetEnumerator()
 {
     return(TableData.GetEnumerator());
 }
コード例 #29
0
        private void UploadData(TableData table)
        {
            using (var subConn = new SqlConnection(ConnectionString))
            {
                subConn.Open();
                if (!string.IsNullOrEmpty(CreateDatabaseName))
                {
                    subConn.ChangeDatabase(CreateDatabaseName);
                }

                new SqlCommand(string.Format("TRUNCATE TABLE {0}", GetStagingTableName(table)), subConn)
                {
                    CommandTimeout = Timeout
                }.ExecuteNonQuery();

                using (var tran = subConn.BeginTransaction())
                {
                    using (var bcp = new SqlBulkCopy(subConn, SqlBulkCopyOptions.TableLock, tran))
                    {
                        bcp.BatchSize = 5000;
                        bcp.EnableStreaming = true;
                        bcp.BulkCopyTimeout = Timeout;
                        bcp.DestinationTableName = GetStagingTableName(table);
                        bcp.WriteToServer(table.CreateReader());
                    }
                    tran.Commit();
                }
            }
        }
コード例 #30
0
 static string GetStagingTableName(TableData table)
 {
     return(Escape("Staging", table.Name + "_Staging"));
 }
コード例 #31
0
 static string GetTableTypeName(TableData table)
 {
     return Escape(table.Name + "_Type");
 }
コード例 #32
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
 /// <summary>
 /// 桌子占位
 /// </summary>
 /// <param name="table"></param>
 /// <param name="pos"></param>
 /// <param name="user"></param>
 /// <param name="roomId"></param>
 private static void SetTablePosition(int roomId, TableData table, PositionData pos, GameUser user)
 {
     pos.Init(user);
     user.Property.InitTablePos(roomId, table.TableId, pos.Id);
 }
コード例 #33
0
        public DataSourse GetData(string constr)
        {
            DataSourse dataSourse = new DataSourse();
            string     dbName     = constr.Substring(0, constr.IndexOf(";")).Substring(constr.IndexOf("=") + 1);
            IDbObject  dbObject   = (IDbObject) new DataAccess();

            dbObject.DbConnectStr = constr;
            List <string>    tables = dbObject.GetTables(dbName);
            List <TableData> list1  = new List <TableData>();
            List <Reference> list2  = new List <Reference>();

            if (tables != null && tables.Count > 0)
            {
                foreach (string tableName in tables)
                {
                    TableData tableData = new TableData();
                    tableData.Code = tableName;
                    tableData.Name = tableName;
                    tableData.Id   = tableName;
                    List <string> list3          = new List <string>();
                    DataTable     columnInfoList = dbObject.GetColumnInfoList(dbName, tableName);
                    List <Column> list4          = new List <Column>();
                    foreach (DataRow row in (InternalDataCollectionBase)columnInfoList.Rows)
                    {
                        Column column1 = new Column();
                        column1.Code      = DataRowExtensions.Field <string>(row, 1).Trim();
                        column1.Comment   = DataRowExtensions.Field <string>(row, 15).Trim();
                        column1.DataType  = DataRowExtensions.Field <string>(row, 2).Trim();
                        column1.Displayed = "true";
                        Column column2 = column1;
                        string str1    = tableName;
                        int    num     = DataRowExtensions.Field <int>(row, 0);
                        string str2    = num.ToString();
                        string str3    = str1 + str2;
                        column2.Id = str3;
                        Column column3 = column1;
                        num = DataRowExtensions.Field <int>(row, 3);
                        string str4 = num.ToString();
                        column3.Length    = str4;
                        column1.Mandatory = DataRowExtensions.Field <string>(row, 13).Trim() == "√" ? "" : "1";
                        column1.Name      = DataRowExtensions.Field <string>(row, 1).Trim();
                        column1.TableCode = tableName;
                        column1.TableId   = tableData.Id;
                        if (DataRowExtensions.Field <string>(row, 7).Trim() != "d")
                        {
                            list3.Add(column1.Id);
                        }
                        list4.Add(column1);
                    }
                    tableData.Columns = list4;
                    if (list3.Count > 0)
                    {
                        tableData.PrimaryKey = new Key()
                        {
                            KeyId     = Guid.NewGuid().ToString(),
                            ColumnRef = list3.ToArray()
                        }
                    }
                    ;
                    list1.Add(tableData);
                }
            }
            if (list1 != null && list1.Count > 0)
            {
                foreach (TableData tableData in list1)
                {
                    TableData tab = tableData;
                    foreach (DataRow dataRow in (InternalDataCollectionBase)dbObject.GetTableRefrence(dbName, tab.Code).Rows)
                    {
                        DataRow   item = dataRow;
                        Reference r    = new Reference();
                        r.ParentTable          = Enumerable.SingleOrDefault <string>(Enumerable.Select <TableData, string>(Enumerable.Where <TableData>((IEnumerable <TableData>)list1, (Func <TableData, bool>)(t => t.Code == DataRowExtensions.Field <string>(item, 1).Trim())), (Func <TableData, string>)(t => t.Id)));
                        r.ParentTableColumnRef = Enumerable.SingleOrDefault <string>(Enumerable.Select(Enumerable.Where(Enumerable.Where(Enumerable.SelectMany((IEnumerable <TableData>)list1, (Func <TableData, IEnumerable <Column> >)(t => (IEnumerable <Column>)t.Columns), (t, f) =>
                        {
                            var fAnonymousType2 = new
                            {
                                t = t,
                                f = f
                            };
                            return(fAnonymousType2);
                        }), param0 => param0.t.Id == r.ParentTable), param0 => param0.f.Code == DataRowExtensions.Field <string>(item, 2).Trim()), param0 => param0.f.Id));
                        r.Id                  = Guid.NewGuid().ToString();
                        r.ChildTable          = tab.Id;
                        r.ChildTableColumnRef = Enumerable.SingleOrDefault <string>(Enumerable.Select(Enumerable.Where(Enumerable.Where(Enumerable.SelectMany((IEnumerable <TableData>)list1, (Func <TableData, IEnumerable <Column> >)(t => (IEnumerable <Column>)t.Columns), (t, f) =>
                        {
                            var fAnonymousType2 = new
                            {
                                t = t,
                                f = f
                            };
                            return(fAnonymousType2);
                        }), param0 => param0.t.Id == tab.Id), param0 => param0.f.Code == DataRowExtensions.Field <string>(item, 0).Trim()), param0 => param0.f.Id));
                        list2.Add(r);
                    }
                }
            }
            dataSourse.ListTable     = list1;
            dataSourse.ListReference = list2;
            DataTable       vieWs = dbObject.GetVIEWs(dbName);
            List <ViewData> list5 = new List <ViewData>();

            if (vieWs != null && vieWs.Rows != null && vieWs.Rows.Count > 0)
            {
                foreach (DataRow row in (InternalDataCollectionBase)vieWs.Rows)
                {
                    string str = DataRowExtensions.Field <string>(row, 0);
                    if (!string.IsNullOrWhiteSpace(str))
                    {
                        string    objectViewInfo = dbObject.GetObjectViewInfo(dbName, str);
                        DataTable dataTable      = dbObject.QueryViewInfo(dbName, str);
                        ViewData  viewData       = new ViewData();
                        viewData.Code     = str;
                        viewData.Name     = str;
                        viewData.Id       = str;
                        viewData.SQLQuery = objectViewInfo;
                        List <Column> list3 = new List <Column>();
                        foreach (DataColumn dataColumn in (InternalDataCollectionBase)dataTable.Columns)
                        {
                            list3.Add(new Column()
                            {
                                Name = dataColumn.ColumnName,
                                Code = dataColumn.ColumnName,
                                Id   = Guid.NewGuid().ToString()
                            });
                        }
                        viewData.Columns = list3;
                        list5.Add(viewData);
                    }
                }
            }
            dataSourse.ListView = list5;
            return(dataSourse);
        }
    }
コード例 #34
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
        /// <summary>
        /// 出牌和叫地主时重置桌子定时
        /// </summary>
        public void ReStarTableTimer(TableData table)
        {
            int outcardPeroid = ConfigEnvSet.GetInt("Game.Table.AIOutCardTime", 5000);

            table.ReStartTimer(outcardPeroid);
        }
        public void TableDataVerifyMatchSpecificComparerFromEnum()
        {
            var other = new TableData();
            other.ColumnNames = tableData.ColumnNames;
            other.Rows = tableData.Rows;

            tableData.VerifyMatch(other, TableDataComparers.OrdinalRowOrdinalColumn);
        }
コード例 #36
0
ファイル: PocoGenerator.tt.cs プロジェクト: LosManos/St4mpede
		private static IList<string> CreateBodyForEqualsMethod(TableData table, ClassData classData, string parameterName)
		{
			var bodyLines = new List<string>
					{
						string.Format("var obj = {0} as {1};", parameterName, classData.Name),
						"if( obj == null ){",
						"\treturn false;",
						"}",
						string.Empty,
						"return"
					};
			bodyLines.AddRange(table.Columns.Select(c =>
				string.Format("\tthis.{0} == obj.{0} &&",
				c.Name,
				parameterName
			)));
			bodyLines[bodyLines.Count - 1] = bodyLines.Last().Replace(" &&", ";");
			return bodyLines;
		}
コード例 #37
0
 public static void RegisterTable(string key, TableData table)
 {
     _tables[key] = table;
 }
コード例 #38
0
ファイル: PocoGenerator.tt.cs プロジェクト: LosManos/St4mpede
		private static MethodData CreateEqualsMethod(TableData table, ClassData classData, string ParameterName)
		{
			return new MethodData
			{
				IsConstructor = false,
				Name = "Equals",
				Override = true,
				ReturnTypeString = typeof(bool).ToString(),
				Comment = new CommentData("This is the Equals method."),
				Parameters = new List<ParameterData>
				{
					new ParameterData
					{
						Name = ParameterName,
						SystemTypeString = typeof(object).ToString()
					}
				},
				Body = new BodyData(
					CreateBodyForEqualsMethod(table, classData, ParameterName)
					)
			};
		}
コード例 #39
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
 public void SyncNotifyAction(int actionId, TableData table, Parameters parameters, Action <int> callback)
 {
     SyncNotifyAction(actionId, ClientNotifier.GetUserList(table), parameters, callback);
 }
コード例 #40
0
        public ActionResult <TableData> Query(string queryStr)
        {
            JObject jObject = new JObject();

            if (string.IsNullOrEmpty(queryStr) == false)
            {
                jObject = JsonConvert.DeserializeObject <JObject>(queryStr);
            }

            int    current        = jObject.Value <int>("current") == 0 ? 1 : jObject.Value <int>("current");
            int    pageSize       = jObject.Value <int>("pageSize") == 0 ? 20 : jObject.Value <int>("pageSize");
            string number         = jObject.Value <string>("number");
            string company        = jObject.Value <string>("company");
            string leadSealNumber = jObject.Value <string>("leadSealNumber");

            //防止查询条件都不满足,先生成一个空的查询
            var where = _context.Truck.Where(p => true);

            if (string.IsNullOrEmpty(number) == false)
            {
                where = where.Where(p => p.Number.Contains(number));
            }
            if (string.IsNullOrEmpty(company) == false)
            {
                where = where.Where(p => p.Company.Contains(company));
            }
            if (string.IsNullOrEmpty(leadSealNumber) == false)
            {
                where = where.Where(p => p.LeadSealNumber.Contains(leadSealNumber));
            }

            //统计总记录数
            int total = where.Count();

            // 解析排序规则
            string  sorterKey = "";
            string  sortRule  = "";
            JObject sorterObj = jObject.Value <JObject>("sorter");
            IEnumerable <JProperty> properties = sorterObj.Properties();

            foreach (JProperty item in properties)
            {
                sorterKey = item.Name;
                sortRule  = item.Value.ToString();
            }
            if (string.IsNullOrEmpty(sorterKey) == false && string.IsNullOrEmpty(sortRule) == false)
            {
                if (sorterKey.Equals("number") && sortRule.Equals("descend"))
                {
                    where = where.OrderByDescending(p => p.Number);
                }
                else if (sorterKey.Equals("number") && sortRule.Equals("ascend"))
                {
                    where = where.OrderBy(p => p.Number);
                }

                if (sorterKey.Equals("company") && sortRule.Equals("ascend"))
                {
                    where = where.OrderBy(p => p.Company);
                }
                else if (sorterKey.Equals("company") && sortRule.Equals("ascend"))
                {
                    where = where.OrderBy(p => p.Company);
                }

                if (sorterKey.Equals("leadSealNumber") && sortRule.Equals("ascend"))
                {
                    where = where.OrderBy(p => p.LeadSealNumber);
                }
                else if (sorterKey.Equals("leadSealNumber") && sortRule.Equals("ascend"))
                {
                    where = where.OrderBy(p => p.LeadSealNumber);
                }

                // 按照最后更新时间排序
                if (sorterKey.Equals("lastUpdateTime") && sortRule.Equals("descend"))
                {
                    where = where.OrderByDescending(p => p.LastUpdateTime);
                }
                else if (sorterKey.Equals("lastUpdateTime") && sortRule.Equals("ascend"))
                {
                    where = where.OrderBy(p => p.LastUpdateTime);
                }
            }
            else
            {
                //结果按照最后修改时间倒序排序
                where = where.OrderByDescending(p => p.LastUpdateTime);
            }

            //跳过翻页的数量
            where = where.Skip(pageSize * (current - 1));
            //获取结果
            List <Truck> dataList = where.Take(pageSize).ToList();

            TableData resultObj = new TableData();

            resultObj.Data     = dataList;
            resultObj.Current  = current;
            resultObj.Success  = true;
            resultObj.PageSize = pageSize;
            resultObj.Total    = total;

            return(resultObj);
        }
コード例 #41
0
ファイル: PocoGenerator.tt.cs プロジェクト: LosManos/St4mpede
		private IList<string> CreateBodyForGetHashCodeMethod(TableData table)
		{
			IParserLogic2 parserLogic2 = new ParserLogic2();

			var bodyLines = new List<string>
			{
				"int hash = 13;"
			};
			bodyLines.AddRange(table.Columns.Select(c =>
				"hash = (hash*7) + " +
				(
					DefaultValueIsNull( parserLogic2.ConvertDatabaseTypeToDotnetType(c.DatabaseTypeName))
				?   //	It is a parameter that cannot be null.
                    string.Format("( null == {0} ? 0 : this.{0}.GetHashCode() );", c.Name)
				:	//	It is a value that can be null.
					string.Format("this.{0}.GetHashCode();", c.Name)
			)));
			bodyLines.Add("return hash;");
			return bodyLines;
		}
コード例 #42
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
        /// <summary>
        /// 叫地主
        /// </summary>
        /// <param name="positionId"></param>
        /// <param name="tableData"></param>
        /// <param name="isCall">true:叫,false:不叫</param>
        public void CallCard(int positionId, TableData tableData, bool isCall)
        {
            if (positionId != tableData.CallLandlordPos)
            {
                TraceLog.WriteComplement("桌子:{0}未轮到位置{1}叫地主", tableData.TableId, positionId);
                return;
            }
            if (tableData.CallTimes < tableData.CallOperation.Length)
            {
                if (isCall)
                {
                    tableData.DoDouble();
                    TraceLog.WriteComplement("桌子:{0}叫地主加倍{1}", tableData.TableId, tableData.MultipleNum);
                }
                tableData.CallOperation[tableData.CallTimes] = isCall;
                tableData.CallTimes++;
            }
            if (tableData.CallTimes > tableData.PlayerNum - 1 &&
                !Array.Exists(tableData.CallOperation, op => op))
            {
                //都不叫时重新发牌接口
                TraceLog.WriteComplement("桌子:{0}重新发牌,CallTimes:{1},Log:{2}", tableData.TableId, tableData.CallTimes, string.Join(",", tableData.CallOperation));
                CheckStart(tableData);
                return;
            }

            int noCallNum    = 0;
            int calledNum    = 0;
            int preCallIndex = 0;//上次操作的索引
            //计算叫地主记录中,不叫次数
            int endIndex = tableData.CallTimes - 1;

            for (int i = endIndex; i >= 0; i--)
            {
                bool called = tableData.CallOperation[i];
                if (!called)
                {
                    noCallNum++;
                }
                else
                {
                    calledNum++;
                }
                if (called && calledNum == 1)
                {
                    preCallIndex = i;
                }
            }
            TraceLog.WriteComplement("桌子:{0}位置:{1},前一个:{2},最后一个:{3}叫地主", tableData.TableId, positionId, preCallIndex, endIndex);
            if ((tableData.CallTimes == tableData.PlayerNum && noCallNum == tableData.PlayerNum - 1) ||
                tableData.CallTimes > tableData.PlayerNum)
            {
                int index = endIndex - preCallIndex;
                index = (positionId + tableData.PlayerNum - index) % tableData.PlayerNum;
                PositionData pos = index >= 0 && index < tableData.Positions.Length ? tableData.Positions[index] : null;
                if (pos != null)
                {
                    //确定地主
                    pos.IsLandlord          = true;
                    tableData.LandlordPos   = pos.Id;
                    tableData.LandlordId    = pos.UserId;
                    tableData.IsCallEnd     = true;
                    tableData.OutCardPos    = pos.Id;
                    tableData.OutCardUserId = pos.UserId;
                    //增加底牌
                    pos.CardData.AddRange(tableData.BackCardData);
                    _cardRole.SortCard(pos.CardData);
                }
            }
            else
            {
                //取下个叫地主玩家
                int          nextPos = (positionId + 1) % tableData.PlayerNum;
                PositionData pos     = tableData.Positions[nextPos];
                if (pos != null)
                {
                    tableData.CallLandlordPos  = pos.Id;
                    tableData.CallLandlordId   = pos.UserId;
                    tableData.CallLandlordName = pos.NickName;
                }
            }
            var param = new Parameters();

            param.Add("IsCall", isCall ? 1 : 0);
            param.Add("IsRob", (calledNum == 1 && isCall) || calledNum == 0 ? 0 : 1);
            SyncNotifyAction(ActionIDDefine.Cst_Action2006, tableData, param, null);

            TraceLog.WriteComplement("桌子:{0}叫地主通知成功,地主是:{1},是否结束{2}",
                                     tableData.TableId,
                                     tableData.IsCallEnd ? (tableData.LandlordId + "") : (tableData.CallLandlordId + tableData.CallLandlordName),
                                     tableData.IsCallEnd);
        }
コード例 #43
0
ファイル: PocoGenerator.tt.cs プロジェクト: LosManos/St4mpede
		private MethodData CreateHashMethod(TableData table, ClassData classData)
		{
			return new MethodData
			{
				IsConstructor = false,
				Name = "GetHashCode",
				Override = true,
				ReturnTypeString = typeof(int).ToString(),
				Comment = new CommentData("This is the GetHashCode method."),
				Parameters = null,
				Body = new BodyData(CreateBodyForGetHashCodeMethod(table))
			};
		}
コード例 #44
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
        public bool OutCard(int userId, int positionId, TableData tableData, string cardsStr)
        {
            int errorCode;

            return(DoOutCard(userId, positionId, tableData, cardsStr, out errorCode));
        }
コード例 #45
0
ファイル: PocoGenerator.tt.cs プロジェクト: LosManos/St4mpede
		internal IList<string> UT_CreateBodyForGetHashCodeMethod(TableData table)
		{
			return CreateBodyForGetHashCodeMethod(table);
        }
コード例 #46
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
        /// <summary>
        /// 出牌
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="positionId"></param>
        /// <param name="tableData"></param>
        /// <param name="cardsStr"></param>
        /// <param name="errorCode">0:正常,1:不合规则,2:不存在牌,3:离开桌位</param>
        public bool DoOutCard(int userId, int positionId, TableData tableData, string cardsStr, out int errorCode)
        {
            errorCode = 0;
            int[] cards = new int[0];
            if (!string.IsNullOrEmpty(cardsStr.Trim()))
            {
                string[]   tempArray = cardsStr.Split(new char[] { ',' });
                List <int> tempList  = new List <int>();
                for (int i = 0; i < tempArray.Length; i++)
                {
                    if (!string.IsNullOrEmpty(tempArray[i]))
                    {
                        tempList.Add(tempArray[i].ToInt());
                    }
                }
                cards = tempList.ToArray();
            }

            var pos = GetUserPosition(positionId, tableData);

            if (pos == null)
            {
                errorCode = 3;
                return(false);
            }
            if (!CheckCardEffective(pos.CardData, cards))
            {
                errorCode = 2;
                TraceLog.WriteComplement("桌子:{0}玩家{0}出牌{1}不在手中的牌内", tableData.TableId, userId, cardsStr);
                return(false);
            }
            int cardSize;
            var cardType = _cardRole.GetCardType(cards, out cardSize);

            if (cardType == DeckType.Error)
            {
                errorCode = 1;
                TraceLog.WriteComplement("桌子:{0}玩家{0}出牌{1}不合规则", tableData.TableId, userId, cardsStr);
                return(false);
            }
            if (cardType == DeckType.None && CheckOutCardNoneType(tableData))
            {
                //多次循环不出牌,则结束
                tableData.StopTimer();
                var param = new Parameters();
                param.Add("FleeUserId", 0);
                SyncNotifyAction(ActionIDDefine.Cst_Action2013, tableData, param,
                                 c =>
                {
                    //Console.WriteLine("Table:{0} is stop", tableData.TableId);
                    DoComplatedSettlement(tableData);
                    TraceLog.WriteError("桌子{0}多次连续不出牌并强制退出桌位", tableData.TableId);
                });
                errorCode = 3;
                return(true);
            }
            CardData cardData = new CardData(userId, positionId);

            cardData.Cards    = cards;
            cardData.Type     = cardType;
            cardData.CardSize = cardSize;

            if (tableData.PreCardData != null)
            {
                //压牌
                CardData tempData = tableData.PreCardData;
                if (cardData.Type != DeckType.None &&
                    tempData.Type != DeckType.None &&
                    tempData.UserId != cardData.UserId &&
                    !_cardRole.EqualsCard(cardData, tempData))
                {
                    errorCode = 1;
                    return(false);
                }
            }
            foreach (var card in cardData.Cards)
            {
                pos.CardData.Remove(card);
            }
            tableData.OutCardList.Add(cardData);
            if (cardData.Type != DeckType.None)
            {
                tableData.PreCardData = cardData;
            }

            if (cardData.Type == DeckType.Bomb ||
                cardData.Type == DeckType.WangBomb)
            {
                tableData.DoDouble();
            }
            if (pos.CardData.Count > 0)
            {
                int index   = (pos.Id + 1) % tableData.PlayerNum;
                var nextPos = tableData.Positions[index];
                tableData.OutCardPos    = nextPos.Id;
                tableData.OutCardUserId = nextPos.UserId;
                SyncNotifyAction(ActionIDDefine.Cst_Action2010, tableData, null, null);
            }
            else
            {
                //结束
                foreach (var p in tableData.Positions)
                {
                    TraceLog.WriteComplement("桌子:{0},房间:{1},玩家:{2}-{3}剩余牌{4}",
                                             tableData.TableId, tableData.RoomId, p.UserId, p.NickName, string.Join(",", p.CardData));
                }
                tableData.IsClosed      = true;
                tableData.IsLandlordWin = pos.IsLandlord ? true : false;
                DoOutCardEnd(tableData);

                SyncNotifyAction(ActionIDDefine.Cst_Action2012, tableData, null,
                                 t =>
                {
                    DoComplatedSettlement(tableData);
                    TraceLog.WriteComplement("桌子:{0}玩家:{1}出牌结束通知", tableData.TableId, userId);
                });
            }
            return(true);
        }
コード例 #47
0
        public void CreateFromTo(IFromToService fromToService, StringBuilder sb, UserData userData, TableData data)
        {
            if (!SameType(data.ColumnType))
            {
                return;
            }

            sb.Append("if (!DBNull.Value.Equals(");
            fromToService.FillDataRow(sb, userData, data);
            sb.Append(")) ");
            sb.Append("\n");
            sb.Append("    ");
            sb.Append(userData.ObjectName);
            sb.Append(data.ColumnName);
            sb.Append(" = ");
            fromToService.FillDataRow(sb, userData, data);
            sb.Append(".");
            sb.Append(userData.MethodExtension);
            sb.Append("<DateTime>();");
        }
コード例 #48
0
 public void GetData(IQueryable <MbomDetail> data, TableData result, PageReq pageRequest = null)
 {
     _app.GetData(data, result, pageRequest);
 }
コード例 #49
0
        private void InsertOrUpdateData(TableData table, SqlConnection conn, SqlTransaction tran, string sourceTable = null)
        {
            var insert = false;
            if (Update)
            {
                var clear =
                    SqlClearOptions.HasFlag(table.Schema.IsDimension()
                        ? SqlClearOptions.Dimensions
                        : SqlClearOptions.Facts);

                if (!clear && _cutoff.HasValue)
                {
                    var pfield = SqlUpdateUtil.GetPartitionField(table.Schema);
                    if (pfield != null)
                    {
                        var sql = string.Format("DELETE {0} FROM {0} {1}", Escape(table.Name),
                            SqlUpdateUtil.GetUpdateCriteria(table.Schema, pfield, true, _cutoff));
                        new SqlCommand(sql, conn, tran)
                        {
                            CommandTimeout = Timeout
                        }.ExecuteNonQuery();
                        insert = true;
                    }
                }
                else
                {
                    new SqlCommand(string.Format("DELETE FROM {0}", Escape(table.Name)), conn, tran).ExecuteNonQuery();
                    insert = true;
                }
            }


            SqlCommand cmd;
            //Merge new dimension values
            if (Update && !insert)
            {
                var sql = new StringBuilder();

                sql.AppendFormat(@"MERGE [{0}] WITH (TABLOCK) AS Target USING {1} AS Source ON {2} ",
                    table.Name,
                    sourceTable ?? "@Data",
                    //Join criteria
                    string.Join(" AND ",
                        (table.Schema.Keys.Length > 0 ? table.Schema.Keys : table.Schema.Dimensions).Select(
                            field =>
                                string.Format("{0} = {1}", Escape("Target", field.Value.Name),
                                    Escape("Source", field.Value.Name)))));

                if (table.Schema.Fields.Any(f => !table.Schema.IsKey(f)))
                {
                    sql.AppendFormat(@"WHEN Matched THEN UPDATE SET {0}",
                        //Update fields
                    string.Join(", ",
                        table.Schema.Fields.Where(f => !table.Schema.IsKey(f)).Select(field =>
                            string.Format(
                                field.FieldType == FieldType.Fact ? "{0} = [Target].{0} + {1}" : "{0} = {1}", // <- Consider this. What if dimensions have measures?
                                Escape(field.Name), Escape("Source", field.Name)))));
                }


                sql.AppendFormat("WHEN NOT MATCHED THEN INSERT ({0}) VALUES ({1});",
                    //Insert fields                                                
                    string.Join(", ",
                        table.Schema.Fields.Select(field => Escape(field.Name))),
                    string.Join(", ",
                        table.Schema.Fields.Select(field => Escape("Source", field.Name)))
                    );

                cmd = new SqlCommand(sql.ToString(), conn, tran);
            }
            else
            {
                cmd =
                    new SqlCommand(
                        string.Format("INSERT {0} WITH (TABLOCK) SELECT * FROM {1}", Escape(table.Name), sourceTable ?? "@Data"), conn, tran);
            }

            cmd.CommandTimeout = Timeout;
            if (sourceTable == null)
            {
                var p = cmd.Parameters.AddWithValue("@Data", new SqlRecordAdapter(table));
                p.SqlDbType = SqlDbType.Structured;
                p.TypeName = GetTableTypeName(table);
            }
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (ArgumentException ex)
            {
                //Ignore. SqlCommand throws ArgumentException when table is empty.
            }
        }
コード例 #50
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
        /// <summary>
        /// 结算积分
        /// </summary>
        /// <param name="tableData"></param>
        /// <param name="isLandlordWin"></param>
        /// <param name="landPos"></param>
        /// <param name="posList"></param>
        private void DoSettlement(TableData tableData, bool isLandlordWin, PositionData landPos, List <PositionData> posList)
        {
            //都有加积分
            GameUser user;

            if (isLandlordWin)
            {
                foreach (PositionData pos in posList)
                {
                    user = GetUser(pos.UserId);
                    if (user != null)
                    {
                        pos.CoinNum       = tableData.AnteNum / 2;
                        pos.ScoreNum      = tableData.MultipleNum / 2;
                        pos.CoinNum       = user.GameCoin > pos.CoinNum ? pos.CoinNum : user.GameCoin;
                        landPos.CoinNum  += pos.CoinNum;
                        landPos.ScoreNum += pos.ScoreNum;
                        pos.ScoreNum      = user.ScoreNum > pos.ScoreNum ? pos.ScoreNum : user.ScoreNum;

                        TraceLog.WriteComplement("桌子:{0}玩家(农):{1}败,结算:-{2}金豆,-{3}积分,之前剩余:{4}-{5}",
                                                 tableData.TableId, user.UserId, pos.CoinNum, pos.ScoreNum, user.GameCoin, user.ScoreNum);
                        user.GameCoin = MathUtils.Subtraction(user.GameCoin, pos.CoinNum);
                        user.ScoreNum = MathUtils.Subtraction(user.ScoreNum, pos.ScoreNum);
                        user.FailNum  = MathUtils.Addition(user.FailNum, 1);
                    }
                    else
                    {
                        landPos.CoinNum  += tableData.AnteNum / 2;
                        landPos.ScoreNum += tableData.MultipleNum / 2;
                    }
                }
                user = GetUser(landPos.UserId);
                if (user != null)
                {
                    TraceLog.WriteComplement("桌子:{0}玩家(主):{1}胜,结算:+{2}金豆,+{3}积分,之前剩余:{4}-{5}",
                                             tableData.TableId, user.UserId, landPos.CoinNum, landPos.ScoreNum, user.GameCoin, user.ScoreNum);
                    user.GameCoin = MathUtils.Addition(user.GameCoin, landPos.CoinNum);
                    user.ScoreNum = MathUtils.Addition(user.ScoreNum, landPos.ScoreNum);
                    user.WinNum   = MathUtils.Addition(user.WinNum, 1);
                    AchieveTask.SaveUserTask(user.UserId.ToString(), TaskClass.HuanLe, 1);
                    AchieveTask.SaveUserTask(user.UserId.ToString(), TaskClass.HuanLeJiFen, landPos.ScoreNum);
                }
            }
            else
            {
                user = GetUser(landPos.UserId);
                if (user != null)
                {
                    landPos.CoinNum  = user.GameCoin > tableData.AnteNum ? tableData.AnteNum : user.GameCoin;
                    landPos.ScoreNum = tableData.MultipleNum;

                    TraceLog.WriteComplement("桌子:{0}玩家(主):{1}败,结算:-{2}金豆,-{3}积分,之前剩余:{4}-{5}",
                                             tableData.TableId, user.UserId, landPos.CoinNum, landPos.ScoreNum, user.GameCoin, user.ScoreNum);
                    user.GameCoin = MathUtils.Subtraction(user.GameCoin, landPos.CoinNum);
                    user.ScoreNum = MathUtils.Subtraction(user.ScoreNum, user.ScoreNum > tableData.MultipleNum ? tableData.MultipleNum : user.ScoreNum);
                    user.FailNum  = MathUtils.Addition(user.FailNum, 1);
                }
                else
                {
                    landPos.CoinNum  += tableData.AnteNum;
                    landPos.ScoreNum += tableData.MultipleNum;
                }

                foreach (PositionData pos in posList)
                {
                    user = GetUser(pos.UserId);
                    if (user != null)
                    {
                        pos.CoinNum  = landPos.CoinNum / 2;
                        pos.ScoreNum = landPos.ScoreNum / 2;

                        TraceLog.WriteComplement("桌子:{0}玩家(农):{1}胜,结算:+{2}金豆,+{3}积分,之前剩余:{4}-{5}",
                                                 tableData.TableId, user.UserId, pos.CoinNum, pos.ScoreNum, user.GameCoin, user.ScoreNum);
                        user.GameCoin = MathUtils.Addition(user.GameCoin, pos.CoinNum);
                        user.ScoreNum = MathUtils.Addition(user.ScoreNum, pos.ScoreNum);
                        user.WinNum   = MathUtils.Addition(user.WinNum, 1);
                        AchieveTask.SaveUserTask(user.UserId.ToString(), TaskClass.HuanLe, 1);
                        AchieveTask.SaveUserTask(user.UserId.ToString(), TaskClass.HuanLeJiFen, pos.ScoreNum);
                    }
                }
            }
            _userCacheSet.Update();
            tableData.IsSettlemented = true;
            //出牌记录
            StringBuilder sb = new StringBuilder();

            foreach (var card in tableData.OutCardList)
            {
                sb.AppendLine();
                sb.AppendFormat("User:{0}\t->{1}", card.UserId, string.Join(",", card.Cards));
            }
            TraceLog.WriteComplement("房间:{0}桌子:{1}出牌记录:{2}", tableData.RoomId, tableData.TableId, sb);
        }
コード例 #51
0
 static string GetStagingTableName(TableData table)
 {
     return Escape("Staging", table.Name + "_Staging");
 }
コード例 #52
0
ファイル: UserLoc.cs プロジェクト: AlderMatus/WPFDemo
        // make a TableData object from a SADataReader record
#if !NO_ASA
        static void MakeDataRec(SADataReader myDataReader, out TableData data)
        {
            data = new TableData(
                MainClass.ToInt(TableName, myDataReader["UserIid"])
                , MainClass.ToInt(TableName, myDataReader["AreaIid"]));
        }
 public void TestInitialize()
 {
     tableData = new TableData();
     tableData.ColumnNames = new List<string> { "a", "b" };
     tableData.Rows.Add(new List<object> { "1", "2" });
 }
コード例 #54
0
 public void CreateFromTo(IFromToService fromToService, StringBuilder sb, UserData userData, TableData data)
 {
     sb.Append(userData.ObjectName);
     sb.Append(data.ColumnName);
     sb.Append(" = ");
     fromToService.FillRow(sb, userData, data);
 }
コード例 #55
0
        public TableData GetCodes(int campaignID, int pageNumber, int pageSize, CodeConverter codeConverter)
        {
            int         campaignSize = 0;
            int         codeIDStart  = 0;
            int         codeIDEnd    = 0;
            var         td           = new TableData(pageSize, pageNumber);
            List <Code> codes        = new List <Code>();

            Connection.Open();

            var transaction = Connection.BeginTransaction();
            var command     = Connection.CreateCommand();

            command.Transaction = transaction;

            try
            {
                // Get information about the campaign
                command.CommandText = @"
                    SELECT [Size], CodeIDStart, CodeIDEnd FROM Campaigns
                    WHERE ID = @campaignID
                ";
                command.Parameters.AddWithValue("@campaignID", campaignID);
                using (var reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        campaignSize = (int)reader["Size"];
                        codeIDStart  = (int)reader["CodeIDStart"];
                        codeIDEnd    = (int)reader["CodeIDEnd"];
                    }
                }

                // Set page count
                td.SetPageCount(campaignSize);

                // Get a page of codes from the campaign
                command.CommandText = @"
                    SELECT * FROM Codes
                    WHERE ID BETWEEN @codeIDStart AND @codeIDEnd
                    ORDER BY ID OFFSET @rowOffset ROWS
                    FETCH NEXT @pageSize ROWS ONLY
                ";
                command.Parameters.AddWithValue("@codeIDStart", codeIDStart);
                command.Parameters.AddWithValue("@codeIDEnd", codeIDEnd);
                command.Parameters.AddWithValue("@rowOffset", td.RowOffset);
                command.Parameters.AddWithValue("@pageSize", pageSize);

                // Read codes
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var code = new Code
                        {
                            StringValue = codeConverter.ConvertToCode((int)reader["SeedValue"]),
                            State       = States.ConvertToString((byte)reader["State"])
                        };
                        codes.Add(code);
                    }
                }

                transaction.Commit();

                // Add codes to the table data
                td.Codes = codes;
            }
            catch (Exception e)
            {
                transaction.Rollback();
            }

            Connection.Close();
            return(td);
        }
コード例 #56
0
ファイル: TurnData.cs プロジェクト: JeremyDelecraz/BlackJack
 public void addTableData(TableData tableData)
 {
     LstTable.Add(tableData);
 }
コード例 #57
0
 public void GetData(IQueryable <EquipmentAlarmLog> data, TableData result, PageReq pageRequest = null)
 {
     _app.GetData(data, result, pageRequest);
 }
コード例 #58
0
        private void ProcessTableTag(TableTag obTag)
        {
            TableData obData = new TableData(obTag);

            this.m_obPageData.m_Tables.Add(obData);
        }
コード例 #59
0
ファイル: GameTable.cs プロジェクト: liucy2007975/ddz-1
 /// <summary>
 /// 获取玩家座位
 /// </summary>
 /// <param name="user"></param>
 /// <param name="tableData"></param>
 /// <returns></returns>
 public PositionData GetUserPosition(GameUser user, TableData tableData)
 {
     return(GetUserPosition(user.Property.PositionId, tableData));
 }
コード例 #60
0
ファイル: Disp.cs プロジェクト: susan4343/StandardMathineHY
        public StationStep StepCheckIpos(bool bmanual = false)
        {
            StationStep step               = StationStep.Step_CheckIpos;
            bool        dEnableA           = ParamSetMgr.GetInstance().GetBoolParam("屏蔽A工位");
            bool        dEnableB           = ParamSetMgr.GetInstance().GetBoolParam("屏蔽B工位");
            bool        bA_UnLoadLoadStart = TableData.GetInstance().GetStationStartCmd("A_UnLoadLoad") && !dEnableA;
            bool        bB_UnLoadLoadStart = TableData.GetInstance().GetStationStartCmd("B_UnLoadLoad") && !dEnableB;

            if (bA_UnLoadLoadStart || bB_UnLoadLoadStart || ParamSetMgr.GetInstance().GetBoolParam("重新上料"))
            {
                ParamSetMgr.GetInstance().SetBoolParam("重新上料", false);
                TableData.GetInstance().ResetStartCmd("A_UnLoadLoad");
                TableData.GetInstance().ResetStartCmd("B_UnLoadLoad");
                strStationName = TableData.GetInstance().GetStationName();
                if (strStationName == "A_Pick" || strStationName == "B_Pick")
                {
                    TableData.GetInstance().SetStationResult("A_UnLoadLoad", true);
                    TableData.GetInstance().SetStationResult("B_UnLoadLoad", true);
                    return(step);
                }
                SocketNumOfUnloadLoad = TableData.GetInstance().GetSocketNum(1, 0.5) - 1;
                if (SocketNumOfUnloadLoad == 0 && dEnableA)
                {
                    TableData.GetInstance().SetStationResult("A_UnLoadLoad", true);
                    TableData.GetInstance().SetStationResult("B_UnLoadLoad", true);
                    return(step);
                }
                if (SocketNumOfUnloadLoad == 1 && dEnableB)
                {
                    TableData.GetInstance().SetStationResult("A_UnLoadLoad", true);
                    TableData.GetInstance().SetStationResult("B_UnLoadLoad", true);
                    return(step);
                }
                IOMgr.GetInstace().WriteIoBit("NG指示红灯", false);
                IOMgr.GetInstace().WriteIoBit("OK指示绿灯", true);
                Info("开始上下料,安全光栅开始屏蔽");
                ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", false);
                ParamSetMgr.GetInstance().SetBoolParam("可以上下料", true);

                SocketState state = SocketMgr.GetInstance().socketArr[SocketNumOfUnloadLoad].socketState;
                if (state == SocketState.HaveOK || state == SocketState.HaveNG)
                {
                    string lightColor = state == SocketState.HaveOK ? "OK指示绿灯" : "NG指示红灯";
                    string fp         = state == SocketState.HaveOK ? "P" : "F";
                    UserTest.TestResultAB[SocketNumOfUnloadLoad].SocketerNumber = SocketNumOfUnloadLoad == 0 ? "A" : "B";
                    #region 计算CT赋值
                    if (UserTest.ProductCount.CountCTAll == 0)
                    {
                        UserTest.ProductCount.StarCTTime  = DateTime.Now;
                        UserTest.ProductCount.EndCTTime   = DateTime.Now;
                        UserTest.ProductCount.CountCTTime = 0;
                    }
                    else
                    {
                        UserTest.ProductCount.CountCTTime += (DateTime.Now - UserTest.ProductCount.EndCTTime).TotalSeconds;
                        UserTest.ProductCount.EndCTTime    = DateTime.Now;
                        if ((DateTime.Now - UserTest.ProductCount.StarCTTime).TotalMinutes > ParamSetMgr.GetInstance().GetDoubleParam("UPH计算时长"))
                        {
                            if (UserTest.ProductCount.CountCTAll > ParamSetMgr.GetInstance().GetDoubleParam("UPH计算时长范围内最少个数"))
                            {
                                UserTest.ProductCount.UPH = (UserTest.ProductCount.CountCTAll) * 3600 / UserTest.ProductCount.CountCTTime;
                            }
                            //清除
                            UserTest.ProductCount.CountCTAll = -1;
                        }
                    }
                    UserTest.ProductCount.CountCTAll++;
                    if (SocketNumOfUnloadLoad == 0)
                    {
                        if (fp == "P")
                        {
                            UserTest.ProductCount.OKA++;
                        }
                        else
                        {
                            UserTest.ProductCount.NGA++;
                            if (!UserTest.FailResultAB.Play)
                            {
                                UserTest.ProductCount.PlayFailA++;
                                UserTest.FailResultAB.OC   = true;
                                UserTest.FailResultAB.SFR  = true;
                                UserTest.FailResultAB.Tilt = true;
                            }
                            if (!UserTest.FailResultAB.OC)
                            {
                                UserTest.ProductCount.OCFailA++;
                                UserTest.FailResultAB.Play = true;
                                UserTest.FailResultAB.SFR  = true;
                                UserTest.FailResultAB.Tilt = true;
                            }
                            if (!UserTest.FailResultAB.Tilt)
                            {
                                UserTest.ProductCount.TiltFailA++;
                                UserTest.FailResultAB.OC   = true;
                                UserTest.FailResultAB.SFR  = true;
                                UserTest.FailResultAB.Play = true;
                            }
                            if (!UserTest.FailResultAB.SFR)
                            {
                                UserTest.ProductCount.SFRFailA++;
                                UserTest.FailResultAB.OC   = true;
                                UserTest.FailResultAB.Play = true;
                                UserTest.FailResultAB.Tilt = true;
                            }
                            if (UserTest.FailResultAB.Play && UserTest.FailResultAB.OC && UserTest.FailResultAB.Tilt && UserTest.FailResultAB.SFR)
                            {
                                UserTest.ProductCount.OtherFailA++;
                            }
                        }
                    }
                    else
                    {
                        if (fp == "P")
                        {
                            UserTest.ProductCount.OKB++;
                        }
                        else
                        {
                            UserTest.ProductCount.NGB++;
                            if (!UserTest.FailResultAB.Play)
                            {
                                UserTest.ProductCount.PlayFailB++;
                                UserTest.FailResultAB.OC   = true;
                                UserTest.FailResultAB.SFR  = true;
                                UserTest.FailResultAB.Tilt = true;
                            }
                            if (!UserTest.FailResultAB.OC)
                            {
                                UserTest.ProductCount.OCFailB++;
                                UserTest.FailResultAB.Play = true;
                                UserTest.FailResultAB.SFR  = true;
                                UserTest.FailResultAB.Tilt = true;
                            }
                            if (!UserTest.FailResultAB.Tilt)
                            {
                                UserTest.ProductCount.TiltFailB++;
                                UserTest.FailResultAB.OC   = true;
                                UserTest.FailResultAB.SFR  = true;
                                UserTest.FailResultAB.Play = true;
                            }
                            if (!UserTest.FailResultAB.SFR)
                            {
                                UserTest.ProductCount.SFRFailB++;
                                UserTest.FailResultAB.OC   = true;
                                UserTest.FailResultAB.Play = true;
                                UserTest.FailResultAB.Tilt = true;
                            }
                            if (UserTest.FailResultAB.Play && UserTest.FailResultAB.OC && UserTest.FailResultAB.Tilt && UserTest.FailResultAB.SFR)
                            {
                                UserTest.ProductCount.OtherFailB++;
                            }
                        }
                    }


                    #endregion
                    Form_Auto.EvenShowCT(SocketNumOfUnloadLoad + 1);
                    UserTest.TestResultAB[SocketNumOfUnloadLoad].Result = fp == "P" ? true : false;
                    if (fp == "P")
                    {
                        UserTest.TestResultAB[SocketNumOfUnloadLoad].FailStep = "Pass";
                    }
                    UserTest.TestResultAB[SocketNumOfUnloadLoad].EndTime  = DateTime.Now;
                    UserTest.TestResultAB[SocketNumOfUnloadLoad].TestTime = (UserTest.TestResultAB[SocketNumOfUnloadLoad].EndTime - UserTest.TestResultAB[SocketNumOfUnloadLoad].StarTime).TotalSeconds;
                    string errCsv = CSVHelper.Instance.SaveToCSVPath(PathHelper.TestResultCsvPath, UserTest.TestResultAB[SocketNumOfUnloadLoad]);
                    IOMgr.GetInstace().WriteIoBit("OK指示绿灯", false);
                    IOMgr.GetInstace().WriteIoBit("NG指示红灯", false);
                    IOMgr.GetInstace().WriteIoBit(lightColor, true);
                    Info($"保存OK结果:cvs={errCsv}.");
                    if (SocketNumOfUnloadLoad == 0)
                    {
                        IOMgr.GetInstace().WriteIoBit($"ALens升降气缸", true);
                    }
                    else
                    {
                        IOMgr.GetInstace().WriteIoBit($"BLens升降气缸", true);
                    }
                    //PlaceToSocket(SocketNumOfUnloadLoad);
                    UserTest.CTTestAB[SocketNumOfUnloadLoad].Star = false;
                    UserTest.CTTestAB[SocketNumOfUnloadLoad].End  = false;
                    UserTest.CTTestAB[SocketNumOfUnloadLoad].Show = true;
                }
                //同意下料接口
                SysFunConfig.LodUnloadPatten.ULoad(SocketNumOfUnloadLoad == 0? "A":"B", bmanual);
retry_check_Start:
                ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", false);
                WaranResult waranResult = doWhileCheckStartSignal.doSomething(this, doWhileCheckStartSignal, false, new object[] { this });
                if (waranResult == WaranResult.Retry)
                {
                    goto retry_check_Start;
                }
                IOMgr.GetInstace().WriteIoBit($"相机光源", true);
                IOMgr.GetInstace().WriteIoBit("启动按钮灯", false);
                IOMgr.GetInstace().WriteIoBit("OK指示绿灯", false);
                IOMgr.GetInstace().WriteIoBit("NG指示红灯", false);
                if (!IOMgr.GetInstace().ReadIoInBit($"点胶液位感应") && ParamSetMgr.GetInstance().GetBoolParam("点胶液位检测"))
                {
                    MessageBox.Show($"点胶液位感应有信号,胶水已经用完!请更换,或者屏蔽[点胶液位检测]。", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    goto retry_check_Start;
                }
                Form_Auto.EvenGetSN(SocketNumOfUnloadLoad);
                if (UserTest.TestResultAB[SocketNumOfUnloadLoad].SerialNumber == "NOSN")
                {
                    MessageBox.Show("请输入SN 或者屏蔽SN,重新启动", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    goto retry_check_Start;
                }
                if (SocketNumOfUnloadLoad == 0)
                {
                    UserTest.ProductCount.CompeteA++;
                }
                else
                {
                    UserTest.ProductCount.CompeteB++;
                }
                ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", true);
                ParamSetMgr.GetInstance().SetBoolParam("可以上下料", false);
                ParamSetMgr.GetInstance().SetBoolParam("AA完成", false);
                ParamSetMgr.GetInstance().SetBoolParam("点胶完成", false);
                ParamSetMgr.GetInstance().SetBoolParam("启动AA", false);
                ParamSetMgr.GetInstance().SetBoolParam("启动点胶", false);
                Info("开始上下料,安全光栅开始启用");
                ParamSetMgr.GetInstance().SetBoolParam("启用安全光栅", true);
                UserTest.CTTestAB[SocketNumOfUnloadLoad].Star = true;
                UserTest.CTTestAB[SocketNumOfUnloadLoad].End  = false;
                UserTest.CTTestAB[SocketNumOfUnloadLoad].Show = false;

                step = StationStep.Step_GoSnap;
            }
            return(step);
        }