void ChangeBCState() { switch (bcState) { case BCState.HIDE: if (hideRun) { collider2d.enabled = false; fit = (FIT)Random.Range(0, Enum.GetNames(typeof(FIT)).Length); // img 변경 randomPos = Random.Range(-3f, 3f); this.transform.position = new Vector3(randomPos, startHeight, 0); hideRun = false; } break; case BCState.APPEAR: hideRun = true; collider2d.enabled = true; this.transform.Translate(0, -speed * Time.deltaTime, 0); break; case BCState.DIE: bcState = BCState.HIDE; if (!hideRun) // false일때 true 바꾸기 위해 { hideRun = true; } break; } }
private void writeDefintion(string[] str) { byte header = byte.Parse(str[1]); int localMesgIndex = header & 0x0f; byte reserved = byte.Parse(str[2]); localMsgDef msgDef = new localMsgDef(); byte arch = msgDef.Architecture = byte.Parse(str[3]); UInt16 globalMesgIndex = msgDef.globalMesgIndex = UInt16.Parse(str[4]); byte fields = msgDef.Fields = byte.Parse(str[5]); msgDef.localFields = new localField[fields]; msgDef.mesg = FIT.getMessageStruct(msgDef.globalMesgIndex); localMesgDefs[localMesgIndex] = msgDef; fitstream.writeValue(header); fitstream.writeValue(reserved); fitstream.writeValue(arch); fitstream.writeValue(globalMesgIndex, 0); fitstream.writeValue(fields); for (int i = 0; i < fields; i++) { localField fielddef = new localField(); byte FieldDefinitionNumber = fielddef.FieldDefinitionNumber = byte.Parse(str[6 + (i) * 3]); byte size = fielddef.size = byte.Parse(str[7 + (i) * 3]); byte baseType = fielddef.baseType = byte.Parse(str[8 + (i) * 3]); fielddef.GlobalField = FIT.getFieldStruct(msgDef.mesg, (int)FieldDefinitionNumber); localMesgDefs[localMesgIndex].localFields[i] = fielddef; fitstream.writeValue(FieldDefinitionNumber); fitstream.writeValue(size); fitstream.writeValue(baseType); } }
public void writeValue(localField localFieldDef, string value, statistics st, int globalMesgIndex) { UInt32 _UInt32 = 0; Int32 _Int32 = 0; UInt16 _UInt16 = 0; Int16 _Int16 = 0; byte _byte = 0; int size = localFieldDef.size; int arch = localFieldDef.arch; int baseType = localFieldDef.baseType; globalField globalField = localFieldDef.GlobalField; string fieldName = globalField.name; double scale = globalField.scale; double offset = globalField.offset; if (localFieldDef.FieldDefinitionNumber == 253) { DateTime dt; DateTime.TryParseExact(value, "yyyy-MM-dd HH:mm:ss", cuNL, DateTimeStyles.None, out dt); value = ((UInt32)dt.ToUniversalTime().Subtract(dt1989).Duration().TotalSeconds).ToString("0"); } if (globalMesgIndex == FIT.FIT_MESG_NUM_SESSION) { switch (fieldName) { case "start_time": writeValue(st.SessionStartTimestamp, arch); return; case "start_position_lat": writeValue(st.start_position_lat, arch); return; case "start_position_long": writeValue(st.start_position_long, arch); return; case "total_elapsed_time": writeValue(st.total_elapsed_time, arch); return; case "total_timer_time": writeValue(st.total_timer_time, arch); return; case "total_distance": writeValue(st.total_distance, arch); return; case "total_calories": writeValue(st.total_calories, arch); return; case "avg_speed": writeValue(st.avg_speed, arch); return; case "max_speed": writeValue(st.max_speed, arch); return; case "avg_heart_rate": writeValue(st.avg_heart_rate); return; case "max_heart_rate": writeValue(st.max_heart_rate); return; case "avg_cadence": writeValue(st.avg_cadence); return; case "max_cadence": writeValue(st.max_cadence); return; case "avg_power": writeValue(st.avg_power, arch); return; case "max_power": writeValue(st.max_power, arch); return; case "total_ascent": writeValue((UInt16)(st.SessionTotal_ascent / 5.0), arch); return; case "total_descent": writeValue((UInt16)(st.SessionTotal_descent / 5.0), arch); return; } } if (globalMesgIndex == FIT.FIT_MESG_NUM_LAP) { switch (fieldName) { case "start_time": writeValue(st.LapStartTimestamp, arch); return; case "start_position_lat": writeValue(st.start_position_lat, arch); return; case "start_position_long": writeValue(st.start_position_long, arch); return; case "total_elapsed_time": writeValue(st.total_elapsed_time, arch); return; case "total_timer_time": writeValue(st.total_timer_time, arch); return; case "total_distance": writeValue(st.total_distance, arch); return; case "total_calories": writeValue(st.total_calories, arch); return; case "avg_speed": writeValue(st.avg_speed, arch); return; case "max_speed": writeValue(st.max_speed, arch); return; case "avg_heart_rate": writeValue(st.avg_heart_rate); return; case "max_heart_rate": writeValue(st.max_heart_rate); return; case "avg_cadence": writeValue(st.avg_cadence); return; case "max_cadence": writeValue(st.max_cadence); return; case "avg_power": writeValue(st.avg_power, arch); return; case "max_power": writeValue(st.max_power, arch); return; case "total_ascent": writeValue((UInt16)(st.LapTotal_ascent / 5.0), arch); return; case "total_descent": writeValue((UInt16)(st.LapTotal_descent / 5.0), arch); return; } } switch (baseType) { case 0x00: writeValue(FIT.StringToEnum(fieldName, value)); break; //enum case 0x01: if (value == "") { writeValue((sbyte)0x7F); } else { writeValue((sbyte)((double.Parse(value) + offset) * scale + 0.1)); } break; //sbyte case 0x02: if (value == "") { writeValue((byte)0xFF); } else { writeValue(_byte = (byte)((double.Parse(value) + offset) * scale + 0.1)); } break; //byte case 0x83: if (value == "") { writeValue((Int16)0x7FFF, arch); } else { writeValue(_Int16 = (Int16)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //int16 case 0x84: if (value == "") { writeValue((UInt16)0xFFFF, arch); } else { writeValue(_UInt16 = (UInt16)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //Uint16 case 0x85: if (value == "") { writeValue((Int32)0x7FFFFFFF, arch); } else { writeValue(_Int32 = (Int32)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //int32 case 0x86: if (value == "") { writeValue((UInt32)0xFFFFFFFF, arch); } else { writeValue(_UInt32 = (UInt32)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //Uint32 case 0x87: if (value == "") { writeValue((UInt32)0xFFFFFFFF, arch); } else { writeValue((UInt32)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //float32 case 0x89: if (value == "") { writeValue((UInt64)0xFFFFFFFFFFFFFFFF, arch); } else { writeValue((UInt64)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //float64 case 0x0A: if (value == "") { writeValue((byte)0x00); } else { writeValue((byte)((double.Parse(value) + offset) * scale + 0.1)); } break; //byteZ case 0x8B: if (value == "") { writeValue((UInt16)0x00, arch); } else { writeValue((UInt16)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //Uint16Z case 0x8C: if (value == "") { writeValue((UInt32)0x00, arch); } else { writeValue((UInt32)((double.Parse(value) + offset) * scale + 0.1), arch); } break; //Uint32Z case 0x07: for (int i = 0; i < size; i++) { writeValue(value.ToArray()[i]); } break;; //string case 0x0D: for (int i = 0; i < size; i++) { writeValue(byte.Parse(value.Substring(i * 2, 2), NumberStyles.AllowHexSpecifier)); } break;; //string default: break; } if (globalMesgIndex == FIT.FIT_MESG_NUM_RECORD) { switch (fieldName) { case "timestamp": st.timestamp = _UInt32; break; case "position_lat": if (st.start_position_lat == 0) { st.start_position_lat = _Int32; } break; case "position_long": st.start_position_long = _Int32; break; case "altitude": st.altitude = _UInt16; break; case "distance": st.distance = _UInt32; break; case "speed": st.speed = _UInt16; break; case "power": st.power = _UInt16; break; case "cadence": st.cadence = _byte; break; case "heart_rate": st.heart_rate = _byte; break; } } }
public static extern bool FIFSupportsExportType(FIF format, FIT ftype);
public static extern bool FIFSupportsICCProfiles(FIF format, FIT ftype);
public static extern FIBITMAP AllocateT(FIT ftype, int width, int height, int bpp, uint red_mask, uint green_mask, uint blue_mask);
public static extern FIBITMAP ConvertToType(FIBITMAP dib, FIT dst_type, bool scale_linear);
void ChangeFIT() { switch ((int)bcState) { case 0: // HIDE delTime += Time.deltaTime; if (delTime >= spawnTime) { coll2D.enabled = true; bcState = BCState.APPEAR; delTime = 0.0f; // 소환 되는 타임 초기화 spawnTime = Random.Range(1.0f, maxSpawnTime); fit = (FIT)rand.RC(); // 소환되는 종류 설정 step = Random.Range(0, floorY.Length); // 몇번째 줄에 소환되는지 설정 if (step == 0 && mgr.stepcheck[0] != true) { this.transform.position = new Vector2(this.transform.position.x, floorY[step] + collHeightHalf); // 소환되는 위치 설정 mgr.stepcheck[0] = true; } else if (step == 1 && mgr.stepcheck[1] != true) { this.transform.position = new Vector2(this.transform.position.x, floorY[step] + collHeightHalf); // 소환되는 위치 설정 mgr.stepcheck[1] = true; } else if (step == 2 && mgr.stepcheck[2] != true) { this.transform.position = new Vector2(this.transform.position.x, floorY[step] + collHeightHalf); // 소환되는 위치 설정 mgr.stepcheck[2] = true; } } break; case 1: // APPEAR if (this.transform.position.x <= -4) { bcState = BCState.DIE; } else { transform.Translate((-1) * speed, 0, 0); // 실질적 이동 } break; case 2: // DIE this.transform.position = spawnPos; coll2D.enabled = false; if (step == 0 && mgr.stepcheck[0] != false) { mgr.stepcheck[0] = false; } else if (step == 1 && mgr.stepcheck[1] != false) { mgr.stepcheck[1] = false; } else if (step == 2 && mgr.stepcheck[2] != false) { mgr.stepcheck[2] = false; } bcState = BCState.HIDE; break; } }
public string readValue(localField localFieldDef) { globalField FIELD = localFieldDef.GlobalField; double scale = FIELD.scale; double offset = FIELD.offset; int size = localFieldDef.size; int arch = localFieldDef.arch; string fm = scale <= 1 ? "0" : scale <= 10 ? "0.0" : scale <= 100 ? "0.00" : scale <= 1000 ? "0.000" : "0.0000"; baseType = localFieldDef.baseType; switch (baseType) { case 0x00: strValue = FIT.EnumToString(localFieldDef.GlobalField.name, (int)(_enum = readbyte())); break; //enum case 0x01: strValue = ((isLastValueValid = (_sbyte = readsbyte()) != 0x7f) ? (_sbyte / scale - offset).ToString(fm) : ""); break; //sbyte case 0x02: strValue = ((isLastValueValid = (_byte = readbyte()) != 0xFF) ? (_byte / scale - offset).ToString(fm) : ""); break; //byte case 0x83: strValue = ((isLastValueValid = (_int16 = readInt16(arch)) != 0x7FFF) ? (_int16 / scale - offset).ToString(fm) : ""); break; //int16 case 0x84: strValue = ((isLastValueValid = (_Uint16 = readUInt16(arch)) != 0xFFFF) ? (_Uint16 / scale - offset).ToString(fm) : ""); break; //Uint16 case 0x85: strValue = ((isLastValueValid = (_int32 = readInt32(arch)) != 0x7FFFFFFF) ? (_int32 / scale - offset).ToString(fm) : ""); break; //int32 case 0x86: strValue = ((isLastValueValid = (_Uint32 = readUInt32(arch)) != 0xFFFFFFFF) ? (_Uint32 / scale - offset).ToString(fm) : ""); break; //Uint32 case 0x87: strValue = ((isLastValueValid = (_Uint32 = readUInt32(arch)) != 0xFFFFFFFF) ? (_Uint32 / scale - offset).ToString(fm) : ""); break; //float32 case 0x89: strValue = ((isLastValueValid = (_Uint64 = readUInt64(arch)) != 0xFFFFFFFFFFFFFFFF) ? (_Uint64 / scale - offset).ToString(fm) : ""); break; //float64 case 0x0A: strValue = ((isLastValueValid = (_byte = readbyte()) != 0x00) ? (_byte / scale - offset).ToString(fm) : ""); break; //byteZ case 0x8B: strValue = ((isLastValueValid = (_Uint16 = readUInt16(arch)) != 0x00) ? (_Uint16 / scale - offset).ToString(fm) : ""); break; //Uint16Z case 0x8C: strValue = ((isLastValueValid = (_Uint32 = readUInt32(arch)) != 0x00) ? (_Uint32 / scale - offset).ToString(fm) : ""); break;; //Uint32Z case 0x07: for (int i = 0; i < size; i++) { strValue += readChar(); } break;; //string case 0x0D: for (int i = 0; i < size; i++) { strValue += readbyte().ToString("X2"); } break;; //string default: break; } switch (FIELD.name) { case "timestamp": break; case "position_lat": break; case "position_long": break; case "altitude": break; case "distance": break; case "speed": break; case "power": break; } return(strValue); }
private string readFieldDef() { localMsgDef msgDef = new localMsgDef(); msgDef.reserved = file.readbyte(); if (msgDef.reserved != 0) { return(""); } msgDef.Architecture = file.readbyte(); if (msgDef.Architecture > 1) { return(""); } msgDef.globalMesgIndex = file.readUInt16(msgDef.Architecture); if (msgDef.globalMesgIndex > 255 && msgDef.globalMesgIndex < 0xFE00) { return(""); } msgDef.mesg = FIT.getMessageStruct(msgDef.globalMesgIndex); msgDef.Fields = file.readbyte(); if (msgDef.Fields > msgDef.mesg.fields.Length + 10) { return(""); } recordString += (string.Format(";{0};{1};{2};{3}", msgDef.reserved, msgDef.Architecture, msgDef.globalMesgIndex, msgDef.Fields)); recordDefinitionHeader = ";;reserved;Architecture;globalMesgIndex;Fields"; msgDef.localFields = new localField[msgDef.Fields]; for (int i = 0; i < msgDef.Fields; i++) { localField fieldDef = new localField(); byte d = fieldDef.FieldDefinitionNumber = file.readbyte(); byte s = fieldDef.size = file.readbyte(); byte b = fieldDef.baseType = file.readbyte(); fieldDef.arch = (((b & 0x80) == 0x80) && msgDef.Architecture == 1) ? 1 : 0;; fieldDef.GlobalField = FIT.getFieldStruct(msgDef.mesg, d); { if (d == 253) { msgDef.isCompressedMsg = false; } //if (fieldDef.field.valid && (fieldDef.field.type != b || fieldDef.field.num != d)) return ""; if (!(d <= 80 || d >= 253)) { return(""); } if (!(b == 0x00 && s == 1 || b == 0x01 && s == 1 || b == 0x02 && s == 1 || b == 0x83 && s == 2 || b == 0x84 && s == 2 || b == 0x85 && s == 4 || b == 0x86 && s == 4 || b == 0x07 && s > 0 || b == 0x88 && s == 4 || b == 0x89 && s == 8 || b == 0x0A && s == 1 || b == 0x8B && s == 2 || b == 0x8C && s == 4 || b == 0x0D && s > 0)) { return(""); } recordString += (string.Format(";{0};{1};{2}", d, s, b)); } msgDef.localFields[i] = fieldDef; } msgDef.isValid = true; localMsgDef = localMsgDefs[localMesgIndex] = msgDef; return(string.Format("{0}\n{1}\n{2}", recordDefinitionHeader, recordString, getHeader(localMesgIndex))); }
private string readFieldData() { string str = ""; localMsgDef = localMsgDefs[localMesgIndex]; foreach (localField localField in localMsgDef.localFields) { str = file.readValue(localField); globalField globalField = localField.GlobalField; if (globalField.foutMarge >= 0) { Int64 value = file.getLastValue(); if (file.isLastValueValid) { if (localField.lastGoodValue == Int64.MinValue) { localField.lastGoodValue = value; } else if (Math.Abs(localField.lastGoodValue - value) > globalField.foutMarge) { return(""); } else { localField.lastGoodValue = value; } } else { if (globalField.name == "software_version" || globalField.name == "device_index") //verplicht veld { return(""); } } } if (globalField.name == "timestamp") { str = FIT.timestampToLocalTime(UInt32.Parse(str)); } recordString += ";" + str; switch (globalField.name) { case "timestamp": timestamp = file._Uint32; break; case "position_lat": position_lat = file._int32; break; case "position_long": position_long = file._int32; break; case "altitude": altitude = file._Uint16; break; case "distance": distance = file._Uint32; break; case "speed": speed = file._Uint16; break; case "power": power = file._Uint16; break; case "cadence": cadence = file._byte; break; case "event": _event = file._enum; break; case "event_type": _event_type = file._enum; break; } } return(recordString); }
private void closeSession(StreamWriter outFile, localMsgDef[] localMsgDefs, UInt32 TravelEndTimestamp)//, DateTime dt, UInt32 start_position_lat, UInt32 start_position_long, UInt32 total_elapsed_time, UInt32 total_timer_time, UInt32 total_distance, UInt32 total_calories, UInt32 avg_speed, UInt32 max_speed, UInt32 avg_power, UInt32 max_power, UInt32 total_ascent, UInt32 total_descent, UInt32 avg_heart_rate, UInt32 max_heart_rate, UInt32 avg_cadence, UInt32 max_cadence) { int _event = 0; int i = 0; for (i = 0; i < 16; i++) { if (localMsgDefs[i] == null) { break; } if (localMsgDefs[i].globalMesgIndex == FIT.FIT_MESG_NUM_EVENT) { _event = i; } if (localMsgDefs[i].globalMesgIndex == FIT.FIT_MESG_NUM_SESSION) { return; } } outFile.WriteLine(string.Format("def;{0};0;0;18;31;253;4;134;2;4;134;3;4;133;4;4;133;7;4;134;8;4;134;9;4;134;10;4;134;29;4;133;30;4;133;31;4;133;32;4;133;254;2;132;11;2;132;13;2;132;14;2;132;15;2;132;20;2;132;21;2;132;22;2;132;23;2;132;25;2;132;26;2;132;0;1;0;1;1;0;5;1;0;6;1;0;16;1;2;17;1;2;18;1;2;19;1;2", i + 64)); outFile.WriteLine(string.Format("data;{0};{1};708788214;627355257;56710458;6176,85;5831,27;52979,47;;;;;;0;997;;9,085;13,627;231;712;137;133;0;53;SESSION;STOP;CYCLING;255;154;180;76;116", i, FIT.timestampToLocalTime(TravelEndTimestamp))); outFile.WriteLine(string.Format("data;{0};{1};1;SESSION;STOP_DISABLE_ALL;1", _event, FIT.timestampToLocalTime(TravelEndTimestamp))); outFile.WriteLine(string.Format("def;{0};0;0;34;6;253;4;134;0;4;134;1;2;132;2;1;0;3;1;0;4;1;0", i + 1 + 64)); outFile.WriteLine(string.Format("data;{0};{1};5831,27;1;0;ACTIVITY;STOP", i + 1, FIT.timestampToLocalTime(TravelEndTimestamp))); }