0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AUTOSAR 846 AP, Figure 6.5: Service Discovery using PlantUML by ChatGPT

Posted at

AUTOSARは、Classic Platformは、EnterPriseArchitect(ソフト名)のファイルを配付している。
なぜか、より公開側に振ったはずのAdaptive Platrformでは、UML図を配布していない。

AUTOSAR APの図をChatGPTにPlantUMLで書いてもらう企画を考案。
今回は第9回目。

Explanation of ara::com API AUTOSAR 846, R23-11, AP
https://qiita.com/kaizen_nagoya/items/5c2bbd029f8d9bed641b

で参照している

Explanation of ara::com API
https://www.autosar.org/fileadmin/standards/R23-11/AP/AUTOSAR_AP_EXP_ARAComAPI.pdf

Figure 6.5: Service Discovery

AUTOSAR Adaptive Platfrom PlantUML with ChatGPT
https://qiita.com/kaizen_nagoya/items/4fef7700b57419ddf2c2

Si desea leer el código fuente de PlantUML, puede hacerlo seleccionando la solicitud de edición.
If you would like to read the source code of PlantUML, you can do by selecting the edit request.
PlantUMLのソースコードを読みたい方は、編集リクエストを選択するとソースコードが読めます。

CHatGPT

https://www.autosar.org/fileadmin/standards/R23-11/AP/AUTOSAR_AP_EXP_ARAComAPI.pdf のFigure 6.5: Service Discovery をPlantUMLで書き直してください。

ChatGPT:

AUTOSARの “Figure 6.5: Service Discovery” を PlantUML に書き直す例を以下に示します。図の内容を正確に把握できないので、典型的なサービス発見(Service Discovery)のシーケンスと登場要素を想定して構成しています。必要に応じて修正して使ってください。

もしよければ、あなたが持ってる “Figure 6.5” の具体的なメッセージ名・参加者名・詳細な流れを教えてもらえれば、それに沿った正確な PlantUML を作れます。どうしますか?

参加者名は、左からApplication 1 Service provider、Service Registry、Application 2 Service requesterです。メッセージ名は、上からoffer, find, callです。

ChatGPT:

了解しました。ご指定の参加者名とメッセージ名を反映した PlantUML のシーケンス図は以下の通りです。

このコードを PlantUML でレンダリングすると、
左から Application 1 Service provider → Service Registry → Application 2 Service requester の順で並び、
メッセージが上から offer → find → call となるシンプルなシーケンス図が得られます。

この図から、C++とRUSTのソースコードを生成してください。

ChatGPT:

以下は、提示いただいたシーケンス(offer → find → call)を 簡単な動作例として表したサンプルコードです。
実際のAUTOSAR ARACom APIや本格的なネットワーク通信を省略し、コンソール出力で動きを確認できるミニマルな擬似実装にしています。
C++例

#include <iostream>
#include <string>

class ServiceRegistry {
public:
    void offer(const std::string& serviceName) {
        std::cout << "[Registry] Service offered: " << serviceName << "\n";
        offeredService = serviceName;
    }

    bool find(const std::string& serviceName) const {
        std::cout << "[Registry] Searching for: " << serviceName << "\n";
        return (serviceName == offeredService);
    }

private:
    std::string offeredService;
};

class ServiceProvider {
public:
    ServiceProvider(ServiceRegistry& r) : registry(r) {}
    void offerService() { registry.offer("ExampleService"); }
    void call() { std::cout << "[Provider] Service logic executed.\n"; }
private:
    ServiceRegistry& registry;
};

class ServiceRequester {
public:
    ServiceRequester(ServiceRegistry& r) : registry(r) {}
    void findAndCall(ServiceProvider& provider) {
        if (registry.find("ExampleService")) {
            std::cout << "[Requester] Service found, calling provider.\n";
            provider.call();
        } else {
            std::cout << "[Requester] Service not found.\n";
        }
    }
private:
    ServiceRegistry& registry;
};

int main() {
    ServiceRegistry registry;
    ServiceProvider provider(registry);
    ServiceRequester requester(registry);

    provider.offerService();
    requester.findAndCall(provider);
    return 0;
}

Rust例

struct ServiceRegistry {
    offered_service: Option<String>,
}

impl ServiceRegistry {
    fn new() -> Self {
        ServiceRegistry { offered_service: None }
    }

    fn offer(&mut self, service: &str) {
        println!("[Registry] Service offered: {}", service);
        self.offered_service = Some(service.to_string());
    }

    fn find(&self, service: &str) -> bool {
        println!("[Registry] Searching for: {}", service);
        self.offered_service
            .as_ref()
            .map_or(false, |s| s == service)
    }
}

struct ServiceProvider<'a> {
    registry: &'a mut ServiceRegistry,
}

impl<'a> ServiceProvider<'a> {
    fn offer_service(&mut self) {
        self.registry.offer("ExampleService");
    }

    fn call(&self) {
        println!("[Provider] Service logic executed.");
    }
}

struct ServiceRequester<'a> {
    registry: &'a ServiceRegistry,
}

impl<'a> ServiceRequester<'a> {
    fn find_and_call(&self, provider: &ServiceProvider) {
        if self.registry.find("ExampleService") {
            println!("[Requester] Service found, calling provider.");
            provider.call();
        } else {
            println!("[Requester] Service not found.");
        }
    }
}

fn main() {
    let mut registry = ServiceRegistry::new();
    let mut provider = ServiceProvider { registry: &mut registry };
    let requester = ServiceRequester { registry: &registry };

    provider.offer_service();
    requester.find_and_call(&provider);
}

実装ポイント
ServiceRegistry が「offer」および「find」を担当。
ServiceProvider がサービスを提供し、call メソッドで処理を実行。
ServiceRequester が find でサービスを探し、見つかれば call を呼び出す。
このコードを実行すると、シーケンス図どおりに
offer → find → call の流れが標準出力に表示されます。
ChatGPT の回答は必ずしも正しいとは限りません。重要な情報は確認するようにしてください。

参照

ChatGPT利用の技4つ with ChatGPT
https://qiita.com/kaizen_nagoya/items/4a178bd6a09a4a471a7f

ChatGPTによるQiita記事の改良と補足
https://qiita.com/kaizen_nagoya/items/20604d6dd0702ab95c2f

ChatGPTによるQiita記事の改良と補足(2)
https://qiita.com/kaizen_nagoya/items/996275307ffc8c1243f8

本から始める 面倒なことはChatGPTにやらせよう by からあげ
https://qiita.com/kaizen_nagoya/items/f5ce2a18db54b5610e4b

MCP入門 〜面倒なことはAIエージェントにやらせよう〜 by からあげ を聞きながら
https://qiita.com/kaizen_nagoya/items/54b648c838fae8d57e38

【松尾研LLMコミュニティ】面倒なことはLLMにやらせよう "Beginning LLM"2024年10月17日 AI(9)
https://qiita.com/kaizen_nagoya/items/efdc23fbe67cdae2126e

設計:ChatGPTで特異解か一般解を求める AI(1)
https://qiita.com/kaizen_nagoya/items/4dec580e16a7c84b0ec4

みんなの使い方から学ぶ
https://qiita.com/kaizen_nagoya/items/8e7de492d896df94a36e

AI・機械学習 昨日、今日、明日
https://qiita.com/kaizen_nagoya/items/adb184c8fc7a65ac9756

DNA LLM and genome for survey 2200 papers by name.
https://qiita.com/kaizen_nagoya/items/ce8a28d6072f340a9d59

ChatGPTから学ぶ 3倍褒めて3分の1貶す
https://qiita.com/kaizen_nagoya/items/91e70fd8caa25076718b

AI時代の相棒は、キミに決めた! 推しのAIエージェントをシェアしよう!企画参加まとめへの序章
https://qiita.com/kaizen_nagoya/items/e3fd7557bac97d1b88f2

記事投稿数、いいね数の目標設定して ChatGPTに聞いてみた。
https://qiita.com/kaizen_nagoya/items/019e2ad9c3e45e45854e

AI時代の相棒は、キミに決めた! ChatGPT推し ver.0
https://qiita.com/kaizen_nagoya/items/8068a884fb2e64cd3c4f

無料ChatGPTの処理限界
https://qiita.com/kaizen_nagoya/items/84683aee26d9f4a28af0

by ChatGPT, with ChatGPT and people opinions.
https://qiita.com/kaizen_nagoya/items/57f00f9b48b25bc231e6

ChatGPTの使い方の利点と課題 by ChatGPT
https://qiita.com/kaizen_nagoya/items/0f469e473a6ed0407daa

DataRobot 風 AI agent Robotをあなたに
https://qiita.com/kaizen_nagoya/items/1ca8ca1dedefaf739d16

ChatGPTの賢い使い方
https://qiita.com/kaizen_nagoya/items/3a7e4583553543eeeeb3

ChatGPTの弱みをあなたに
https://qiita.com/kaizen_nagoya/items/3c97c63a22939e203905

ChatGPTで裸の王様
https://qiita.com/kaizen_nagoya/items/8377be38d3a763e93811

設計 仕様 制約 AI利用開発の鍵 by ChatGPT
https://qiita.com/kaizen_nagoya/items/1b9cb2f9d26308d84791

PowerPoint 筋書き(outline), 見直し(review), 見栄え加工 by ChatGPT
https://qiita.com/kaizen_nagoya/items/37bb97fc250fca37295b

逃げ回るChatGPTを追い詰めるには
https://qiita.com/kaizen_nagoya/items/cd60426e626ba05e0377

三人寄れば文珠の知恵は直交する能力前提 by ChatGPT
https://qiita.com/kaizen_nagoya/items/512e5611615e2426bb42

プログラマ3年で社長事業(未成年編) 博士論文支援追加
https://qiita.com/kaizen_nagoya/items/326452b5bf29c144c307

自殺防止手引き原稿 補足 by ChatGPT
https://qiita.com/kaizen_nagoya/items/7e459fa7edf7205c2667

しつけ(discipline) の測定視点 by ChatGPT
https://qiita.com/kaizen_nagoya/items/6b5ce03c545f7bbd8723

技術者は英語を学ぶ必要はない。英単語の羅列でいい=プログラム。
https://qiita.com/kaizen_nagoya/items/4fc3963a21e0339fd1c9

猫中心設計から鳥中心設計へ part2
https://qiita.com/kaizen_nagoya/items/4d7a5a33c85e0b01dc5d

プログラマ必須科目 ChatGPTにも確認
https://qiita.com/kaizen_nagoya/items/7b30d9d119792130facd

なんで音楽とプログラムの関係がうまく書けないか。
https://qiita.com/kaizen_nagoya/items/489a68d360df4b26f87d

AI利用業務手引き
https://qiita.com/kaizen_nagoya/items/f201b292f37dba16e9ef

C言語(C++)が必要な人と必要ない人
https://qiita.com/kaizen_nagoya/items/2afe9e846b55b24cb6f1

C言語(C++)が必要な人、必要ない人 ChatGPT
https://qiita.com/kaizen_nagoya/items/a074cb8cd292d8d94bd4

C言語を習得する3つの方法
https://qiita.com/kaizen_nagoya/items/84cab0888c193bba429b

C言語を習得する3つの方法 ChatGPT
https://qiita.com/kaizen_nagoya/items/4a3518a18fa49f46787f

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?