Module 7 — Case Study

🎯 Module Objective

By the end of this module, you will:


1️⃣ Scenario: Smart Factory

We are modeling a Smart Factory with:

We aim for a modular, query-friendly, and real-world model.


2️⃣ Step 1 — Define Base Components

Machine Interface

{
  "@id": "dtmi:com:smartfactory:Machine;1",
  "@type": "Interface",
  "@context": "dtmi:dtdl:context;2",
  "displayName": "Machine",
  "contents": [
    {
      "@type": "Property",
      "name": "operationalStatus",
      "schema": {
        "@type": "Enum",
        "valueSchema": "string",
        "enumValues": [
          { "name": "Running", "enumValue": "Running" },
          { "name": "Stopped", "enumValue": "Stopped" },
          { "name": "Maintenance", "enumValue": "Maintenance" }
        ]
      }
    },
    {
      "@type": "Telemetry",
      "name": "temperature",
      "schema": "double"
    },
    {
      "@type": "Command",
      "name": "start",
      "request": null,
      "response": null
    }
  ]
}

Sensor Interface

{
  "@id": "dtmi:com:smartfactory:Sensor;1",
  "@type": "Interface",
  "displayName": "Sensor",
  "contents": [
    {
      "@type": "Telemetry",
      "name": "reading",
      "schema": "double"
    },
    {
      "@type": "Property",
      "name": "unit",
      "schema": "string"
    }
  ]
}

3️⃣ Step 2 — Define Energy System

{
  "@id": "dtmi:com:smartfactory:EnergySystem;1",
  "@type": "Interface",
  "displayName": "Energy System",
  "contents": [
    {
      "@type": "Property",
      "name": "voltage",
      "schema": "double"
    },
    {
      "@type": "Property",
      "name": "load",
      "schema": "double"
    },
    {
      "@type": "Relationship",
      "name": "powers",
      "target": "dtmi:com:smartfactory:Machine;1"
    }
  ]
}

4️⃣ Step 3 — Facility Interface

{
  "@id": "dtmi:com:smartfactory:Facility;1",
  "@type": "Interface",
  "displayName": "Facility",
  "contents": [
    {
      "@type": "Component",
      "name": "machines",
      "schema": "dtmi:com:smartfactory:Machine;1"
    },
    {
      "@type": "Component",
      "name": "sensors",
      "schema": "dtmi:com:smartfactory:Sensor;1"
    },
    {
      "@type": "Component",
      "name": "energy",
      "schema": "dtmi:com:smartfactory:EnergySystem;1"
    }
  ]
}

5️⃣ Step 4 — Relationships

{
  "@type": "Relationship",
  "name": "monitors",
  "target": "dtmi:com:smartfactory:Machine;1"
}

6️⃣ Step 5 — Putting it Together

The factory model now has:

This is a full-stack real-world model.


7️⃣ Step 6 — Practice Exercise

  1. Add a conveyor belt interface with properties: speed, load, status
  2. Link conveyor belts to machines via relationships
  3. Add telemetry for temperature, vibrations, or error codes
  4. Extend facility to include operators component

8️⃣ Step 7 — Best Practices


Key Takeaways


Next Module (Module 8)

You now have a full Smart Factory model that is production-ready!

💬
AI Learning Assistant