Home /Modules/operating-system/SLHardDisk.sleela

SLHardDisk.sleela

lib/operating-system/hdd/SLHardDisk.sleela · 118 line(s) · sleela

<< lib/operating-system/hdd/SLHardDisk.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLHardDisk — a named rotational hard disk drive. It
     extends SLHardwareComponent and models the finite catalogue of HDD variants
     by the dimensions that distinguish them: form factor (3.5" / 2.5"),
     spindle speed (5400 / 7200 / 10000 / 15000 RPM), host interface (SATA III /
     SAS), recording technology (CMR vs SMR), cache size, capacity, and
     representative sustained transfer rate. A machine description requests an
     HDD by manufacturer + model and composes it as a bulk/boot storage device.
   
   Like SLSSD it is a storage device whose capacity-in-blocks maps onto the VM
   block store; media kind is rotational so SLMachineModel marks it MEDIA_HDD.
   
   Family: operating-system. Extends SLHardwareComponent. >>
#sleela 2.5
material;
class SLHardDisk extends SLHardwareComponent {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 10894;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-10";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }
  < Interface ordinals. >
  < 6 Gb/s >
  static final int IF_SATA3 = 0;
  < 12 Gb/s enterprise >
  static final int IF_SAS   = 1;
  < Recording technology. >
  < conventional (preferred) >
  static final int REC_CMR = 0;
  < shingled (higher density, slower random writes) >
  static final int REC_SMR = 1;

  < IF_* >
  int iface;
  < "3.5\"" / "2.5\"" >
  String formFactor;
  < spindle speed >
  int rpm;
  < REC_* >
  int recording;
  < DRAM cache >
  int cacheMb;
  int capacityGb;
  < representative sustained transfer rate >
  int sustainedMBps;
  < logical block size >
  int blockBytes;

  void configure(String manufacturer, String partName, int interfaceKind, int rpmSpeed, int capacityGigabytes) {
    configureComponent(manufacturer, partName, CLASS_HDD);
    iface = interfaceKind; rpm = rpmSpeed; capacityGb = capacityGigabytes;
    recording = REC_CMR; cacheMb = 256; blockBytes = 4096; formFactor = "3.5\"";
    < Sustained rate scales roughly with areal density + spindle speed. >
    if (rpm >= 15000)      { sustainedMBps = 300; }
    else if (rpm >= 10000) { sustainedMBps = 250; }
    else if (rpm >= 7200)  { sustainedMBps = 260; }
    else                   { sustainedMBps = 180; }
  }

  void setRecording(int tech) { recording = tech; }
  void setCache(int megabytes) { cacheMb = megabytes; }
  void setFormFactor(String ff) { formFactor = ff; }
  void setSustained(int mbps) { sustainedMBps = mbps; }

  boolean isSas()  { return iface == IF_SAS; }
  boolean isSmr()  { return recording == REC_SMR; }
  String interfaceName() { if (iface == IF_SAS) { return "SAS"; } return "SATA III"; }
  String recordingName() { if (recording == REC_SMR) { return "SMR"; } return "CMR"; }
  String form()          { return formFactor; }
  int spindleRpm()       { return rpm; }
  int cacheMegabytes()   { return cacheMb; }
  int capacityGigabytes(){ return capacityGb; }
  int transferMBps()     { return sustainedMBps; }
  int blockSize()        { return blockBytes; }

  int capacityBlocks() {
    int bytes = capacityGb * 1073741824;
    return bytes / blockBytes;
  }
}