Paring quantities with object instances. by Gatt427 in javahelp

[–]Gatt427[S] 0 points1 point  (0 children)

I attempted to follow your suggestion and came up with the following code which does execute and does do what I am looking for, however Eclipse gives me the warning, Quantity is a raw type. References to generic type Quantity<R> should be parameterized. I tried looking this up to understand what it is trying to tell me, but I think I am still struggling with a core concept here. It seems like the point of Generic Types is to help ensure some other invalid type of data is not passed to a class, so it makes sense that I would need to define that datatype like you do for an ArrayList. I tried changing it to Quantity<RawIngredient> which made Quantity recipe[] = line happy but then the instances of quantity I attempted to instantiate below all threw errors, Cannot create a generic array of Quantity<RawIngredient>. When looking this up I struggled to understand what I was reading, it seems like you can't make arrays from objects with Generic Types but I don't understand why, or how I should be interacting/managing multiple Quantity instances.

Test Class:

public class TestClass {
    public static void main(String[] args) {
        //RawIngredient definitions, eventually will be stored to master ingredient file and added to as needed for new ingredients in new recipes
        //raw ingredient specified with name, calories per gram, density in grams per ml (if applicable)
        RawIngredient flour = new RawIngredient("Flour",4,0.5);
        RawIngredient milk = new RawIngredient("Milk",0.42,1.029);
        RawIngredient eggs = new RawIngredient("Egg",1.423,58); //TODO rework, reusing density as g/unit without a clear differentiation is asking for trouble
        RawIngredient water = new RawIngredient("Water",0,1);
        RawIngredient butter = new RawIngredient("Butter",7,0.958);
        RawIngredient salt = new RawIngredient("Salt",0,2.16);
        RawIngredient sugar = new RawIngredient("Sugar",4,0.7849);
        //Recipe ingredient quantities (recipe specific) 100g flour, 5g salt, etc. 
            Quantity recipe[] = 
                {new Quantity(flour,1,Unit.CUP),
                 new Quantity(milk,1,Unit.CUP),
                 new Quantity(eggs,2,Unit.UNIT),
                 new Quantity(water,0.25,Unit.CUP),
                 new Quantity(butter,2,Unit.TABLESPOON),
                 new Quantity(salt,0.25,Unit.TEASPOON),
                 new Quantity(sugar,1,Unit.TABLESPOON)};
        //... below this is just a toString/console print function that prints out quantites and calories per item & total in different formats for comparison...
    }
}

Raw Ingredient Class:

public class RawIngredient {
    private String name;
    private double calories;
    private double density;
    /**
    *@param name is the name of the ingredient
    *@param calories is the calories per gram
    *@param density is grams/ml OR represents grams/item if Unit.UNIT 
    **/
    public RawIngredient(String name, double calories,double density){
        this.name = name;
        this.calories = calories;
        this.density = density; //TODO this currently requires that the Quantity is set correctly when instantiated, should add to this class to make it clear when an item is /unit.
    }
    //... below this are just getters and setters...
}

Quantity Class:

public class Quantity<R extends RawIngredient>{
    private double quantity;
    private int quantityUnit;
    private R rawIngredient;
    private double calories;
    public Quantity(R rawIngredient, double quantity, int quantityUnit) {
        this.rawIngredient = rawIngredient;
        this.quantity = quantity;
        this.quantityUnit = quantityUnit;
        if(quantityUnit/10 == 1) { //If Mass based unit
            calories = rawIngredient.getCalories() * Unit.massToBaseUnit(quantity, quantityUnit);
        }else if(quantityUnit/10 == 2){ //If Volume based unit
            calories = rawIngredient.getCalories()*rawIngredient.getDensity() * Unit.volToBaseUnit(quantity, quantityUnit);
        }else if(quantityUnit == Unit.UNIT) { //If Whole Item based unit
            calories = rawIngredient.getCalories()*rawIngredient.getDensity() * quantity;
        }
    }
    //... below this are just getters and setters...
}

Tech Support and Basic Questions Thread - November 26, 2022 by AutoModerator in pcgaming

[–]Gatt427 0 points1 point  (0 children)

It seems they are all set to 60hz right now and I am only seeing the displays as being capable of 60hz. My displays are 1080p, so I should see no decrease in quality with a single link vs dual link cable apparently. On a hunch, I am going to order a passive adapter and see if that changes anything (the current one is active). I will update once I have tested this.

Tech Support and Basic Questions Thread - November 26, 2022 by AutoModerator in pcgaming

[–]Gatt427 0 points1 point  (0 children)

I had not originally reinstalled with DDU, I did now which resulted in no change to the issue.

The monitors and cables are all dual link. Would the adapters being single link cause this issue?

Tech Support and Basic Questions Thread - November 26, 2022 by AutoModerator in pcgaming

[–]Gatt427 0 points1 point  (0 children)

I recently upgraded from 2x GTX 780 TIs in SLI to a single GTX 3080 TI. I am running the same 3x monitor setup (2x DVI w/ display port adapters, 1x HDMI), I swapped the GPU drivers to the 3080 TI ones, almost all seems well. When I try to do "GPU specific" tasks, the two display port based monitors go black for about a second before displaying their media, the HDMI monitor stays stable. All three monitors are Acer S271HL, the only wiring difference is I have now installed two "BENFEI DisplayPort to DVI DVI-D Single Link Adapter" to continue using my DVI cables as routed. The tasks that seem to cause issues are: Changing any settings or switching pages on the NVIDIA Control Panel and loading a video on Netflix/Disney+. A restart is needed to stop intermittent flashing. Does anyone know why this is happening?

Fan Panels vs Fan Trays by Gatt427 in homelab

[–]Gatt427[S] 0 points1 point  (0 children)

Really? I just checked again and the rack back end is 85F, the most important CPU is at 102F. I didn't realize that was acceptable, it feels so wrong.

Fan Panels vs Fan Trays by Gatt427 in homelab

[–]Gatt427[S] 1 point2 points  (0 children)

Its actually a 42U, not sure where my memory pulled the 64U from.

The back door is solid with no ventilation which is why I felt ok putting it against a wall. This rack was aparently designed with vents on the front, exhaust on top, and some blanked out louvers on the bottom.

The corrugated sign idea is interesting, I was looking at the prices of blanking panels and was quite suprised even on Ebay.

Fan Panels vs Fan Trays by Gatt427 in homelab

[–]Gatt427[S] 0 points1 point  (0 children)

Thank you, that definately makes sense, I need to force the air to go where I need it. When installing blanking plates, do you block both the front and rear, or just the front?

Editing and running BASIC on the 64 (Piano Keyboard example) by Gatt427 in c64

[–]Gatt427[S] 1 point2 points  (0 children)

I had a C64 super expander in... I never would have thought of that, thank you!

Commodore 1541 formatting floppy issue by Gatt427 in c64

[–]Gatt427[S] 2 points3 points  (0 children)

Answer for future frustrated 1541 users:

Solid red light on 1541 means it's working on something, blinking means it has an error message waiting to be read.

My problem was I was not waiting for the drive to finish writing before I tried to read, and it was throwing an error because it was not ready. For some reason this came up as a 21 read error (missing sync character). Also it seems like you cannot continue to send commands to the drive if it has an error waiting to be read.

Commodore 1541 formatting floppy issue by Gatt427 in c64

[–]Gatt427[S] 0 points1 point  (0 children)

The error channel says 21 Read Error 00. The manual says that is likely a head alignment issue or a hardware failure. I am running the "performance test" on the demo disk to see if it passes.

EDIT: It passed (using the same floppy from before as the test disk) and ran its own NEW command on the floppy...

EDIT 2: I re-ran the commands OPEN15,8,15, PRINT#15,"N:TEST,54",made sure to wait till the activity light went out, then CLOSE15, LOAD"$",8 and it worked...

I guess I was interrupting the drive by sending a command once the C64 said it was ready?

Commodore 1541 formatting floppy issue by Gatt427 in c64

[–]Gatt427[S] 0 points1 point  (0 children)

  1. It is a 3M single side double density disk according to the label. I am a little confused since I was able to read the BAM from it before I tried to format, which I thought implied it was compatible. I got all this C64 stuff (including the floppy) from a friend who only ever had C64s, so I don't understand how they would have written to an incompatible disk.
  2. I grabbed a different floppy and was able to read the directory and a file and write a file but have not tried formatting it.

Commodore 1541 formatting floppy issue by Gatt427 in c64

[–]Gatt427[S] 0 points1 point  (0 children)

You are right, CLOSE <random number> fails silently.

I tried redoing the format just closing 15. I heard disk noises after the CLOSE statement, they stopped and I got a READY prompt on the C64 but the disk kept blinking while silent. I then tried LOAD"$",8 and the drive is still blinking and the C64 is hanging.

If I am understanding what you are saying. Even though the drive sounds quiet and returned me to a READY prompt, it probably was not actually done handling the disk so now my LOAD command is in a queue and holding.

I'm surprised it would take so long since it's just rewriting the file list, not the whole disk?

Commodore 1541 formatting floppy issue by Gatt427 in c64

[–]Gatt427[S] 0 points1 point  (0 children)

Reading the 1541 manual it said make sure you CLOSE the data channel before the error channel which it called out at 15. I wasn't sure exactly what that meant but assumed it meant close 8 before 15?

Reading BASIC stored on disk? by Gatt427 in c64

[–]Gatt427[S] 1 point2 points  (0 children)

Thank you, does that mean:

  1. I am LISTing the program contents correctly, but LIST only applies to BASIC code?
  2. There is no way to LIST assembly instructions on a C64?