|
If you want "Intel hex" do exactly what the spec says; if you want something else, don't call it "Intel hex".
Whatever you do, calculating the checksum does not involve the textual representation, it starts off with the data bytes no matter what they represent.
|
|
|
|
|
Guys,
I could solve the problem.
This is the solution...
private string ToHexString(string str)
{
var sb = new StringBuilder();
var bytes = Encoding.Unicode.GetBytes(str);
for(int i=0; i<str.Length; i++)
{
byte b = (byte)str[i];
sb.Append(b.ToString("X"));
}
return sb.ToString();
}
}
}
However, this has opened up new problem.
Now the checksum is wrong
When I pass string "Quote: :107830003132313131303031323331323334363120 "
for checksum calculation, the expected o/p is 0x2B however the function returns "20".
this is the function...
private string GetChecksum(string strData)
{
byte checksum = 0;
char[] DataArray = strData.ToCharArray();
byte ArrayLen = 0;
string strAscii;
while (ArrayLen < strData.Length)
{
if ((DataArray[ArrayLen]) != ':')
{
checksum += (byte)DataArray[ArrayLen];
}
ArrayLen++;
}
checksum = (byte)(~(int)checksum);
checksum += 1;
strAscii = ((checksum & 0xF0) >> 4).ToString("X") + (checksum & 0x0F).ToString("X");
return strAscii;
}
When I debug the problem, I could see, the function received first 1 in string as 31. I know that is the problem, it should receive first 10 as 10 and not as 31 30
|
|
|
|
|
private void VtfGraphicalViewMode(Page page, float x, float y)
{
AddCaptionAndRectangle(page, "Vertical Forces Graph", x, y, CHAR_WIDTH, CHAR_HEIGHT);
ceTe.DynamicPDF.PageElements.Charting.Chart chart =
new ceTe.DynamicPDF.PageElements.Charting.Chart(x + 10, y + 25, CHAR_WIDTH - 25, CHAR_HEIGHT - 25, ceTe.DynamicPDF.Font.Helvetica, 10, RgbColor.Black);
ceTe.DynamicPDF.PageElements.Charting.PlotArea plotArea = chart.PrimaryPlotArea;
ceTe.DynamicPDF.PageElements.Charting.Title headerTitle =
new ceTe.DynamicPDF.PageElements.Charting.Title("Vertical Forces (VTF)");
chart.HeaderTitles.Add(headerTitle);
if (vtfGraph.Count > 0)
{
ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries leftVTFLineSeries =
new ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries("Left VTF");
leftVTFLineSeries.Values.Add(vtfGraph.GetLeftVTF(0, 100));
ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries rightVTFLineSeries =
new ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries("Right VTF");
rightVTFLineSeries.Values.Add(vtfGraph.GetRightVTF(0, 100));
ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries totalVTFLineSeries =
new ceTe.DynamicPDF.PageElements.Charting.Series.IndexedLineSeries("Total VTF");
totalVTFLineSeries.Values.Add(vtfGraph.GetTotalVTF(0, 100));
plotArea.Series.Add(leftVTFLineSeries);
plotArea.Series.Add(rightVTFLineSeries);
plotArea.Series.Add(totalVTFLineSeries);
}
page.Elements.Add(chart);
}
Regards,
Manjum
|
|
|
|
|
And?
If you are waiting for permission, consider it given.
If you have a problem, then it's probably a good idea to explain what problem you are having, where you are having it, and what help you need in solving it...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I want to add many items after scan them one by one from database into datatable
public void CheckItem( string itemcode)
{
string constring = @"Data Source=.;Initial Catalog=pos;User id = sa;password=123";
SqlCommand objCmd = new SqlCommand();
objCmd.Parameters.Clear();
using (SqlConnection objCnn = new SqlConnection(constring))
{
objCnn.Open();
using (objCmd = objCnn.CreateCommand())
{
objCmd.CommandType = CommandType.Text;
objCmd.CommandText = "SELECT * FROM Items where Item_Code=@Item_Code";
objCmd.Parameters.Add(new SqlParameter("@Item_Code", itemcode));
SqlDataReader myreader = objCmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(myreader);
decimal sumprice=0;
if (dt.Rows.Count <= 0)
dt = objDT.NewRow();
dt.Columns.Add("", typeof(decimal));
dataGridView1.DataSource = dt;
}
}
}
|
|
|
|
|
I suggest moving the instantiation of the datatable to a class level (outside of you method) and each time you populate dt you add the dt rows to the class level table.
The class level table is the one that will be bound to your DGV
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
anyone cal add code in this for that
public class VerticalForceGraph
{
private List<verticalforce> vtfList = new List<verticalforce>();
public int BufferSize { get; set; }
public void Add(VerticalForce vtf)
{
vtfList.Add(vtf);
// remove first item if condition
if(vtfList.Count > BufferSize)
{
// vtfList.RemoveRange(1, 1);
vtfList.RemoveAt(0);
}
}
public int[] GetLeftVTF()
{
return vtfList.Select(x => x.Left).ToArray();
}
public int[] GetRightVTF()
{
return vtfList.Select(x => x.Right).ToArray();
}
public int[] GetTotalVTF()
{
return vtfList.Select(x => x.Total).ToArray();
}
}
// and i want to cal it here and draw graph
private void VtfGraphicalViewMode(Graphics graphics)
{
Pen yellowPen = new Pen(Color.Yellow, 2);
Pen bluePen = new Pen(Color.Blue, 2);
Pen redPen = new Pen(Color.Red, 2);
int hOffset = heatmapWidth / 2;
int vOffset = heatmapHeight / 2;
//Display title
using (Font title_font = new Font("Times New Roman", 20))
{
using (StringFormat string_format = new StringFormat())
{
string_format.Alignment = StringAlignment.Center;
string_format.LineAlignment = StringAlignment.Center;
Point title_center = new Point(this.heatmapWidth / 2, 20);
Point titleleft = new Point(this.heatmapHeight / 4, heatmapWidth/10);
Font leftfornt = new Font("Times New Roman", 10);
Font totalfont = new Font("Times New Roman", 10);
Font rightfont = new Font("Times New Roman", 10);
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.DrawRectangle(outline, new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight));
Rectangle graph_area = new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight);
graphics.FillRectangle(Brushes.LightBlue, graph_area);
graphics.DrawString("VTF Grahical View",
title_font, Brushes.Blue,
title_center, string_format);
graphics.DrawString("Left VTF", leftfornt, Brushes.Blue, titleleft, string_format);
//Y-axis
int xOffset = 50;
int yOffset = 20;
graphics.DrawLine(Pens.Blue,
heatmapCoord_X + xOffset, heatmapCoord_Y + (heatmapHeight - 50),heatmapCoord_X + xOffset, heatmapCoord_Y + yOffset
);
//X-axis
graphics.DrawLine(Pens.Blue,
heatmapCoord_X + (heatmapWidth - 10), heatmapCoord_Y + (heatmapHeight - 50), heatmapCoord_X + xOffset, heatmapCoord_Y + (heatmapHeight - 50)
);
|
|
|
|
|
You haven't described a problem at all as your "question" makes no sense. Your code makes even less sense.
We have no idea what you're having a problem with or what you're asking.
|
|
|
|
|
namespace VistaBalanceAlgorithms
{
public class VerticalForce
{
public static float SteadyStateTotalForce = 1;
public static bool SteadyState = false;
public VerticalForce(float[] frameValues)
{
Left = 0;
Right = 0;
Total = 0;
if (frameValues != null)
{
float leftForce = frameValues.Take(frameValues.Length / 2).Sum();
float rightForce = frameValues.Skip(frameValues.Length / 2).Sum();
Left = (int)((leftForce / SteadyStateTotalForce) * 100);
Right = (int)((rightForce / SteadyStateTotalForce) * 100);
Left = Left < 0 ? 0 : Left;
Right = Right < 0 ? 0 : Right;
Total = Left + Right;
}
}
public int Left { get; protected set; }
public int Right { get; protected set; }
public int Total { get; protected set; }
}
public class VerticalForceGraph
{
private List<VerticalForce> vtfList = new List<VerticalForce>();
public int BufferSize { get; set; }
public void Add(VerticalForce vtf)
{
vtfList.Add(vtf);
if(vtfList.Count > BufferSize)
{
vtfList.RemoveAt(0);
}
}
public int[] GetLeftVTF()
{
return vtfList.Select(x => x.Left).ToArray();
}
public int[] GetRightVTF()
{
return vtfList.Select(x => x.Right).ToArray();
}
public int[] GetTotalVTF()
{
return vtfList.Select(x => x.Total).ToArray();
}
}
}
here i want to cal it on another class
//here i only created rectangle inside panel and draw x and y acc to panel scale
private void HeatmapViewMode(Graphics graphics)
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.DrawRectangle(borderPen, new Rectangle(heatmapCoord_X, heatmapCoord_Y, heatmapWidth, heatmapHeight));
Pen semiTransPen = new Pen(Color.FromArgb(128, 0, 0, 255), 3);
var points = m_CopTail.GetPoints().Select(c => { c.X = c.X - m_AutocenterOffsetX; c.Y = c.Y - m_AutocenterOffsetY; return c; }).ToArray();
if (points != null && points.Length > 1)
{
SizeF copPointSize = new SizeF(10, 10);
SizeF centerOffset = new SizeF(copPointSize.Width / 2, copPointSize.Height / 2);
PointF copPoint = new PointF(COP.X - m_AutocenterOffsetX - centerOffset.Width,
COP.Y - m_AutocenterOffsetY - centerOffset.Height);
graphics.FillEllipse(Brushes.Red, new RectangleF(copPoint, copPointSize));
if (m_CopTail.TimeRange.TotalSeconds > 0)
graphics.DrawCurve(semiTransPen, points);
if ((Mode == ModeOfOperation.STABILITY_MODE && m_CopTail.HasAutoCenter() == true) ||
(m_CopTail.HasAutoCenter() == true && CopArrow == true))
{
PointF centerPoint = new PointF(heatmapCoord_X + heatmapWidth / 2f,
heatmapCoord_Y + heatmapHeight / 2f);
PointF endPoint = new PointF(copPoint.X + centerOffset.Width, copPoint.Y + centerOffset.Height);
var distance = Math.Sqrt(Math.Pow((centerPoint.X - endPoint.X), 2) + Math.Pow((centerPoint.Y - endPoint.Y), 2));
float triggerZoneDiameter = 30f;
StabilityTriggerZoneDraw(graphics, triggerZoneDiameter, distance > triggerZoneDiameter);
graphics.DrawLine(stabilityArrowPen, centerPoint, endPoint);
}
if (heatmap != null)
heatmap.Draw(graphics, heatmapCoord_X - m_AutocenterOffsetX, heatmapCoord_Y - m_AutocenterOffsetY, 80);
}
}
|
|
|
|
|
It's "calibrate", not "cal". Yes, it makes a difference when talking to other people who are not involved in your project.
So, what's the problem? You still haven't described the problem you're having.
|
|
|
|
|
I need to get 'Form1' to retain its black back-ground color while the 3 labels with a white BackColor displaying famous quotes are not visible (Form1 totally black) until a mouse pointer hovers over a label and reveals the famous quote(s) during the execution of runtime.
Ronald Richards
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I followed the instructions that tells me to put three labels to the form each displaying a famous quote. When the program starts, the BackColor of the form and each of the 3 labels should be black. Now, as the user passes or hovers the mouse pointer over a label it should change the label's BackColor white thus revealing the quote. The results I get is not the same. That is, when the program starts the BackColor of the form is black, but the 3 labels do not have a black back ground at all. Instead, all the labels on the form are visible (showing quotes) with a white BackColor. Now, as I hover my mouse pointer over each label the back ground color of the form turns white and as I release the pointer from the label(s) the back ground color of the form returns to black.// The control settings in the properties window are: On Form1; BackColor = ControlText(black) & ForeColor = ControlText(black)// On Label1,Label2,Label3; BackColor = White & ForeColor = ControlText(black). In the Events window settings are:On Form1; Load = Form1_Load & MouseHover = Form1_Load// On Label1,Label2,Label3; MouseHover = Label1,2,3_MouseHover
Ronald Richards
|
|
|
|
|
Well you answer you own question!
Member 13364520 wrote: When the program starts, the BackColor of the form and each of the 3 labels should be black.
Member 13364520 wrote: On Label1,Label2,Label3; BackColor = White & ForeColor = ControlText(black).
So set the BackColor of the Labels to Black...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Welcome to CodeProject !
Questions here need to have more detail than what you've written. At the least, share the ideas you have for this project: what is required to sense the mouse moving over a Control which is not visible ?
Hint: examine the Rectangle.Contains method.
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it. A few hundred years later another traveler despairing as myself, may mourn the disappearance of what I may have seen, but failed to see.» Claude Levi-Strauss (Tristes Tropiques, 1955)
|
|
|
|
|
Hi,
if a Controls foreground and background colors equal its parents background color, would you call it visible?
|
|
|
|
|
If an application crashes in a forest, does anyone notice the BSoD?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That is exactly why Win10 "BSoD" got switched to green
|
|
|
|
|
Only if it's black on a black background, a small black light lights up black.
This space for rent
|
|
|
|
|
Pete, you just revealed the first famous quote; can you discover the other two as well? without hovering?
|
|
|
|
|
I attempted to hover once. I managed it for less than half a second.
Okay. It was a jump. I jumped, but let's call it hovering for the sake of avoiding edge cases.
This space for rent
|
|
|
|
|
Pete O'Hanlon wrote: I managed it for less than half a second. The secret is in the time.
David Eddings, Magicians Gambit : “What was that?" Belgarath asked, coming back around the corner.
"Brill," Silk replied blandly, pulling his Murgo robe back on.
"Again?" Belgarath demanded with exasperation. "What was he doing this time?"
"Trying to fly, last time I saw him." Silk smirked.
The old man looked puzzled.
"He wasn't doing it very well," Silk added.
Belgarath shrugged. "Maybe it'll come to him in time."
"He doesn't really have all that much time." Silk glanced out over the edge.
From far below - terribly far below - there came a faint, muffled crash; then, after several seconds, another. "Does bouncing count?" Silk asked.
Belgarath made a wry face. "Not really."
"Then I'd say he didn't learn in time." Silk said blithely.”
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
only in the surrender of the light could the darkness prevail.
|
|
|
|
|
Please explain! I noticed as I set the BackColor of the Labels white, and Form1 having a black BackColor; in runtime when I hover over a label, the whole back ground color of Form1 turns white. Now this is the problem, because the form is always suppose to stay black when the labels should be darkened (black) until the user hovers a mouse pointer over it to lighten it up - revealing the quotes. So, I changed the BackColor setting of the labels to black; now the whole form is Black, but as I Run the program and hover my mouse over a label nothing happens,i.e, the labels stays black as well as the form. How can I tweak this program to get the results required in runtime?
Ronald Richards
|
|
|
|
|
It's a quote from the Hitchhiker's Guide to the Galaxy:
Hitchhiker's Guide Quotes (‘It’s the wild colour scheme that freaks me out,’...)[^]
It's a jokey response to Luc's slightly tounge-in-cheek response to your original question:
if a Controls foreground and background colors equal its parents background color, would you call it visible?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|