public BLRoutineShow() { db = DataLinkLayer.DBconnect(); bLPlanned = new BLPlanned(); bLExecuted = new BLExecuted(); Executed executed = new Executed() { ID = 1, RoutinePlannedID = 0, RoutineID = 0, ExerciseID = 0, Date = "01:01:01", Reps = "0", Sets = 2, lbs = "0" }; // db.CreateTable<Executed>(); //bLExecuted.InsertRoutineExecuted(executed); //db.DropTable<Exercise>(); //db.CreateTable<Exercise>(); //BLExercise bl = new BLExercise(); //bl.InsertExcercise(new Exercise()); //db.DropTable<Routine>(); //db.CreateTable<Routine>(); //BLRoutine bL = new BLRoutine(); //bL.InsertRoutine(new Routine()); //db.DropTable<Planned>(); //db.CreateTable<Planned>(); }
public List <Planned> ReadRoutinePlanned() { Planned p = new Planned(); List <Planned> list = DataLinkLayer.DBread <Planned>(p); return(list); }
public List <RoutineShow> RoutineShowSend() { Routine rt = new Routine(); //BLRoutine r = new BLRoutine(); //Int32 c = r.InsertRoutine(rt); RoutinePlanned rpd = new RoutinePlanned(); // Int32 d = InsertRoutinePlanned(rpd); int d = InsertRoutinePlanned(rpd); List <RoutinePlanned> routinePlanned = DataLinkLayer.DBread <RoutinePlanned>(rpd); List <Routine> routine = DataLinkLayer.DBread <Routine>(new Routine()); List <Exercise> exercise = DataLinkLayer.DBread <Exercise>(new Exercise()); List <RoutineShow> myRoutine = new List <RoutineShow>(); { foreach (RoutinePlanned rp in routinePlanned) { String a = routine.Find(x => x.RoutineID == rp.RoutineID).RoutineName; String b = exercise.Find(x => x.ExcerciseID == (rp.ExcertciseID)).Name; myRoutine.Add(new RoutineShow { RoutineName = a, ExcerciseName = b }); } }; Console.WriteLine(myRoutine.ToString()); return(myRoutine); }
public int UpdateProfile(Profile profileUpdate) { //Profile toUpdate = ReadProfileId(profileUpdate.ProfileID); //Profile profile = profileUpdate; return(DataLinkLayer.DBupdate <Profile>(profileUpdate)); }
public Int32 InsertRoutineExecuted(Executed ExecutedRoutine) { var maxPK = db.Table <Executed>().OrderByDescending(c => c.ID).FirstOrDefault(); if (maxPK != null) { rExecuted = new Executed() { ID = (maxPK == null ? 1 : (maxPK.ID + 1)), RoutineID = ExecutedRoutine.RoutineID, ExerciseID = ExecutedRoutine.ExerciseID, Date = ExecutedRoutine.Date, Reps = ExecutedRoutine.Reps, Sets = ExecutedRoutine.Sets, lbs = ExecutedRoutine.lbs }; } else { db.CreateTable <Executed>(); rExecuted = new Executed() { ID = 0, RoutineID = ExecutedRoutine.RoutineID, ExerciseID = ExecutedRoutine.ExerciseID, Date = ExecutedRoutine.Date, Reps = ExecutedRoutine.Reps, Sets = ExecutedRoutine.Sets, lbs = ExecutedRoutine.lbs }; } return(DataLinkLayer.DBinsert <Executed>(rExecuted)); }
public Int32 InsertRoutinePlanned(Planned routinePlanned) { //int count = 0; //foreach (Planned rp in GetRoutinePlanned()) //{ // Int32 x = DataLinkLayer.DBinsert<Planned>(rp); // count += x; //} //return count; var maxPK = db.Table<Planned>().OrderByDescending(c => c.ID).FirstOrDefault(); Planned plannedRoutine = new Planned() { ID = (maxPK == null ? 1 : (maxPK.ID + 1)), RoutineID = routinePlanned.RoutineID, ExcerciseID = routinePlanned.ExcerciseID }; return DataLinkLayer.DBinsert<Planned>(plannedRoutine); }
public List <RoutineShow> RoutineShowSend() { Routine rt = new Routine(); Planned rpd = new Planned(); Exercise ex = new Exercise(); BLExercise addExerciseData = new BLExercise(); BLRoutine addRoutineData = new BLRoutine(); RoutineShow eachRoutineShow = new RoutineShow(); //db.DropTable<Routine>(); //db.CreateTable<Routine>(); //BLRoutine bL = new BLRoutine(); //bL.InsertRoutine(new Routine()); //db.DropTable<Planned>(); //db.CreateTable<Planned>(); List <Routine> routine = DataLinkLayer.DBread <Routine>(new Routine()); List <Exercise> exercise = DataLinkLayer.DBread <Exercise>(new Exercise()); List <RoutineShow> finalList = new List <RoutineShow>(); finalList.Clear(); List <Planned> routinePlanned = DataLinkLayer.DBread <Planned>(rpd); Console.WriteLine(routinePlanned); RoutineShow myRoutineShow = new RoutineShow(); foreach (Planned rp in routinePlanned) { String a = routine.Find(x => x.RoutineID == rp.RoutineID).RoutineName; String b = exercise.Find(x => x.ExcerciseID == (rp.ExcerciseID)).Name; Console.WriteLine(a + "-" + b + "-" + rp.Date); if (finalList.Find(x => x.RoutineName.Equals(a)) == null) { RoutineShow routineShow = new RoutineShow(); routineShow.RoutineName = a; routineShow.ExcerciseList.Add(b); routineShow.ExTime = rp.Date; routineShow.Sets.Add(rp.Sets); routineShow.Reps.Add(rp.Reps); routineShow.Lbs.Add(rp.Lbs); finalList.Add(routineShow); } else { finalList.Find(x => x.RoutineName.Equals(a)).ExcerciseList.Add(b); finalList.Find(x => x.RoutineName.Equals(a)).ExTime = rp.Date; finalList.Find(x => x.RoutineName.Equals(a)).Sets.Add(rp.Sets); finalList.Find(x => x.RoutineName.Equals(a)).Reps.Add(rp.Reps); finalList.Find(x => x.RoutineName.Equals(a)).Lbs.Add(rp.Lbs); } } return(finalList); }
public List <Exercise> ReadExercise() { Exercise e = new Exercise(); // Int32 count = InsertExcercise(e); List <Exercise> list = DataLinkLayer.DBread <Exercise>(e); return(list); }
public BLProfile() { db = DataLinkLayer.DBconnect(); BLRoutine bl = new BLRoutine(); //DeleteProfile(12); //ReadProfile(db); }
public void UpdatePlanned(ExerciseShow exerciseShow) { Planned planned = ReadRoutinePlanned(exerciseShow); planned.Reps = exerciseShow.Reps; planned.Lbs = exerciseShow.Lbs; DataLinkLayer.DBupdate(planned); }
// delete exercise from planned routine public Boolean DeletePlanned(ExerciseShow exerciseShow) { Planned toDelPlanned = ReadRoutinePlanned(exerciseShow); if (DataLinkLayer.DBdelete <Planned>(toDelPlanned) > 0) { return(true); } return(false); }
public Planned ReadRoutinePlanned(ExerciseShow exerciseShow) { List <Planned> planneds = ReadRoutinePlanned(); List <Exercise> exerciseList = DataLinkLayer.DBread <Exercise>(new Exercise()); List <Routine> routineList = DataLinkLayer.DBread <Routine>(new Routine()); Int32 routineID = routineList.Find(x => x.RoutineName.Equals(exerciseShow.RoutineName)).RoutineID; Int32 Exerciseid = exerciseList.Find(x => x.Name.Equals(exerciseShow.ExcerciseName)).ExcerciseID; return(planneds.Find(x => x.RoutineID == routineID && x.ExcerciseID == Exerciseid)); }
public BLPlanned() { db = DataLinkLayer.DBconnect(); bLExercise = new BLExercise(); bLRoutine = new BLRoutine(); exercises = bLExercise.ReadExercise(); routines = bLRoutine.ReadRoutine(); //Planned rpd = new Planned(); // Int32 d = InsertRoutinePlanned(rpd); }
public void SendCommunicationMessage(byte[] bytes, List <UpdateInformation> infoList, object lockobj) { int nFrameLen = 0; if ((bytes.Length) % 8 == 0) { nFrameLen = (bytes.Length) / 8; } else { nFrameLen = (bytes.Length) / 8 + 1; } m_bIsSendMultiFrame = true; int nSendIndex = 0; for (int n = nFrameLen; n > 0; n--) { byte[] byteCmdBuf = new byte[8]; if (nSendIndex + 8 > bytes.Length) { Buffer.BlockCopy(bytes, nSendIndex, byteCmdBuf, 0, (bytes.Length - nSendIndex)); } else { Buffer.BlockCopy(bytes, nSendIndex, byteCmdBuf, 0, 8); } uint BqProtID = (uint)(BqProtocolID | (n - 1)); DataLinkLayer.SendCanFrame(BqProtID, byteCmdBuf); nSendIndex += 8; UpdateInformation info = new UpdateInformation(); info.DirectionStr = "发送"; info.Length = byteCmdBuf.Length.ToString(); info.TimeStr = DateTime.Now.ToString("MM/dd HH:mm:ss") + string.Format(":{0}", DateTime.Now.Millisecond); info.ID = string.Format("0x{0}", BqProtID.ToString("X")); info.Content = BitConverter.ToString(byteCmdBuf); if (nFrameLen > 1) { info.Comments = string.Format("多帧第{0}帧,共{1}帧", nFrameLen - n + 1, nFrameLen); } else { info.Comments = string.Format("第{0}帧,共{1}帧", nFrameLen - n + 1, nFrameLen); } lock (lockobj) { infoList.Add(info); } } m_bIsSendMultiFrame = false; }
public void EraseDidiRecord() { byte[] rdBuf = new byte[] { m_bSourceAddress, 0x03, 0xDD, 0xBD, 0x00, 0x06, 0x00, 0x00 }; byte[] crc16 = CRC_Check.CRC16(rdBuf, 0, rdBuf.Length - 2); rdBuf[rdBuf.Length - 2] = crc16[1]; rdBuf[rdBuf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[6]; Buffer.BlockCopy(rdBuf, 2, cmdBuf, 0, rdBuf.Length - 2); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
public void ReadDidiCurrentRecordData() { byte[] rdBuf = new byte[] { m_bSourceAddress, 0x03, 0xCC, 0xA4, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00 }; byte[] crc16 = CRC_Check.CRC16(rdBuf, 0, rdBuf.Length - 2); rdBuf[rdBuf.Length - 2] = crc16[1]; rdBuf[rdBuf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[8]; Buffer.BlockCopy(rdBuf, 2, cmdBuf, 0, rdBuf.Length - 2); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
public Boolean DeletePlanned(Planned p) { Int32 count = DataLinkLayer.DBdelete <Planned>(p); if (count > 0) { return(true); } else { return(false); } }
public Int32 InsertExcercise(Exercise e) { int count = 0; foreach (Exercise ex in GetExercises()) { Int32 x = DataLinkLayer.DBinsert <Exercise>(ex); count += x; } return(count); }
public void InsertData(object sender, EventArgs e) { Profile profile = new Profile(); profile.Name = txt_name.Text; // Metrix = matrix.SelectedItem.ToString() == "US" ? false : true, if (matrix.SelectedItem.ToString() == "US") { profile.Metrix = false; } else { profile.Metrix = true; } if (gender.SelectedItem.ToString() == "Male") { profile.Gender = 1; } else if (gender.SelectedItem.ToString() == "Female") { profile.Gender = 2; } else { profile.Gender = 3; } profile.Height = Double.Parse(txt_height.Text.ToString()); profile.Weight = Double.Parse(txt_weight.Text.ToString()); profile.DOB = dob.Date.ToString(); // Actually insert data in database DataLinkLayer dll = new DataLinkLayer(); SQLiteConnection db = DataLinkLayer.DBconnect(); int insertConfirm = DataLinkLayer.DBinsert(profile); if (insertConfirm > 0) { Console.WriteLine("User Name" + profile.Name); //System.Diagnostics.Debug.WriteLine(""+ profile.Name); //await DisplayAlert(null, profile.Name + "Saved", "ok"); } // dll.ReadProfile(db); DataLinkLayer.DBclose(db); }
public void DD_PowerOff() { byte[] poBuf = new byte[] { m_bSourceAddress, 0x03, 0x10, 0xA2, 0x00, 0x01, 0x00, 0x00, 0x5A, 0xE9 }; byte[] crc16 = CRC_Check.CRC16(poBuf, 0, poBuf.Length - 2); poBuf[poBuf.Length - 2] = crc16[1]; poBuf[poBuf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[8]; Buffer.BlockCopy(poBuf, 2, cmdBuf, 0, 8); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
private void CheckConnectReadSOH() { byte[] rdBuf = new byte[] { m_bSourceAddress, 0x03, 0x03, 0xA2, 0x00, 0x01, 0x00, 0x00 }; byte[] crc16 = CRC_Check.CRC16(rdBuf, 0, rdBuf.Length - 2); rdBuf[rdBuf.Length - 2] = crc16[1]; rdBuf[rdBuf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[6]; Buffer.BlockCopy(rdBuf, 2, cmdBuf, 0, 6); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
public void DD_ReadFeedbackInfo() { byte[] rdBuf = new byte[] { m_bSourceAddress, 0x03, 0x03, 0xA2, 0xA0, 0x03, 0x00, 0x00 }; byte[] crc16 = CRC_Check.CRC16(rdBuf, 0, rdBuf.Length - 2); rdBuf[rdBuf.Length - 2] = crc16[1]; rdBuf[rdBuf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[6]; Buffer.BlockCopy(rdBuf, 2, cmdBuf, 0, rdBuf.Length - 2); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
public void DD_SettingBrakeStatus(byte status) { byte[] Buf = new byte[] { m_bSourceAddress, 0x03, 0x10, 0xA2, 0x68, 0x01, status, 0x00, 0x00, 0x00 }; byte[] crc16 = CRC_Check.CRC16(Buf, 0, Buf.Length - 2); Buf[Buf.Length - 2] = crc16[1]; Buf[Buf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[8]; Buffer.BlockCopy(Buf, 2, cmdBuf, 0, 8); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
public void DD_ReleyEvent() { byte[] Buf = new byte[] { m_bSourceAddress, 0x03, 0x46, 0x02, 0x00, 0x00, 0x00, 0x00 }; byte[] crc16 = CRC_Check.CRC16(Buf, 0, Buf.Length - 2); Buf[Buf.Length - 2] = crc16[1]; Buf[Buf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[6]; Buffer.BlockCopy(Buf, 2, cmdBuf, 0, 6); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
public void SendMultiFrame(byte[] dataBuf, int len, byte nCmd) { byte[] cmdBuf = new byte[len + 8]; cmdBuf[0] = m_bSourceAddress; cmdBuf[1] = 0x03; cmdBuf[2] = 0xDD; cmdBuf[3] = nCmd; byte[] lenBuf = BitConverter.GetBytes((short)cmdBuf.Length - 2); cmdBuf[4] = lenBuf[1]; cmdBuf[5] = lenBuf[0]; Buffer.BlockCopy(dataBuf, 0, cmdBuf, 6, len); byte[] crc16 = CRC_Check.CRC16(cmdBuf, 0, cmdBuf.Length - 2); cmdBuf[cmdBuf.Length - 2] = crc16[1]; cmdBuf[cmdBuf.Length - 1] = crc16[0]; int nFrameLen = 0; if ((cmdBuf.Length - 2) % 8 == 0) { nFrameLen = (cmdBuf.Length - 2) / 8; } else { nFrameLen = (cmdBuf.Length - 2) / 8 + 1; } m_bIsSendMultiFrame = true; int nSendIndex = 2; for (int n = nFrameLen; n > 0; n--) { byte[] byteCmdBuf = new byte[8]; if (nSendIndex + 8 > cmdBuf.Length) { Buffer.BlockCopy(cmdBuf, nSendIndex, byteCmdBuf, 0, (cmdBuf.Length - nSendIndex)); } else { Buffer.BlockCopy(cmdBuf, nSendIndex, byteCmdBuf, 0, 8); } uint BqProtID = (uint)(BqProtocolID | (n - 1)); DataLinkLayer.SendCanFrame(BqProtID, byteCmdBuf); nSendIndex += 8; Thread.Sleep(5); } m_bIsSendMultiFrame = false; }
private void SendMessages(String text, ulong sequence, ulong messageId, Boolean sendnowflag) { //STrace.Debug("", Id, "SendMessages did={0} msg={1}", Id, text); var msg = new UserMessage(Id, sequence).AddStringToSend(text); if (!sendnowflag) { Fota.Enqueue(this, messageId, text); } else { DataLinkLayer.SendMessage(Id, msg); } }
private void SendSingleFrameData(byte[] rdBuf) { byte[] crc16 = CRC_Check.CRC16(rdBuf, 0, rdBuf.Length - 2); rdBuf[rdBuf.Length - 2] = crc16[1]; rdBuf[rdBuf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[rdBuf.Length - 2]; Buffer.BlockCopy(rdBuf, 2, cmdBuf, 0, rdBuf.Length - 2); DataLinkLayer.SendCanFrame(BqProtocolID, cmdBuf); bReadBqBmsResp = false; }
public void DD_ReadRegister(byte[] addr, byte num) { byte[] rdBuf = new byte[] { m_bSourceAddress, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 }; Buffer.BlockCopy(addr, 0, rdBuf, 3, addr.Length); rdBuf[addr.Length + 3] = num; byte[] crc16 = CRC_Check.CRC16(rdBuf, 0, rdBuf.Length - 2); rdBuf[rdBuf.Length - 2] = crc16[1]; rdBuf[rdBuf.Length - 1] = crc16[0]; byte[] cmdBuf = new byte[6]; Buffer.BlockCopy(rdBuf, 2, cmdBuf, 0, rdBuf.Length - 2); DataLinkLayer.SendCanFrame(DidiProtocolID, cmdBuf); }
public BLExecuted() { db = DataLinkLayer.DBconnect(); //db.CreateTable<Executed>(); exerciseList = bLExercise.ReadExercise(); routineList = bLRoutine.ReadRoutine(); planneds = bLPlanned.ReadRoutinePlanned(); //Planned rpd = new Planned(); // Int32 d = InsertRoutinePlanned(rpd); }
public Int32 InsertRoutinePlanned(RoutinePlanned routinePlanned) { int count = 0; db.CreateTable <RoutinePlanned>(); foreach (RoutinePlanned rp in GetRoutinePlanned()) { Int32 x = DataLinkLayer.DBinsert <RoutinePlanned>(rp); count += x; } return(count); }