private void updatePosition(bool forward) { if (forward) { if (playbackPos < (numFrames - 1)) { playbackPos++; } else if (ckLoop.Checked) { playbackPos = 0; } } else { if (playbackPos > 0) { playbackPos--; } else if (ckLoop.Checked) { playbackPos = numFrames - 1; } } //Debug.Print(playbackPos.ToString()); //only send frame out if its ID is checked in the list. Otherwise discard it. int fid = foundID.IndexOf(loadedFrames[playbackPos].ID); if (cListFrames.GetItemChecked(fid)) { loadedFrames[playbackPos].timestamp = Utility.GetTimeMS(); parent.sideloadFrame(loadedFrames[playbackPos]); //index 0 is none, 1 is Bus 0, 2 is bus 1, 3 is from file. if (whichBusSend == 1) { parent.SendCANFrame(loadedFrames[playbackPos], 0); } if (whichBusSend == 2) { parent.SendCANFrame(loadedFrames[playbackPos], 1); } if (whichBusSend == 3) { parent.SendCANFrame(loadedFrames[playbackPos], loadedFrames[playbackPos].bus); } //updateFrameCounter(); } }
/// <summary> /// Called every millisecond to set the system update figures and send frames if necessary. /// </summary> /// <param name="sender"></param> /// <param name="timerEventArgs"></param> private void HandleTick(object sender, EventArgs e) { for (int i = 0; i < sendingData.Count; i++) { if (!sendingData[i].enabled) { continue; //abort any processing on this if it is not enabled. } if (sendingData[i].triggers == null) { return; } for (int j = 0; j < sendingData[i].triggers.Length; j++) { if (sendingData[i].triggers[j].currCount >= sendingData[i].triggers[j].maxCount) { continue; //don't process if we've sent max frames we were supposed to } if (!sendingData[i].triggers[j].readyCount) { continue; //don't tick if not ready to tick } //is it time to fire? if (++sendingData[i].triggers[j].msCounter >= sendingData[i].triggers[j].milliseconds) { sendingData[i].triggers[j].msCounter = 0; sendingData[i].count++; sendingData[i].triggers[j].currCount++; doModifiers(i); updateGridRow(i); parent.SendCANFrame(sendingData[i], sendingData[i].bus); if (sendingData[i].triggers[j].ID > 0) { sendingData[i].triggers[j].readyCount = false; //reset flag if this is a timed ID trigger } } } } }