Thank you for your answer. The data is used only to restore the last program state. There is an additional export feature - so I think SQLite ore SQL CE will achieve what I want. Alex
LionAM
Posts
-
Persistent storage of measuring results -
Persistent storage of measuring resultsIn principle, this is exactly what I want - store a live view of a certain time span as well as the status of several control charts. As the statistical spread of the measurement results is of great interest, it makes no sense to store only large fluctuations (then it would perhaps be too late to countersteer ...). As the data is only used to restore the last program state and therefore stored locally (there is a separate export feature), I would prefer some compact database (without a database server). Which would you recommend? SQLite? Alex
-
Persistent storage of measuring resultsThank you for your answer. In a previous version, we wrote the complete XML file - however, due to the relative large amount of data (and the limited resources, as it is an embedded system) - this will not be possible in the final release. So I think the database is the most promising. Which leaves me with the other questions, how to implement this as a weak reference pattern. Alex
-
Persistent storage of measuring resultsHello, I want to store the recent measuring results as well as control samples of older measurements persitently on disk so that the last state can be restored even in the case of a power loss. To make loading the data on startup not unnecessary slow, I want to remove the old, unneeded data from the list. This means that the measuring results will be continuously appended to the list, but the time when it will be removed is not known in advance. Would you recommend using a database (ideally some compact system like SQLite so that the user does not have to install a databse server) for this, or are there alternatives? My idea would be to store the measuring results in one table, using the measuring time as key. In another table, the keys for the last n measuring results would be stored and in a third table the keys of the control samples. If the entries of the first table are not referenced any more from the two other tables, the measuring results should be automatically removed. Is there some concept to acchieve this? Alex
-
Reuse template for different listbox itemsHello, I have a ListBox which is bound to an ObservableCollection, using some (complex) ItemTemplate to display the data. It is guaranteed that there is a fixed number of items within the ItemsSource. Every time, the ObservableCollection changes (e.g., an item is replaced), a new ItemTemplate is generated. Can I somehow avoid this and instead reuse the existing template object and simply bind this to the new data? My idea was to use a dynamic resource:
...
But how can I, in this case, set the Properties of the chart (e.g. the DataContext, or the Grid.Row as the object is embedded within a Grid)? A second problem is: If I have n elements within the ObservableCollection, I need n chart objects. How can I make sure to use a different chart object for each observable? Alex
-
SerialPort open, but receive no responseI finally found the cause: I have to set
_serialPort.DtrEnable = true;
and it works - I receive the expected data. However, I am still wondering why this is not done in typical other examples? Alex
-
SerialPort open, but receive no responseThank you for your answer. The settings are exactly the same as in Advance Serial Port Monitor as well as the manufacturer application. Indeed, it makes no difference if I change any of these settings except for the NewLine string (when I change this setting, the commands are not accepted any more). Perhaps the settings do not play any role because the COM port is only "virtual"? The device is connected to an USB slot, where the communication is handled by windows. However, still no response with SerialPort ... Alex
-
SerialPort open, but receive no responseHello, I am trying to communicate with a Cognex data matrix scanner which is connected to the PC via USB, emulating a COM port. I can open the connection and send commands to the scanner (which is reacting on the commands), but I do not receive any data from the port. For getting started, I used an example from the MSDN (http://msdn.microsoft.com/de-de/library/system.io.ports.serialport.aspx[^]) which I simplified and adjusted for the device:
// Create a new SerialPort object with default settings.
_serialPort = new SerialPort();//Set connection parameters
_serialPort.PortName = "COM4";
_serialPort.BaudRate = 115200;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = 8;
_serialPort.StopBits = StopBits.One;
_serialPort.Handshake = Handshake.None;
_serialPort.NewLine = "\r\n";// Set the read/write timeouts
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;_serialPort.Open();
I also tried to use the DataReceived and the other events - but also no response. I wrote a small C++ app to use the Win32 api directly but no response either. I downloaded several example applications - but still no response. The scanner, however, works with the manufacturer application - I therefore downloaded the trial of "Advanced Serial Port Monitor" to see the communication. Interestingly, with this program I am able to communicate with the device and to receive data as expected - but I don't know what is different... Alex
-
WPF: use enum as index for BindingAnd for the expression
{Binding Obj[Enum1.DoSomething()]}
I found a simple workaround for my case. I simply use multiple properties:
{Binding ObjDoSomething[Enum1]}
{Binding ObjDoSomethingElse[Enum1]}which internally call the extension method. Alex
-
WPF: use enum as index for BindingThank you for your answer. However, I have to admit that the C# forum was the wrong forum to ask my question. The Binding expression is not used within C# code but within a (static) .xaml file - although it should in principle be possible to assign the Binding string dynamically, I would avoid it for coding style reasons. Alex
-
WPF: use enum as index for BindingSorry, I missed that there is an WPF forum (hidden behind Silverlight...). Indeed, the samples shown in your links do it the other way round - get the string from the enum value. I needed the value from the string. My error was simply to use the full name
"{Binding Obj[TestEnum.Enum1]}"
instead of simply
"{Binding Obj[Enum1]}"
The latter works now. Alex
-
WPF: use enum as index for BindingHello, I wanted to use a (flag) enum as index to access the single flag values. Instead of
I hoped that I could use something like
with some helper object providing an index operator. The first works, the second does not...
Additionally: Can I use an expression (for example an extension method
TestEnum.Enum1.DoSomething()
(which returns a different enum item of the same type) instead of the enum item name for the Binding?
Alex
-
DrawImage with NearestNeighbor-InterpolationThank you for your answer. At the moment, I use a formula similar to your first aproach where I get an error of up to +/- 1 pixel - it may be enough for the moment... Your second aproach is clever. Perhaps I will try it later (using an invisible bitmap filled with the index as rgba value ...). Alex
-
DrawImage with NearestNeighbor-InterpolationHello, does anyone know where I can find the function which maps the pixel coordinates from the source to the destination? I draw a (stretched) bitmap using
InterpolationMode.NearestNeighbor
andPixelOffsetMode.Half
onto a canvas and now want to know which pixel was mapped to a certain position - so that if I click with the mouse on that stretched pixel, I get the original coordinates. Thank you in advance! Alex -
Store STL iterator in CListBoxThank you for your answer and the interesting article. However, as I mentioned, I am doing insertions within the middle of the list - so the indices change and it does not make any sense to store them in the data cell. Additionally: Your article assumes that I would have to find the right insert position and therefore the vector would be faster - but if it would have been possible to store the iterator inside the data cell, I would immediately start at the right position of my linked list. It would still be nice to have a data structure allowing access by index (not Key!) while beeing able to insert/remove elements in logarithmic time. Alex
-
Share C file across dll boundariesThank you for reminding that. As far as I can see, this is already done right in the sample file. Alex
-
Share C file across dll boundariesFor all global variables defined in the dll header, I defined a function (inside the dll) which returns the value/address of the corresponding global variable. These functions are called from the sample app instead of trying to access the global variables. Now, the dll seems to work - I can render my pdf files. Alex
-
Share C file across dll boundariesThank you for the answer. After correcting this issue (by calling a dll function which returns the dll "version" of colorspace variable), the program does not crash any more. However, it is still not working as expected... I have to search further for similar issues, which becomes more difficult as I don't know where to look for the problem. I think I will debug both the statically and the dynamically linked versions simultaneously and look where they behave different... Alex
-
Share C file across dll boundariesThank you for the answer. In the MuPDF sample, the file is opened with
int fd = _wopen(filename, _O_BINARY | _O_RDONLY, 0666);
The file descriptor
fd
is passed to a function defined within libmupdf. However, when this function tries to read the file (inside libmupdf):read(fd, buf, bufsize)
the function fails with the assertion
---------------------------
Microsoft Visual C++ Debug LibraryDebug Assertion Failed!
Program: p:\OLE_PDF\Debug\OLE_PDF_Test.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\read.c
Line: 86Expression: (_osfile(fh) & FOPEN)
I think the proble is that the libmupdf.dll "lives" in a different address space - you cannot simply assume that resources are valid inside the dll and the exe. Therefore, I changed the MuPDF sample so that the file is opened inside the library. Now the file is read as expected. However, there are still other (perhaps similar problems). For example, there are global variables inside libmupdf:
static fz_colorspace k_device_bgr = { -1, "DeviceRGB", 3, bgr_to_rgb, rgb_to_bgr };
fz_colorspace *fz_device_bgr = &k_device_bgr;In the library header (which is included in the MuPDF sample), it is declared as
extern fz_colorspace *fz_device_bgr;
Inside the MuPDF sample, there is a local variable
fz_colorspace *colorspace = fz_device_bgr;
It is passed to the library. However, the function fails with an access violation when the dll tries to change a member of the colorspace struct. The problem is that
fz_device_bgr
has different values inside the dll and inside the sample (where it is undefinded?). Alex -
Share C file across dll boundariesHello! I want to compile MuPDF as a dynamic library (dll) instead of a static library. With the static library, everthing works fine. However, the dll version is not working. When I call, e.g.
int f = _wopen(...);
read(f, ...);in the main app, everything works fine. However, if
read(f, ...);
is called inside the dll, I get an assertion. It seems to me that the file f is not known within the dll - therefore, the call to read(...) fails. Is there any way to share the files across dll boundaries? Alex