Anylogic simultanious number of flowchart parts - java

I want to add a number of short flowcharts parts which aren't special in a row. The flowchart are in a separate agent named Seperateflowchart. Via Excel I want to read in the number of flowchart parts in a row. If I read in 10, the flowchart part in the image is added 10 times in a row between my source and sink in the main.
Well I basically don't have a good idea.

Best embed one flow chart block into one new agent type and put Enter and Exit blocks around it. Then, instantiate 10 of them (or whatever the data says) and make the actual agents visit these flow chart agents one by one.
See the help on how to use Enter and Exit blocks

Related

how can three cells work in parallel the incoming workpiece carriers in Analogic?

I want to create a conveyor line where three cells do the same work in parallel to reduce the cycle time.
Workflow:
Workpiece carrier = WT: 12 pieces
3x cells
The WT should always be directed to the cell that is free or the work process is most likely to finish.
Since I have just started to get to learn about Anylogic, I am having a hard time setting the correct commands.
If someone has an idea of how to reach my goal I would be very grateful!
Review the implementation in the Solar Panel Production Line Example model inside the AnyLogic help, or download the source form the AnyLogic Cloud
https://cloud.anylogic.com/model/29d54a61-aaac-4c47-8e50-941c0f5bb36e?mode=SETTINGS
Easiest would be to use a select output and base the selection of the exit from the select output on the condition of whether one of the cells are busy or not
In your example, you need to replace the code of randomFrom(collection) with a function to check if a cell is busy or not. Since you don't have the cells in your example I cant give you the code. But try it yourself and if you cant manage after reviewing the example model then post a new question

Prometheus query by label with range vectors

I'm defining a lot of counters in my app (using java micrometer) and in order to trigger alerts I tag the counters which I want to monitor with "error":"alert" so a query like {error="alert"} will generate multiple range vectors:
error_counter_component1{error="alert", label2="random"}
error_counter_component2{error="alert", label2="random2"}
error_counter_component3{error="none", label2="random3"}
I don't control the name of the counters I can only add the label to the counters I want to use in my alert. The alert that I want to have is if all the counters labeled with error="alert" increase more then 3 in one hour so I could use this kind of query: increase({error="alert"}[1h]) > 3 but I get the fallowing error in Prometheus: Error executing query: vector cannot contain metrics with the same labelset
Is there a way to merge two range vectors or should I include some kind of tag in the name of the counter? Or should I have a single counter for errors and the tags should specify the source something like this:
errors_counter{source="component1", use_in_alert="yes"}
errors_counter{source="component2", use_in_alerts="yes"}
errors_counter{source="component3", use_in_alerts="no"}
The version with source="componentX" label is much more fitting to prometheus data model. This is assuming the error_counter metric is really one metric and other than source label value it will have same labels etc. (for example it is emitted by the same library or framework).
Adding stuff like use_in_alerts label is not a great solution. Such label does not identify time series.
I'd say put a list of components to alert on somewhere where your alerting queries are constructed and dynamically create separate alerting rules (without adding such label to raw data).
Other solution is to have a separate pseudo metric that will obnly be used to provide metadata about components, like:
component_alert_on{source="component2"} 1
and. combine it in alerting rule to only alert on components you need. It can be generated in any possible way, but one possibility is to have it added in static recording rule. This has the con of complicating alerting query somehow.
But of course use_in_alerts label will also probably work (at least while you are only alerting on this metric).

Java save simple Data

i need to save data from an java desktop application. The main part of the Data are the texts of around 50 labels. Which are spread over 5 Java GUI-classes. The Rest are some simple application settings.
Now i am quit unsure about how to safe these data. A friend told me to use Random access Data and to write some kind of "serializable" object. At the moment i am using a .txt and a fileReader/writer. But this seemes impractical for 50-100 Data if your want to search the position in the .txt by every update. This is my same problem with random access data.
i thought about using some kind of embedded DB like "h2" but i dont now if this is to much and too complicated for such a small programm.
An other question is how do i put the text of all labels at the programm start. one way i am thinking about is to have a big list of all labels with determind positions and after reading the data from whatever to go over this list and set the labes. An other way would be to give every Label an id.
But maybe there is a much better way. But i dont now how to access the labels by names read from the data.
For saving serializable objects. Can i safe all the gui-object or do i need to combine se data in one class?
maybe someone could give a nice advise =)
For such a small number of labels, I would just keep all data in memory. On app initialization load the file and on every edit write the entire file from scratch
(If you are concerned about reliability in the face of power loss and random crashes during write you need to be careful here. For example, write the new data to a different file, fsync() then atomically rename the new file to the desired filename.)
I'm not sure I understand your serialization problem -- but it seems like you have some sort of language translation layer that tells the gui elements what to display. If so, then yes - I would store the labels in a central class (say LablesMap) and have the other classes refer to data in that class using some constant keys. E.g.,
myButton.setText(labelsMap.get(CANCEL_BUTTON_LABEL)
where CANCEL_BUTTON_LABEL is some constant or enum value.

Javav Sound selecting DataLines and Ports at runtime

I understand the concept of TargetDataLine and SourceDataLine and I have written a program to list them as well as the Ports and the available Controls for each. For the test progam I have an onboard mic, on board speakers, a line in, a speaker jack and an audio interface with two inputs and one output. The inputs on the interface are treated as left and right so I'm not sure how I would differentiate between the two if they act as one stereo input.
I want to be able to select the DataLine I want to use for either recording or playback at runtime. How can I identify and separate inputs and outputs to list them and allow a user to select a specific one to use? And if anyone has any suggestions for handling the interface input as two mono inputs That would be helpful as well. Thanks in advance.
To convert two mono lines into stereo requires interleaving the left and right, one "sample" at a time. The size of the sample depends on your bit depth. For example, 16-bit encoding consumes two bytes. So, take two bytes from the left, then two bytes from the right. Repeat for the duration of the lines.
There may be prebuilt methods that will help you with this. Check out the section in the Java Sound tutorials section on converting formats--it's like the 4th or 5th section of the sound tutorials, and happens to also be the best written of the bunch if I remember correctly. (Actual sample code provided, unlike much of the rest of this very difficult tutorial.)
I'm not sure how selecting a line or port is different from programming selecting anything else. You make a list, and the user clicks a button associated with the item, or selects the item from a drop down, then you plug it in.
I have a theremin where I made a menubar that allows one to select a mixer line. It just populates a radio button set with names of the mixers that are found. When you select the item the listener directs one to install the associated mixer.

Create printable daily schedule/document with Java

I have to create a java program that builds a "tidy" daily schedule for a sports arena.
The program takes in an excel file with a list of "untidy" daily bookings with the following information:
Start Time
End Time
Court
Client
I can read in this information and store it in "BookingObjects".
My question is this:
What is an elegant way to create a printable schedule output, similar to schedules displayed by Microsoft Outlook for example, with time as the rows and which court the booking is on in the columns. The schedule does not need to be interactive, just needs to be printable through the program's GUI and if it can be displayed within the GUI this is also a bonus?
We've recent made the move to Jasper Reports, the main reason was we were producing the reports in PDF, Excel and to the printer, all of which had to execute through different code and different libraries. Jasper Reports has allowed us to go through a single engine.
While not perfect, it does an outstanding job across different export options.
It does have a small learning curve, but the basics allow you to deliver a List of objects which you can then access from within the report and populate your view.
Equally, you can simply connect a SQL data source to it directly
Printing is one of the sore spots in Java. What you can try is create a UI with a table (see the Swing trail for examples) and then print that table.
The problems will start when the table doesn't fit on a single page of paper. If it's longer, then some lines will be printed on the margin (half of it will appear on the previous page and the lower half on the next page). If it's wider, ... let's not go there.
Alternatively, you can try to create a PDF using tools like JasperReports or BIRT. These work better but it will take some time to learn how they work.

Categories